Replies: 4 comments 2 replies
-
Don't we store ast nodes in a bumpalo arena? Can we just use their index as an id for the node to avoid the idea of a "lazy" id. My concern with lazy ids is it will cause code that needs an id to have to either branch or risk panic. Either case will lead to a performance degredation. |
Beta Was this translation helpful? Give feedback.
-
We currently keep a immutable tree after the first pass oxc/crates/oxc_semantic/src/node.rs Lines 47 to 52 in 018675c Perhaps need to make this data structure mutable so that newly created ast nodes can be tracked after the transformer pass. |
Beta Was this translation helpful? Give feedback.
-
You may want to take a look at my TypeScript type inference port: https://gist.github.com/Boshen/d189de0fe0720a30c5182cb666e3e9a5 There is a workaround where I used the ast node spans as index lookups:
You may want to start with this approach and see whether it works or not. This lookup works for all AST nodes except for So you may want to create different look up tables for different purposes. |
Beta Was this translation helpful? Give feedback.
-
Continue in #5689 |
Beta Was this translation helpful? Give feedback.
-
Currently the Semantic pass creates specialized ids such as
symbol_id
andreference_id
that are customized and only generated when encountering the relevant type of data. However, a large variety of alternative passes such as type association and narrowing for the minifier would like to associate data with lots of kinds of nodes (function usages of features likethis
, expression constant result+effects, etc.).Instead of having intrusive PR changes to allow for this, it would be ideal to allow lazily generation of identifiers for all AST Nodes. This would allow for passes to share the identifiers as well.
Per storage and existence check concerns, this change would bloat the storage of AST Nodes with a lazy identifier, but we already have to do existence checks for the
Cell<Option<...>>
approach.My suggestion is that we enable lazy identifier generation for each kind of AST Node and allow multiple passes to use this to associate like:
Beta Was this translation helpful? Give feedback.
All reactions