|
|
0287020a5b
|
refactor: unify error message generation (Phase 3)
Add ErrorBuilder utility and migrate 35 error generation sites
Phase 3: Error Message Generation Unification
============================================
Infrastructure:
- Add src/backend/mir_interpreter/utils/error_helpers.rs (255 lines)
- Implement ErrorBuilder with 7 standardized error patterns
- Add MirInterpreter convenience methods (err_invalid, err_type_mismatch, etc.)
Migration Results:
- Total patterns migrated: 35 instances (80 → 45, 44% reduction)
- calls.rs: 37 → 13 patterns (65% reduction)
- extern_provider.rs: 20 → 9 patterns (55% reduction)
- Lines saved: 33 lines (1.0% of handlers)
Error Patterns Unified:
1. Invalid instruction errors → ErrorBuilder::invalid_instruction()
2. Type mismatch errors → ErrorBuilder::type_mismatch()
3. Argument count errors → ErrorBuilder::arg_count_mismatch()
4. Method not found → ErrorBuilder::method_not_found()
5. Unsupported operations → ErrorBuilder::unsupported_operation()
6. Context errors → ErrorBuilder::with_context()
7. Bounds errors → ErrorBuilder::out_of_bounds()
Benefits:
- Consistent error message formatting across all handlers
- Single point of change for error improvements
- Better IDE autocomplete support
- Easier future i18n integration
- Reduced code duplication
Cumulative Impact (Phase 1+2+3):
- Total lines saved: 150-187 lines (4.5-5.7% of handlers)
- Total patterns unified: 124 instances
* Phase 1: 37 destination patterns
* Phase 2: 52 argument validation patterns
* Phase 3: 35 error generation patterns
Remaining Work:
- 45 error patterns still to migrate (estimated 50-80 lines)
- Complex cases requiring manual review
Testing:
- Build: ✅ 0 errors, 0 new warnings
- Smoke tests: ⚠️ 8/9 passed (1 timeout unrelated)
- Core functionality: ✅ Verified
Related: Phase 21.0 MIR Interpreter refactoring
Risk: Low (error messages only, behavior preserved)
Impact: High (maintainability, consistency, i18n-ready)
Co-authored-by: Claude Code <claude@anthropic.com>
|
2025-11-06 23:18:10 +09:00 |
|
|
|
8d179e9499
|
refactor: add MIR interpreter utility helpers (Phase 1)
- Add destination write helpers (write_box_result, write_void, write_result)
- Add argument validation helpers (validate_args_exact/range/min)
- Add receiver conversion helper (convert_to_box)
- Update handlers to use new helpers
Reduces code duplication:
- Destination patterns: 37 call sites converted
- Each replacement saves 2-3 lines (74-111 lines saved)
- Helper infrastructure: 178 lines added
- Net improvement: Reduced duplication + better maintainability
Impact:
- Build: ✓ SUCCESS (0 errors, 146 warnings)
- Tests: ✓ 8/9 smoke tests PASS
- Functionality: ✓ PRESERVED (no behavior changes)
Files created:
- src/backend/mir_interpreter/utils/mod.rs
- src/backend/mir_interpreter/utils/destination_helpers.rs
- src/backend/mir_interpreter/utils/arg_validation.rs
- src/backend/mir_interpreter/utils/receiver_helpers.rs
Files modified: 15 handler files
- arithmetic.rs, boxes.rs, boxes_array.rs, boxes_instance.rs
- boxes_map.rs, boxes_object_fields.rs, boxes_plugin.rs
- boxes_string.rs, calls.rs, extern_provider.rs, externals.rs
- memory.rs, misc.rs, mod.rs
Related: Phase 21.0 refactoring
Risk: Low (pure refactoring, no behavior change)
|
2025-11-06 22:50:46 +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 |
|