feat(llvm): Phase 132-P2 - Dict ctx removal (FunctionLowerContext SSOT completion)

Completed SSOT unification for FunctionLowerContext by removing the manual
dict ctx creation and assignment in function_lower.py.

Changes:
- Removed builder.ctx = dict(...) creation (18 lines, lines 313-330)
- Removed builder.resolver.ctx assignment (no longer needed)
- Confirmed instruction_lower.py uses context=owner.context throughout
- Added phase132_multifunc_isolation_min.hako test for multi-function isolation
- Extended phase132_exit_phi_parity.sh with Case C (Rust VM context test)

Testing:
- Phase 132 smoke test: All 3 cases PASS
- Phase 87 LLVM exe test: PASS (Result: 42)
- STRICT mode: PASS
- No regressions: Behavior identical before/after (RC:6 maintained)

Impact:
- Reduced manual context management complexity
- FunctionLowerContext now sole source of truth (SSOT)
- Per-function state properly isolated, no cross-function collisions
- Cleaner architecture: context parameter passed explicitly vs manual dict

🤖 Generated with Claude Code
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-15 12:12:54 +09:00
parent a15d1e97e6
commit aad01a1079
4 changed files with 70 additions and 21 deletions

View File

@ -308,26 +308,8 @@ def lower_function(builder, func_data: Dict[str, Any]):
from builders.block_lower import resolve_jump_only_snapshots as _resolve_jump_only_snapshots
_resolve_jump_only_snapshots(builder, block_by_id, context)
# Optional: capture lowering ctx for downstream helpers
try:
builder.ctx = dict(
module=builder.module,
i64=builder.i64,
i32=builder.i32,
i8=builder.i8,
i1=builder.i1,
i8p=builder.i8p,
vmap=builder.vmap,
bb_map=builder.bb_map,
preds=builder.preds,
block_end_values=context.block_end_values,
resolver=builder.resolver,
trace_phi=os.environ.get('NYASH_LLVM_TRACE_PHI') == '1',
verbose=os.environ.get('NYASH_CLI_VERBOSE') == '1',
)
builder.resolver.ctx = builder.ctx
except Exception:
pass
# Phase 132-P2: Dict ctx removed; FunctionLowerContext is now SSOT
# All context access goes through owner.context (passed to instruction handlers)
# Phase 131-4 Pass B (now Pass B2): Finalize PHIs (wires incoming edges)
# Phase 132-P1: Pass context Box for function-local state isolation