mirror of
https://github.com/imjasonh/nescript
synced 2026-07-12 18:49:45 +00:00
M2: Add call graph analysis, recursion detection, and optimizer
Analyzer extensions: - Call graph construction from function bodies and state handlers - DFS-based recursion detection (direct and mutual) with E0402 errors - Max call depth computation per entry point with E0401 enforcement - Function declarations registered as symbols (E0503 for undefined calls) - Collects calls from all statement/expression types recursively Optimizer (new module): - Constant folding: evaluate known-constant arithmetic at compile time - Dead code elimination: remove ops with unused destination temps - Both operate per-basic-block in a single pass 171 tests total (22 new: 6 analyzer + 11 IR lowering + 5 optimizer) https://claude.ai/code/session_01W6eQFStA66EuMKHUFo2rx3
This commit is contained in:
parent
664ccc05db
commit
192d9c5c3d
9 changed files with 914 additions and 23 deletions
|
|
@ -133,7 +133,7 @@ pub enum IrOp {
|
|||
pub enum IrTerminator {
|
||||
/// Unconditional jump to a label.
|
||||
Jump(String),
|
||||
/// Conditional branch: if temp != 0 goto true_label else goto false_label.
|
||||
/// Conditional branch: if temp != 0 goto `true_label` else goto `false_label`.
|
||||
Branch(IrTemp, String, String),
|
||||
/// Return from function, optionally with a value.
|
||||
Return(Option<IrTemp>),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue