Commit graph

23 commits

Author SHA1 Message Date
overlookmotel
2c7bb9f6c8 refactor(ast): pass final ScopeFlags into visit_function (#4283)
We have a strange workaround for `visit_function` where we pass in `ScopeFlags`, to support creating the scope inside `Function`, but setting different flags for `MethodDefinition`s.

Previously `visit_function` took `Option<ScopeFlags>` and then did `flags.unwrap_or(ScopeFlags::empty()) | ScopeFlags::Function` to it. Personally, I found this confusing. When I was looking at `MethodDefinition`, I was wondering "It's a function, why doesn't it set Function flag too?"

This changes makes it more explicit and clear what `ScopeFlags` everything has.
2024-07-16 07:22:07 +00:00
Boshen
a71787572e
chore: remove unsafe_code = "warn" rust lint
Feels too verbose as we already have unsafe comment turned on
2024-07-15 10:39:08 +08:00
Boshen
83bd40db4e
chore: turn off doctest for all [[bin]] 2024-07-14 16:55:19 +08:00
rzvxa
aab7aaaa06 refactor(ast/visit): fire node events as the outermost one. (#4203)
I'm going to be AFK today(till about 9 PM UTC). Meanwhile, I Didn't want to be a blocker so here we go.
It would fix the #4200 merge if you guys find it in the correct order otherwise feel free to close it.
2024-07-12 03:27:59 +00:00
Boshen
8c54a2f1ed fix(tasks/ast_codegen): run cargo fmt synchronously (#4181)
relates #4152

This is my wild guess, because it works in my other script 143685deb1/xtask/src/main.rs (L21)
2024-07-11 02:59:30 +00:00
rzvxa
67fe75ec6c feat(ast, ast_codegen): pass the scope_id to the enter_scope event. (#4168) 2024-07-10 15:19:23 +00:00
rzvxa
3ba7cfed1f feat(ast_codegen): add #[visit(enter_before)] hint. (#4147)
Closes #4142

I can split it into 2 PRs but it seems pointless. Let me know if you guys disagree with me.
2024-07-10 14:02:29 +00:00
rzvxa
0b433108be feat(ast_codegen): add cli arguments to use with oxc_ast_codegen executable. (#4117)
```
Usage: oxc_ast_codegen [--dry-run] [--no-fmt] [--schema=ARG]

Available options:
        --dry-run     Runs all generators but won't write anything down.
        --no-fmt      Don't run cargo fmt at the end
        --schema=ARG  Path of output `schema.json`.
    -h, --help        Prints help information
```
2024-07-09 03:42:11 +00:00
rzvxa
6db630fab3 refactor(ast_codegen): cleanup usages of the generated outputs. (#4116) 2024-07-09 03:42:05 +00:00
rzvxa
91c792a2ce feat(ast_codegen): add ast builder generator. (#4098) 2024-07-09 00:47:23 +00:00
rzvxa
aa585d31e1
fix(ast_codegen, ast): visit ExpressionArrayElement as Expression. (#4061)
hotfix for #4060

I just added an edge case, We can come back to it later on and make it a
standard in our codegen.

The diff is big because it causes the code to reorder, The edge case
generated code doesn't follow the order in which they are defined in the
source of truth(eg `js.rs`)
2024-07-06 00:29:36 +08:00
rzvxa
1854a52bd7 feat(ast_codegen): introduce the #[span] hint. (#4012)
closes #3904
2024-07-02 10:18:58 +00:00
rzvxa
71e9286fa6 improvement(ast_codegen): use visit_as attribute to create aliased AstKinds. (#4011) 2024-07-02 10:18:56 +00:00
rzvxa
352c0b4103 pref(ast): inline visit walks with small bodies. (#4009)
~~Attempt to improve the performance of visitors, It is mostly for experiments. I'm not sure how much performance is there to gain back.~~

- [x] inline plural visits (eg: visit_statements)
- [x] inline enums when there are 5 or fewer match cases
- [x] inline structs when there are 5 or less fields
- [x] inline `Visit::alloc`
2024-07-02 10:18:55 +00:00
rzvxa
b51f75baf8 refactor(ast_codegen): no longer outputs discard variable for empty visitors. (#4008) 2024-07-02 10:18:53 +00:00
rzvxa
272df6ee90 feat(ast_codegen): support for generating VisitMut. (#4006) 2024-07-02 10:18:49 +00:00
rzvxa
7538af12d8 feat(ast_codegen): add visit generator (#3954)
~~The generated code is only here for the sake of my own comparison (instead of manually keeping a backup of the old generated file). I would clean this up as soon as it is ready, submit some parts of it as the down stack, and stack the actual generated code on top of this. So please don't let the huge diff distract you, It won't have many conflicts since almost all of these are the generated visit code, which is completely contained to its own module(other than some minor renaming refactors).~~

The order of function definitions is a bit different, I've used a depth-first search, We can switch to a breadth-first one to align functions more closely to the original.
2024-07-02 10:18:45 +00:00
Boshen
1852ea4fd2
chore: clean up unused deps 2024-06-30 19:04:44 +08:00
rzvxa
71c07c59d7 improvement(ast_codegen): better output formatting. (#3932)
We use prettyplease for formatting our generated code, Which has a lot of advantages over rustfmt, But sometimes it conflicts with our cargo fmt config,
Since it isn't configurable I just added a `cargo fmt` step after the generation process to prevent conflicts.
We might be able to not rely on prettyplease at all, But We have to test that one after we have most of our generated code, rustfmt usually bails on nested calls and macros so it might not work as our only solution. In contrast to that prettyplease is used in both bindgen and cargo-expand and is created for this exact reason(formatting generated code).
2024-06-29 05:37:15 +00:00
Boshen
4cf3c7645f refactor(parser): improve parsing of TypeScript types (#3903)
- [x] fix everything
2024-06-26 05:58:16 +00:00
rzvxa
2e026e1b7f feat(ast_codegen): generate ast_kind.rs. (#3888)
[List of 68 blacklisted items](https://github.com/oxc-project/oxc/pull/3888/files#diff-59cbea4a1444e752992821d3429a5f27bf1027a530977d075ec89aa55995912aR11)
2024-06-25 15:47:04 +00:00
rzvxa
09f4d3c4d3 feat(ast_codegen): add ImplGetSpanGenerator. (#3852)
This one is ready to replace the handwritten module.
2024-06-25 14:39:39 +00:00
rzvxa
f6c4ec44ca feat(tasks/ast_codegen): prototype for codegen AST related code (#3815)
Part of https://github.com/oxc-project/oxc/issues/3819
2024-06-25 13:54:50 +00:00