Skip to content

Codegen AST related code #3819

@Boshen

Description

@Boshen

Background

For keeping compilation speed down for ourselves and our downstream crate users, I have avoided using macros to generate boilerplate code at all cost.

All performance issues (runtime and compilation speed) are considered as bugs in this project.

But due to the amount of AST related supporting code has expanded over the last few months, and our desire to experiment with different ideas with the AST, our current approach of manually updating everything is no longer functional.

The goal of this task is to provide code generation for all AST node related code.

Requirements

  • no build.rs published to the user
  • all generated code are checked into git
  • no nightly
  • Rust code residing in crates/oxc_ast should be the source of truth

Workflow

  • a user changes the oxc_ast crate
  • a watch change picks it up
  • parse all #[visited_node]
  • saves them into a model, e.g. struct ASTModel { name: String, attributes: Vec<Attributes> }
  • generate code and save file

Code to generate

  • ASTKind (Milestone 1)
  • GetSpan (Milestone 2)
  • Hash, PartialEq implementations (Milestone 3)
  • ASTBuilder (Milestone 4)
  • Visit (Milestone 5)
  • VisitMut (Milestone 5)
  • Traverse, remove current js code (Milestone 6)
  • typescript definition for napi and wasm moving the scope to AST transfer.

Every milestone should be a stack of PRs, since they will involve changing other files as well.

Metadata

Metadata

Assignees

Labels

C-enhancementCategory - New feature or request

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions