cure-java-ast
Java AST for the cure pipeline: a
u32-indexed arena with copy-increment ids, interned name symbols, and the
reference implementation of the engine's [Lang] trait.
Design
- Arena, not boxes. Every node is a
Node { data: NodeData, children }slot in oneVec; a node handle is aJavaId(u32)—Copy, comparable, sortable. Tree rewrites become cheap arena edits instead of pointer surgery. - Child list inline storage. Children ≤ 3 are stored inline in the node (no heap allocation); larger lists spill to the heap. Java grammar is fan-out-heavy with tiny arity, so the common case is allocation-free.
- Interned name symbols. Names live in a unit-level symbol table
(
Sym(u32)); nodes reference symbols, notStrings — 87 % of identifier occurrences in real corpora are repeats. - Derived analysis caches. The AST carries invalidation-tracked caches: per-node aggregate effects, variable types from scope resolution, and a region-event index (use/write/shadow events over name keys) that the engine binary-searches for kill analysis. Caches rebuild lazily and only for invalidated subtrees.
- Signatures vs. bodies. Class/member signatures are kept in plain
structs (
CompilationUnit,TypeDecl,Member, …) for fidelity; executable bodies live in the arena.
Navigating
use ;
/// Collect every reference to the variable `name` under `root`.
Construction normally happens via
cure-java-parser; printing via
cure-java-print; the rewrite
rules over this AST live in
cure-java-simplify — see the
pipeline example in the repository
README.
License: MIT. Zero runtime dependencies.