Commit graph

21 commits

Author SHA1 Message Date
Boshen
a558492bf9 feat(codegen): implement BinaryExpressionVisitor (#4548)
part of https://github.com/oxc-project/backlog/issues/58

`monitor-oxc` run: https://github.com/oxc-project/monitor-oxc/actions/runs/10179047831
binary expression stack length tally using `counts` in top 100 npm packages from monitor-oxc:

```
29772 counts
(  1)    17652 (59.3%, 59.3%): 0
(  2)     5772 (19.4%, 78.7%): 1
(  3)     3204 (10.8%, 89.4%): 2
(  4)     1276 ( 4.3%, 93.7%): 3
(  5)      616 ( 2.1%, 95.8%): 4
(  6)      308 ( 1.0%, 96.8%): 5
(  7)      202 ( 0.7%, 97.5%): 6
(  8)      168 ( 0.6%, 98.1%): 7
(  9)      114 ( 0.4%, 98.5%): 9
( 10)       90 ( 0.3%, 98.8%): 8
( 11)       84 ( 0.3%, 99.0%): 13
( 12)       58 ( 0.2%, 99.2%): 10
( 13)       48 ( 0.2%, 99.4%): 12
( 14)       32 ( 0.1%, 99.5%): 11
( 15)       20 ( 0.1%, 99.6%): 134
( 16)       16 ( 0.1%, 99.6%): 18
( 17)       16 ( 0.1%, 99.7%): 20
( 18)       12 ( 0.0%, 99.7%): 19
( 19)       12 ( 0.0%, 99.8%): 35
( 20)       12 ( 0.0%, 99.8%): 51
( 21)       10 ( 0.0%, 99.8%): 15
( 22)        6 ( 0.0%, 99.9%): 17
( 23)        6 ( 0.0%, 99.9%): 21
( 24)        6 ( 0.0%, 99.9%): 45
( 25)        4 ( 0.0%, 99.9%): 14
( 26)        4 ( 0.0%, 99.9%): 26
( 27)        4 ( 0.0%, 99.9%): 53
( 28)        2 ( 0.0%, 99.9%): 172
( 29)        2 ( 0.0%, 99.9%): 214
( 30)        2 ( 0.0%,100.0%): 22
( 31)        2 ( 0.0%,100.0%): 27
( 32)        2 ( 0.0%,100.0%): 28
( 33)        2 ( 0.0%,100.0%): 29
( 34)        2 ( 0.0%,100.0%): 31
( 35)        2 ( 0.0%,100.0%): 36
( 36)        2 ( 0.0%,100.0%): 46
( 37)        2 ( 0.0%,100.0%): 55
```
2024-07-31 12:44:19 +00:00
Boshen
35654e665c feat(codegen): align operator precedence with esbuild (#4509)
closes #4339
2024-07-28 11:48:51 +00:00
Boshen
6a94e3f573 fix(codegen): fixes for esbuild test cases (#4503) 2024-07-28 08:57:15 +00:00
Boshen
3d88f20cbb
fix(codegen): print shorthand for all { x } variants (#4374)
closes #4340
2024-07-21 19:54:21 +08:00
Boshen
e167ef79c6 fix(codegen): print parenthesis properly (#4245)
`TSParenthesizedType` handles parenthesis in ts types.

It should be considered a bug if parenthesis is not printed correctly after this PR.
2024-07-14 04:13:10 +00:00
Boshen
83c2c62f7b feat(codegen): add option for choosing quotes; remove slow choose_quot method (#4219) 2024-07-12 03:08:22 +00:00
IWANABETHATGUY
1c117eb20d
fix: avoid print extra semicolon after accessor property (#4199)
## Before
```js
export default class Foo { @x @y accessor #aDef = 1 }
```
**output** 
```bash
Original:
export default class Foo { @x @y accessor #aDef = 1 }


Printed:
export default class Foo {
        accessor #aDef=1;;
}

```
2024-07-11 20:16:02 +08:00
Boshen
aaac2d8775
fix(codegen): preserve parentheses from AST instead calculating from operator precedence (#4055)
…operator precedence

Calculating from operator precedence is currently unsafe and will result
incorrect semantics.
2024-07-05 14:01:17 +08:00
underfin
9e8709f06e
fix(sourcemap): should add tokens for unordered span (#3941)
close: https://github.com/oxc-project/oxc/issues/3843
2024-06-27 20:24:22 +08:00
Boshen
5a99d30eba feat(codegen): improve codegen formatting (#3735) 2024-06-18 11:10:36 +00:00
Boshen
bf9b38a197 feat(codegen): improve codegen formatting (#3731) 2024-06-18 04:14:10 +00:00
Boshen
38a75e559b feat(coverage): improve codegen (#3729) 2024-06-18 02:53:09 +00:00
Boshen
da1e2d0e9b fix(codegen): improve typescript codegen (#3708)
Remaining issues are tracked in https://github.com/oxc-project/oxc/issues/3692
2024-06-17 09:34:54 +00:00
Boshen
534242a729
feat(codegen)!: remove CodegenOptions::enable_typescript (#3674)
The typescript transform pass is now required to strip typescript syntax
for codegen to print things properly.

Codegen will now print whatever is in the AST.
2024-06-14 21:56:00 +08:00
Dunqing
affb2c864e
fix(codegen): print indentation before directive (#3512) 2024-06-05 16:32:12 +08:00
Boshen
e2dd8ac8fc feat(syntax): export is_reserved_keyword and is_global_object method (#3384) 2024-05-22 04:58:04 +00:00
Don Isaac
a12ed0fd26
fix(codegen): using declaration in for statement (#3285)
Fixes conformance tests for `using` declarations in for statements, e.g.
```ts
for (using x = 1;;) {}
```
2024-05-14 23:10:47 -04:00
Dunqing
a227050ed0
chore: update babel repo (#3205) 2024-05-08 20:15:15 +08:00
underfin
64c4b825f1
chore: improve sourcemap visualizer (#2886)
The pr intend to improve `SourcemapVisualizer` log mapping.

- add the mapping for last token to final position of source
- fix token mapping
2024-04-03 10:45:00 +08:00
underfin
9609c34e6d
fix(codegen): CallExpression sourcemap (#2717) 2024-03-14 07:53:22 +00:00
Boshen
8bb1084863
feat(codegen): add sourcemap (#2565)
Co-authored-by: underfin <2218301630@qq.com>
2024-03-03 14:44:49 +08:00