-
Notifications
You must be signed in to change notification settings - Fork 0
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
Track AST node between passes #30
Comments
As discussed in meet just now, I can see solutions to this which doesn't require AST node IDs. 1. Record "path" to nodee.g. For NB: "path" would not be stored as a string, but as a struct Path(Vec<PathSegment>);
enum PathSegment {
ProgramBody(u32),
ProgramDirective(u32),
ProgramHashtag,
ExpressionStatementExpression,
BinaryExpressionLeft,
BinaryExpressionRight,
/* ... lots more ... */
}
fn statement_from_path_mut<'a, 'p>(program: &'p mut Program<'a>, path: &Path) -> &'p mut Statement<'a> {
todo!();
}
fn expression_from_path_mut<'a, 'p>(program: &'p mut Program<'a>, path: &Path) -> &'p mut Expression<'a> {
todo!();
} 2. Record
|
Our semantic pass already generates an ast node id in |
Yes, but that part of semantic is not usable when the AST is mutable, due to aliasing restrictions. This is why |
Tracking in oxc-project/oxc#4188 for research on AST Node ID. |
In Rolldown, ast node information needs to be tracked across scans and transforms.
It's currently using spans to track the nodes, but once transformation is in, newly inserted statements does not have a SPAN so information is lost, and Rolldown will not function anymore :-(
From hyf: how to identity the same ast node in different visit passes
There's workaround for rolldown to use faked span that out of orignal text's length.
But this require oxc could handle span that is out of original source's length
The text was updated successfully, but these errors were encountered: