Commit Graph

9 Commits

Author SHA1 Message Date
e7f9adcfed refactor(joinir): Phase 260 P0.3 Phase 1 - extract terminator_builder + block_finalizer
Extracts shared utilities from joinir_block_converter.rs to prepare for
handler extraction (Phase 2):

**terminator_builder.rs** (207 lines):
- create_branch_terminator() - Branch with empty edge_args
- emit_branch_and_finalize() - Branch + block finalization
- create_jump_terminator() - Jump with empty edge_args
- create_return_terminator() - Return terminator
- Eliminates 4x Branch terminator duplication

**block_finalizer.rs** (246 lines):
- finalize_block() - Add instructions + terminator (PHI-preserving)
- finalize_remaining_instructions() - Flush pending instructions
- Phase 189 FIX: Critical PHI preservation logic
- PHI instructions remain at block start for SSA correctness

Pattern reduction: ~90 lines duplicated 4x → 2 utility modules

All utilities fully tested with comprehensive unit tests.
Phase 1 complete - utilities ready for Phase 2 handler extraction.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 07:40:05 +09:00
875bfee1ba refactor(joinir): Phase 260 P0.2 - extract call_generator + 4 simple handlers
Extracts repeated patterns from joinir_block_converter.rs:

**call_generator.rs** (195 lines):
- emit_call_pair() - Const + Call instruction pair generation
- emit_call_pair_with_spans() - With span tracking
- Eliminates 3x duplication of call generation pattern

**handlers/** module (4 simple handlers, 389 lines total):
- ret.rs - Return instruction handling
- method_call.rs - MethodCall → BoxCall conversion
- field_access.rs - FieldAccess → BoxCall (getter pattern)
- new_box.rs - NewBox instruction handling

All handlers fully tested with comprehensive unit tests.

Pattern reduction: ~60 lines duplicated 3x → single utility modules

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 07:22:14 +09:00
84cd653aef refactor(joinir): Phase 260 P0.2 - extract merge_variable_handler.rs
Extracts merge copy emission pattern from joinir_block_converter.rs to
eliminate 4x code duplication:

- MergeBranch enum (Then/Else) for branch selection
- emit_merge_copies() for MergePair-based copy emission
- emit_copy_instructions() for direct ValueId pair emission
- Comprehensive unit tests for all patterns

Pattern reduction: ~20 lines duplicated 4x → single 60-line module

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 07:07:21 +09:00
c2e8099ff6 refactor(joinir): Phase 260 P0.2 - extract block_allocator.rs
Extract block ID allocation pattern from joinir_block_converter.rs into
dedicated block_allocator.rs module (~130 lines).

New BlockAllocator struct provides:
- allocate_one(): Single block ID
- allocate_two(): Pair (exit + continue pattern)
- allocate_three(): Triple (then + else + merge pattern)
- allocate_n(): N block IDs for nested structures
- 5 unit tests

This eliminates 4x repeated allocation pattern across:
- handle_conditional_method_call() lines 259-265
- handle_jump() lines 484-487
- handle_if_merge() lines 630-635
- handle_nested_if_merge() lines 731-744

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-21 06:57:16 +09:00
e404746612 refactor(mir): Phase 139-P3-B - RoutingDecision を enum 対応 + レガシー削除
- RoutingDecision の missing_caps を Vec<CapabilityTag> に変更(型安全化)
- error_tags は to_tag() メソッドで自動生成
- 全 callsite を enum variant に修正
- capability_tags モジュール(文字列定数群)を完全削除
- 全テスト PASS(型安全性向上を確認)
- フォーマット適用
2025-12-16 07:02:14 +09:00
a4756f3ce1 Add dev normalized→MIR bridge for P1/P2 mini and JP _atoi 2025-12-11 22:12:46 +09:00
af6f95cd4b Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini 2025-12-11 20:54:33 +09:00
7c55baa818 refactor(joinir): Phase 190 convert.rs modularization
- Created joinir_function_converter.rs (~133 lines): Function-level conversion
- Created joinir_block_converter.rs (~691 lines): Block-level conversion
- Reduced convert.rs from 943 → 120 lines (87% reduction)
- Total: 944 lines (original 943 lines, minimal overhead)
- Separation of concerns: Function vs Block responsibilities
- All handlers moved to block_converter for better organization
- Maintained backward compatibility with existing API
- Build successful, simple tests passing
2025-12-05 14:41:24 +09:00
447bbec998 refactor(joinir): Split ast_lowerer and join_ir_vm_bridge into modules
ast_lowerer.rs → ast_lowerer/ (10 files):
- mod.rs: public surface + entry dispatch
- context.rs: ExtractCtx helpers
- expr.rs: expression-to-JoinIR extraction
- if_return.rs: simple if→Select lowering
- loop_patterns.rs: loop variants (simple/break/continue)
- read_quoted.rs: read_quoted_from lowering (Phase 45-46)
- nested_if.rs: NestedIfMerge lowering
- analysis.rs: loop if-var analysis + metadata helpers
- tests.rs: frontend lowering tests
- README.md: module documentation

join_ir_vm_bridge.rs → join_ir_vm_bridge/ (5 files):
- mod.rs: public surface + shared helpers
- convert.rs: JoinIR→MIR lowering
- runner.rs: VM execution entry (run_joinir_via_vm)
- meta.rs: experimental metadata-aware hooks
- tests.rs: bridge-specific unit tests
- README.md: module documentation

Benefits:
- Clear separation of concerns per pattern
- Easier navigation and maintenance
- Each file has single responsibility
- README documents module boundaries

Co-authored-by: ChatGPT <noreply@openai.com>

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:42:19 +09:00