Commit Graph

14 Commits

Author SHA1 Message Date
overlookmotel b28051fb12 refactor(all): pass [v] for single-value ArenaVec builder args (#24623)
Pure refactor. Just shorten code.

#24621 made AST builder methods take arrays as params.

Replace `ArenaVec::from_value_in(v, alloc)` with `[v]` where the `ArenaVec` is passed to an AST builder method.

```rs
let block = Statement::new_block_statement(
    SPAN,
    ArenaVec::from_value_in(return_stmt, ctx),
    ctx,
);
```

\->

```rs
let block = Statement::new_block_statement(SPAN, [return_stmt], ctx);
```
2026-07-17 13:49:39 +00:00
overlookmotel c1a074cdc8 refactor(all): pass [] for empty ArenaVec args to AST builder methods (#24622)
Pure refactor. Just shorten code.

#24621 made AST builder methods take arrays as params.

Replace `ArenaVec::new_in(...)` arguments written inline at AST builder method call sites with the empty array literal `[]`.

```rs
let block = Statement::new_block_statement(SPAN, ArenaVec::new_in(ctx), ctx);
```

\->

```rs
let block = Statement::new_block_statement(SPAN, [], ctx);
```
2026-07-17 13:49:39 +00:00
overlookmotel b7cd88dcd6 refactor(minifier): switch to new AstBuilder (#23832)
Part of #23043. Migrate `oxc_minifier` over to new `AstBuilder`.
2026-06-26 18:17:30 +00:00
overlookmotel c9cd809e50 refactor(str)!: rename Atom to Str (#20835)
Pure refactor.

Rename `Atom` to `Str`. The name "Atom" is a leftover from when we used to intern strings (years ago), and is misleading now.

Just call it `Str`. This follows the naming convention we have for arena-allocated versions of other types e.g. `Box`, `Vec`, `HashMap` - which we name the same as the native equivalents but with a lifetime (`Box<'a>` not `ArenaBox<'a>`, so `Str<'a>` not `ArenaStr<'a>`).

Rename all variables that contained "atom", and methods which relate to `Str`s to match the new type name.

Rename `as_atom` methods to `as_arena_str`. The longer name is required here to disambiguate from `as_str` methods which return a `&str`.

Some variables called "atom" still exist in `oxc_regular_expression` crate - that's a different meaning of "atom" - the meaning defined in regexp spec.

The diff of this PR is large but it's 100% renaming. No substantive or unrelated changes whatsoever.
2026-03-30 02:40:33 +00:00
Boshen 8a5c9b971e refactor(minifier,ecmascript): clean up is_global_reference (#12953) 2025-08-10 15:16:53 +08:00
Boshen 0c5bffc052 refactor(ecmascript): change IsGlobalReference to GlobalContext (#12952) 2025-08-10 06:57:13 +00:00
Boshen 5a46641e94 refactor(ecmascript): move get_constant_value_for_reference_id to IsGlobalReference trait (#11810) 2025-06-19 13:30:39 +00:00
overlookmotel f3eaefbf1b feat(ast)!: add value field to BigIntLiteral (#11564)
Add `value` field to `BigIntLiteral`, same as the other literal types.

Once upon a time, we stored the value as a `BigInt` which normalized the representation (removing `_`s, and converting e.g. `0xFF` to `255`). But we had to remove it because `BigInt` owns a heap allocation, and this caused a memory leak.

https://github.com/oxc-project/oxc/commit/50fe0fef73027f10740e68a65a78216933b5d8a0

This PR brings back the `value` field, but avoids memory leak by storing the normalized value as a string (`Atom`).

This has effects in various places in the codebase:

* Brings our JS-side AST into line with ESTree (fixing the test cases broken by #11563).
* Fixes edge cases in a couple of lint rules.
* Codegen now prints bigints in normalized form e.g. `0xFFn` is printed as `255n`.
* Changes behavior of 1 function in `oxc_ecmascript`.

I've made comments below on the parts I'm not so sure about. Review would be very welcome!
2025-06-09 02:28:46 +00:00
Boshen 7284135135 refactor(ast)!: remove trailing_commas from ArrayExpression and ObjectExpression (#10431)
closes #10419

This change reduces the size of these AST nodes, saving a bit of memory.

`ArrayExpression`: 56 -> 40
`ObjectExpression`: 56 -> 40
`ArrayAssignmentTarget`: 80 -> 64

Also removes the annoying `None` argument from these AST node builders.
2025-04-16 04:04:12 +00:00
sapphi-red f5bbd5d5a9 fix(ecmascript): fix toString for negative numbers (#9508)
`console.log("" + -0/0)` was compressed to `console.log("-NaN")` where it should be `console.log("NaN")`.
2025-03-03 12:41:42 +00:00
Boshen 1d81adac48 Rust Edition 2024 (#9289)
closes #9271

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 11:56:25 +08:00
sapphi-red 36c8640f1e feat(ecmascript): support more string concatenation (#9121) 2025-02-15 00:39:48 +00:00
sapphi-red 17c745cb54 fix(ecmascript): to_string for object with toString (#9104)
`({} + "")` returns `"[object Object]"` but `({ toString() { return "foo" } } + "")` does not.
2025-02-14 08:58:33 +00:00
sapphi-red cfc71f9581 fix(ecmascript): to_string for shadowed undefined (#9103)
`to_string` was returning `"undefined"` for shadowed `undefined` as well.
2025-02-14 08:58:33 +00:00