Files
hakorune/docs/development/mir/MIR_BUILDER_MIGRATION.md
Moe Charm 22212aa314 refactor: Major interpreter modularization and P2PBox enhancements
Major Interpreter Refactoring:
- Split core.rs (373 lines removed) into focused modules
- Split expressions/calls.rs (460 lines removed) into cleaner structure
- Added new modules: calls.rs, errors.rs, eval.rs, methods_dispatch.rs, state.rs
- Improved separation of concerns across interpreter components

P2PBox Enhancements:
- Added on_once() for one-time event handlers
- Added off() for handler deregistration
- Implemented handler flags with AtomicBool for thread-safe management
- Added loopback testing cache (last_from, last_intent_name)
- Improved Arc-based state sharing for transport and handlers

Plugin Loader Unification (In Progress):
- Created plugin_loader_unified.rs skeleton
- Created plugin_ffi_common.rs for shared FFI utilities
- Migration plan documented (2400 lines → 1100 lines target)

MIR & VM Improvements:
- Enhanced modularized MIR builder structure
- Added BoxCall dispatch improvements
- Better separation in builder modules

Documentation Updates:
- Added Phase 9.79a unified box dispatch plan
- Created plugin loader migration plan
- Updated CURRENT_TASK.md with latest progress

All tests passing (180 tests) - ready for next phase of refactoring

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 19:13:57 +09:00

1.2 KiB

MIR Builder Migration Plan (builder -> builder_modularized)

Goal: Gradually switch from src/mir/builder.rs to the modular split in src/mir/builder_modularized/ without breaking default builds.

Phases

  1. Compatibility layer (done)

    • Keep default export MirBuilder from builder.rs.
    • Gate modularized builder behind feature mir_modular_builder.
    • Add helpers (emit_type_check/cast/weak_new/weak_load/barrier_*) in builder.rs.
  2. Field-name alignment (next)

    • builder_modularized/core.rs uses provisional field names for instructions.
    • Align to current MirInstruction:
      • TypeOp: { op, value, ty } instead of { operation, operand, type_info }.
      • WeakRef/Barrier: use WeakRef { dst, op, value } and Barrier { op, ptr } forms if present.
    • Import enums via use crate::mir::{TypeOpKind, WeakRefOp, BarrierOp};.
  3. Swap export (opt-in → default)

    • With --features mir_modular_builder, ensure cargo check passes.
    • After parity tests (printer/optimizer/verifier), flip default export to modularized.

Notes

  • No behavior changes intended during migration — only structural split.
  • Keep logs behind NYASH_BUILDER_DEBUG=1 to avoid noise.