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

Reduce number of attrs for #[visited_node] used by AST codegen #4281

Closed
overlookmotel opened this issue Jul 15, 2024 · 2 comments · Fixed by #4371
Closed

Reduce number of attrs for #[visited_node] used by AST codegen #4281

overlookmotel opened this issue Jul 15, 2024 · 2 comments · Fixed by #4371
Assignees
Labels
A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Comments

@overlookmotel
Copy link
Collaborator

Currently:

#[visited_node]
pub enum Expression<'a> {
    #[visit_args(flags = ScopeFlags::Function)]
    FunctionExpression(Box<'a, Function<'a>>),
    /* ... */
}

#[visited_node]
pub struct TryStatement<'a> {
    /* ... */
    #[visit_as(FinallyClause)]
    pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
}

Could we reduce the number of "special" attrs by changing visit_args(...) / visit_as(...) to visit(args(...)) / visit(as(...))?

#[visited_node]
pub enum Expression<'a> {
    #[visit(args(flags = ScopeFlags::Function))]
    FunctionExpression(Box<'a, Function<'a>>),
    /* ... */
}

#[visited_node]
pub struct TryStatement<'a> {
    /* ... */
    #[visit(as(FinallyClause))]
    pub finalizer: Option<Box<'a, BlockStatement<'a>>>,
}

@rzvxa What do you think? Not a big deal, but I think it'd be neater. I suspect we may end up adding more attrs later on (it may be useful, for instance, to tag all TS-only fields #[typescript]) and it could get out of hand.

@overlookmotel overlookmotel added C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior A-ast Area - AST labels Jul 15, 2024
@rzvxa
Copy link
Collaborator

rzvxa commented Jul 15, 2024

Good idea, I added the visit_args, and when the need for visit_as was raised I just copied the parsing of the previous one. I'll merge them together.

@overlookmotel
Copy link
Collaborator Author

Implemented in #4371.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants