cure-engine
The language-agnostic core of cure: a semantic-preserving code simplification engine — pattern matching, tree rewrites, effect analysis, and a fixed-point convergence driver.
This crate knows nothing about Java. It operates on any tree whose
language implements the [Lang] trait: you provide an arena of nodes with
stable ids, name resolution, and effect queries; the engine provides rule
application, work invalidation, and iteration to a fixed point.
When to use it standalone
You are building a simplifier / normalizer / deobfuscator for your own language or AST and want the engine machinery (not the Java rules):
- rule dispatch + fixed-point driver (
simplify— re-runs until no rule applies; pings-pongs are bounded) - edit invalidation: every accepted edit invalidates exactly the affected ancestor chains and re-analysis caches
- region event index: use/write/shadow events over stable name keys, with binary-search queries for kill-analysis rules (dead stores, dominating-path logic lives here)
- cost model: rewrites only apply when they provably reduce node cost
- effect analysis (pure / read / write / opaque) gating every transform
The reference implementation of the trait is
cure-java-ast (arena AST with
u32 node ids, interned name keys).
Entry points
use ;
/// Run a rule set over `root` until fixed point.
;
Rules are pattern → rewrite functions receiving a RewriteCtx (node access,
children, effect queries). Config toggles individual rules and the
optional/dead-code tiers.
The Java front end lives in the sibling crates — see the pipeline example in the repository README:
| Crate | Role |
|---|---|
| cure-java-ast | arena AST, Lang implementation |
| cure-java-parser | fault-tolerant Java parser |
| cure-java-print | canonical printer/formatter |
| cure-java-simplify | the Java rule pack |
License: MIT. Zero runtime dependencies.