Expand description
Hermes ESTree AST — GC arena (juno-derived) + node model.
The node set in node is generated from
include/hermes/AST/ESTree.def with every parse family enabled — Flow,
TypeScript, JSX, and the parser’s “cover” grammar nodes — so a single
node::Node enum spans all of them.
The pieces a consumer touches:
context::Contextandcontext::GCLock— the arena that owns the nodes and the lock through which they are allocated and read.node::Node— one enum arm per node kind, over#[repr(C)]structs whose fields mirror the.defentry: structural children are&'gcreferences ornode_child::NodeLists, everything else is aCell.visitor::VisitorMutplusNode::visit_children_mut— transforms that rebuild only the spine whose children changed.dump::ESTreeJSONDumper— ESTree JSON matchinghermesc -dump-ast -dump-source-location=bothbyte for byte.
See rust/ARCHITECTURE.md for the design rationale and
doc/superpowers/specs/2026-06-03-ast-design.md for the port spec.
Modules§
- context
- Garbage-collected Storage structures for AST nodes.
- dump
- Port of
lib/AST/ESTreeJSONDumper.cpp. Emits an AST as ESTree JSON — the byte-for-byte differential-oracle surface (the gate lands at Parser time). The per-kind field walk + the"type"name live in the generatednode.rs(Node::dump_children/Node::node_type_str); this module is the driver: modes, locations, therawprop, value emission, and the public entry points. - node
- @generated by gen_nodes.py from include/hermes/AST/ESTree.def — DO NOT EDIT.
Run
python3 rust/crates/ast/gen_nodes.pyto regenerate. - node_
child - Child/leaf field types and the NodeList for the AST.
- visitor
- AST traversal.
Structs§
- NodeId
- Unique, never-reused identity of an AST node within its
Context. Assigned byContext::allocfrom a monotonic counter (starting at 1);UNASSIGNED(0) only exists on metadata not yet stored in the arena. Consumers outside sema key side tables by NodeId (see the Sema design spec §3.1): unlike raw addresses, ids never alias after arena slot reuse; unlike NodeRc keys, they don’t pin garbage. Insert entries only with the node in hand under GCLock — a stored id may already be dead. - SemaId
- Opaque handle to a resolved Sema entity (scope / decl / function info).
The AST only stores the raw index in a
Cell; thesemacrate wraps it in the typed newtypes of itsidsmodule and owns the interpretation.
Traits§
- Heap
Size - Trait for allowing users to query how much memory a type uses in the heap.