oxc-project / oxc-project/backlog
AST template macros
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
This is the code we have to write in transformer to generate let Foo;:
let kind = VariableDeclarationKind::Let;
let declarations = {
let ident = BindingIdentifier::new(SPAN, name.clone());
let pattern_kind = self.ctx.ast.binding_pattern_identifier(ident);
let binding = self.ctx.ast.binding_pattern(pattern_kind, None, false);
let decl = self.ctx.ast.variable_declarator(SPAN, kind, binding, None, false);
self.ctx.ast.new_vec_single(decl)
};
Declaration::VariableDeclaration(self.ctx.ast.variable_declaration(
SPAN,
kind,
declarations,
Modifiers::empty(),
))
Seems a bit bananas! Very long to write, and non-trivial to understand at first glance what the code is doing.
Surely we can find some way to reduce this.
Like: ast!{ let #name; }
The obvious problem is compile time impact of macros. Can we find some way to precompile macro expansion so we can enjoy a simpler code style without paying the compile-time price?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the transformer code that manually constructs the let Foo; AST and trace the AST builder calls shown in the issue. Investigate whether an ast!{ let #name; }-style macro or precompiled expansion can reduce this code without unacceptable compile-time impact. Done means a concrete, validated approach for simpler AST generation with its compile-time trade-offs understood.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100