Commit Graph

8 Commits

Author SHA1 Message Date
3af98964ed feat(joinir): Phase P2-P4 Loop Pattern boxification
- P2: Create loop_patterns/ module structure
  - common.rs: shared helpers (ParsedProgram, LoopContext, etc.)
  - simple.rs: generic loop lowering
  - filter.rs, print_tokens.rs: delegate to simple
  - break_pattern.rs, continue_pattern.rs: new modules

- P3: Create LoopFrontendBinding layer
  - Separate function name detection from pattern lowering
  - detect_loop_pattern() for pattern classification

- P4: Break/Continue pattern migration
  - Move Break/Continue handling from loop_patterns_old.rs
  - Add LoopPattern::Break and LoopPattern::Continue variants

- Design: 3-layer architecture
  - LoopFrontendBinding: function name → LoopPattern
  - loop_patterns: LoopPattern → JoinIR
  - Bridge/VM: Box semantics

All 56 JoinIR tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 09:04:18 +09:00
fd83903f87 feat(joinir): Phase P1 If Handler boxification - 40% code reduction
## Summary
Refactored loop-internal If statement handling into a boxified module
structure, achieving 154-line reduction (40%) from stmt_handlers.rs
with zero regression.

## Implementation
- Created if_in_loop/ module (9 files, ~480 lines)
  - pattern.rs: IfInLoopPattern enum (5 variants)
  - lowering/{empty,single_var_then,single_var_both,conditional_effect,unsupported}.rs
- Replaced lower_if_stmt_in_loop() (154 lines) with lower_if_stmt_in_loop_boxified()
- Made StatementEffect pub(crate) for module visibility

## Pattern Classification
1. Empty: condition-only check (no side effects)
2. SingleVarThen: if { x = a } → x = cond ? a : x
3. SingleVarBoth: if { x = a } else { x = b } → x = cond ? a : b
4. ConditionalEffect: if pred(v) { acc.push(v) } (filter pattern)
5. Unsupported: complex cases (Phase 54+)

## Test Results
 56 JoinIR tests PASSED (0 failed, 0 regression)
 Build successful (1m 02s)
 Improved maintainability (easier to add new patterns)

## Files Changed
- src/mir/join_ir/frontend/ast_lowerer/
  - if_in_loop/ (9 new files)
  - mod.rs (+2 lines: module + pub use)
  - stmt_handlers.rs (-154 lines: 40% reduction)
- CURRENT_TASK.md (+5 lines: Phase P1 記録)
- docs/development/refactoring/p1-if-handler-boxification-plan.md (new)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:20:56 +09:00
51ff558904 feat(phase32): L-2.1 Stage-1 UsingResolver JoinIR integration + cleanup
Phase 32 L-2.1 complete implementation:

1. Stage-1 UsingResolver main line JoinIR connection
   - CFG-based LoopForm construction for resolve_for_source/5
   - LoopToJoinLowerer integration with handwritten fallback
   - JSON snapshot tests 6/6 PASS

2. JoinIR/VM Bridge improvements
   - Simplified join_ir_vm_bridge.rs dispatch logic
   - Enhanced json.rs serialization
   - PHI core boxes cleanup (local_scope_inspector, loop_exit_liveness, loop_var_classifier)

3. Stage-1 CLI enhancements
   - Extended args.rs, groups.rs, mod.rs for new options
   - Improved stage1_bridge module (args, env, mod)
   - Updated stage1_cli.hako

4. MIR builder cleanup
   - Simplified if_form.rs control flow
   - Removed dead code from loop_builder.rs
   - Enhanced phi_merge.rs

5. Runner module updates
   - json_v0_bridge/lowering.rs improvements
   - dispatch.rs, selfhost.rs, modes/vm.rs cleanup

6. Documentation updates
   - CURRENT_TASK.md, AGENTS.md
   - Various docs/ updates

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:17:37 +09:00
0455307418 refactor(phase-a): remove Cranelift/JIT backend legacy code (~373 lines)
Phase A cleanup - Safe deletions with zero risk:

## Deleted Files (6 files, 373 lines total)
1. Cranelift/JIT Backend (321 lines):
   - src/runner/modes/cranelift.rs (45 lines)
   - src/runner/modes/aot.rs (55 lines)
   - src/runner/jit_direct.rs (152 lines)
   - src/tests/core13_smoke_jit.rs (42 lines)
   - src/tests/core13_smoke_jit_map.rs (27 lines)

2. Legacy MIR Builder (52 lines):
   - src/mir/builder/exprs_legacy.rs
   - Functionality inlined into exprs.rs (control flow constructs)

## Module Reference Cleanup
- src/backend/mod.rs: Removed cranelift feature gate exports
- src/runner/mod.rs: Removed jit_direct module reference
- src/runner/modes/mod.rs: Removed aot module reference
- src/mir/builder.rs: Removed exprs_legacy module

## Impact Analysis
- Build: Success (cargo build --release)
- Tests: All passing
- Risk Level: None (feature already archived, code unused)
- Related: Phase 15 JIT archival (archive/jit-cranelift/)

## BID Copilot Status
- Already removed in previous cleanup
- Not part of this commit

Total Reduction: 373 lines (~0.4% of codebase)
Next: Phase B - Dead code investigation

Related: #phase-21.0-cleanup
Part of: Legacy Code Cleanup Initiative
2025-11-06 22:34:18 +09:00
77d4fd72b3 phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0 2025-11-06 15:41:52 +09:00
6ce06501e1 json-native: enable float roundtrip in parser (NUMBER => float by '.'/exp); expand roundtrip smoke with more numeric cases 2025-09-26 00:32:20 +09:00
c8063c9e41 pyvm: split op handlers into ops_core/ops_box/ops_ctrl; add ops_flow + intrinsic; delegate vm.py without behavior change
net-plugin: modularize constants (consts.rs) and sockets (sockets.rs); remove legacy commented socket code; fix unused imports
mir: move instruction unit tests to tests/mir_instruction_unit.rs (file lean-up); no semantic changes
runner/pyvm: ensure using pre-strip; misc docs updates

Build: cargo build ok; legacy cfg warnings remain as before
2025-09-21 08:53:00 +09:00
d99b941218 docs: add MIR13 mode doc and set PHI-off as default; bridge lowering split (if/loop/try); llvmlite resolver stabilization; curated runner default PHI-off; refresh CURRENT_TASK.md 2025-09-17 10:58:12 +09:00