Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST visitor with bottom-up reading WIP #3152

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ oxc_transformer = { version = "0.12.5", path = "crates/oxc_transformer" }
oxc_sourcemap = { version = "0.12.5", path = "crates/oxc_sourcemap" }

# publish = false
oxc_ast_macros = { path = "crates/oxc_ast_macros" }
oxc_macros = { path = "crates/oxc_macros" }
oxc_linter = { path = "crates/oxc_linter" }
oxc_prettier = { path = "crates/oxc_prettier" }
oxc_tasks_common = { path = "tasks/common" }
oxc_traverse = { path = "crates/oxc_traverse" }

napi = "2"
napi-derive = "2"
Expand All @@ -110,6 +112,7 @@ ignore = "0.4.22"
itertools = "0.12.1"
jemallocator = "0.5.4"
lazy_static = "1.4.0"
memoffset = "0.9.1"
miette = { version = "7.2.0", features = ["fancy-no-syscall"] }
mimalloc = "0.1.41"
num-bigint = "0.4.4"
Expand All @@ -132,6 +135,7 @@ tempfile = "3.10.1"
thiserror = "1.0.59"
tokio = "1"
tower-lsp = "0.20.0"
trybuild = "1.0.93"
unicode-id-start = "1.1.2"
ureq = { version = "2.9.6", default-features = false }
url = "2.5.0"
Expand Down
22 changes: 22 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# TODO

* Set enum discriminants for `Ancestor` so that `is_*` can use bitwise ops + `retag_stack` can write 1 byte only.
* Compiler does not auto-optimize `matches!()` in `is_*` functions. Need to do it manually.
* See `ancestor_type2` branch.
* Need to handle big endian systems where bytes are in reverse order.
* That's easy, but how to run tests on big endian? Miri?
* Implement `Debug` for `Ancestor` and `AncestorWithout*` types
* Implement intermediate `as_ref` method which creates an object of references, which debug can use.
* Improve API for `Ancestor::is_via_*`
* API to read siblings in a Vec.
* API to get which index current node is in a Vec.
* API to allow mutating other branches of AST
* I think all that's required is to:
* Pass `&mut TraverseCtx` to `enter_*` and `exit_*`
* Add `parent_mut`, `ancestor_mut` methods to `TraverseCtx`
* Add `span_mut`, `directives_mut` etc to all `*Without*` types
* Mutable borrow on `TraverseCtx` and `Ancestor` prevents creating more than 1 mut ref at a time
* Mutable borrow on `TraverseCtx` unfortunately also blocks calling `ctx.alloc()`.
* Can solve that with e.g. `ctx.ancestry.parent_mut()` + `ctx.ast.alloc()` - separate properties
can be mut borrowed at same time.
* Move `Span` to constant position in all structs, for fast lookup?
7 changes: 4 additions & 3 deletions crates/oxc_ast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ workspace = true
doctest = false

[dependencies]
oxc_allocator = { workspace = true }
oxc_span = { workspace = true }
oxc_syntax = { workspace = true }
oxc_allocator = { workspace = true }
oxc_ast_macros = { workspace = true }
oxc_span = { workspace = true }
oxc_syntax = { workspace = true }

bitflags = { workspace = true }
num-bigint = { workspace = true }
Expand Down
Loading