Commit Graph

5 Commits

Author SHA1 Message Date
9170f0a85d refactor(mir): Remove VariableContext legacy fields (Phase 2-6/7)
完全移行→削除の安全順序(Option C)に従い、VariableContext の
deprecated フィールドと sync helpers を完全削除。

## Changes
- Migrated all 66+ access sites to variable_ctx.variable_map
- Removed 1 deprecated field (variable_map) from MirBuilder
- Removed 2 sync helpers (sync_variable_ctx_to_legacy, sync_legacy_to_variable_ctx)
- Fixed BoxCompilationContext.variable_map references (kept as-is, different scope)
- Fixed ExitBindingBuilder.variable_map references (kept as-is, local field)
- Updated observer.rs to use variable_map() accessor method

## JoinIR Integration Verified
- CarrierInfo::from_variable_map() works correctly
- ExitLine contract maintained (Phase 132-135)
- NYASH_TRACE_VARMAP debug support preserved
- Pattern 1-5 lowering all functional

## Tests
- cargo test --release --lib: 1033 passed, 0 failed
- phase135_trim_mir_verify.sh: PASS (MIR SSA/ValueId OK)
- cargo build --release: SUCCESS
- Deprecation warnings: reduced (86 remaining, from other contexts)

## Statistics
- 27 files changed
- 146 insertions(+), 174 deletions(-)
- Net: -28 lines

Phase 2 Progress: 6/7 contexts complete (86%)
-  MetadataContext
-  CoreContext
-  TypeContext
-  ScopeContext
-  BindingContext
-  VariableContext (this commit)
-  CompilationContext (Phase 2-7 next)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-16 03:48:44 +09:00
d4597dacfa feat(joinir): Phase 245C - Function parameter capture + test fix
Extend CapturedEnv to include function parameters used in loop conditions,
enabling ExprLowerer to resolve variables like `s` in `loop(p < s.length())`.

Phase 245C changes:
- function_scope_capture.rs: Add collect_names_in_loop_parts() helper
- function_scope_capture.rs: Extend analyze_captured_vars_v2() with param capture logic
- function_scope_capture.rs: Add 4 new comprehensive tests

Test fix:
- expr_lowerer/ast_support.rs: Accept all MethodCall nodes for syntax support
  (validation happens during lowering in MethodCallLowerer)

Problem solved: "Variable not found: s" errors in loop conditions

Test results: 924/924 PASS (+13 from baseline 911)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 13:13:08 +09:00
abfe0b198b feat(joinir): Phase 195 - Unified JoinLoopTrace for all JoinIR debug output
Created centralized tracing module for JoinIR loop lowering operations,
consolidating scattered eprintln! calls into a single SSOT interface.

# Implementation

1. **Created trace.rs module** (~233 lines)
   - JoinLoopTrace struct with env var controls
   - Unified API: pattern(), varmap(), joinir_stats(), phi(), merge(), etc.
   - Global singleton via trace() function
   - Supports 5 env vars: NYASH_TRACE_VARMAP, NYASH_JOINIR_DEBUG,
     NYASH_OPTION_C_DEBUG, NYASH_JOINIR_MAINLINE_DEBUG, NYASH_LOOPFORM_DEBUG

2. **Updated debug.rs** - Delegates trace_varmap() to JoinLoopTrace

3. **Updated routing.rs** - All eprintln! replaced with trace calls (10 instances)

4. **Updated pattern routers** - All 3 patterns now use unified trace
   - pattern1_minimal.rs: 6 replacements
   - pattern2_with_break.rs: 6 replacements
   - pattern3_with_if_phi.rs: 6 replacements
   - router.rs: 2 replacements

5. **Updated merge/block_allocator.rs** - 6 eprintln! → trace calls

# Benefits

- **Single Source of Truth**: All trace control through environment variables
- **Consistent Format**: Unified [trace:*] prefix for easy filtering
- **Zero Overhead**: No output when env vars unset
- **Easy Extension**: Add new trace points via existing API
- **Better Debug Experience**: Structured output with clear categories

# Testing

 cargo build --release - Success
 NYASH_TRACE_VARMAP=1 - Shows varmap traces only
 NYASH_JOINIR_DEBUG=1 - Shows joinir + blocks + routing traces
 No env vars - No debug output
 apps/tests/loop_min_while.hako - All tests pass

# Related

- Phase 191-194 groundwork (modular merge structure)
- NYASH_TRACE_VARMAP added today for variable_map debugging
- Consolidates ~80 scattered eprintln! calls across JoinIR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 22:23:51 +09:00
4c42cab2d5 docs: Update control_flow module documentation (Phase 7)
- Enhanced module-level documentation in mod.rs
- Added comprehensive documentation to debug.rs
- Fixed unused imports in try_catch.rs
- Documented modularization history and architecture
- All visibility modifiers verified as correct
- Smoke tests pass (26/27, 1 unrelated timeout)
2025-12-05 21:11:43 +09:00
41de2d20e9 refactor: Extract debug utilities from control_flow.rs (Phase 1)
- Created control_flow/ subdirectory
- Moved trace_varmap() to debug.rs
- All control flow logic now in control_flow/mod.rs
- Zero breaking changes, all functionality preserved
- Tests pass (binary execution verified)
2025-12-05 20:41:19 +09:00