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>
This commit is contained in:
Moe Charm
2025-08-26 19:13:57 +09:00
parent bec61e38c5
commit 22212aa314
46 changed files with 2383 additions and 1438 deletions

View File

@ -5,20 +5,20 @@
* Behavior: Quiet by default; use NYASH_CLI_VERBOSE=1 or NYASH_DEBUG_PLUGIN=1 for logs
*/
use crate::runtime::{init_global_loader_v2, get_global_registry, get_global_loader_v2, PluginConfig};
use crate::runtime::{init_global_plugin_host, get_global_registry, get_global_plugin_host, PluginConfig};
pub fn init_bid_plugins() {
let cli_verbose = std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1");
let plugin_debug = std::env::var("NYASH_DEBUG_PLUGIN").ok().as_deref() == Some("1");
if plugin_debug { eprintln!("🔍 DEBUG: Initializing v2 plugin system"); }
if let Ok(()) = init_global_loader_v2("nyash.toml") {
if let Ok(()) = init_global_plugin_host("nyash.toml") {
if plugin_debug || cli_verbose {
println!("🔌 v2 plugin system initialized from nyash.toml");
println!("🔌 plugin host initialized from nyash.toml");
}
let loader = get_global_loader_v2();
let loader = loader.read().unwrap();
if let Some(config) = &loader.config {
let host = get_global_plugin_host();
let host = host.read().unwrap();
if let Some(config) = host.config_ref() {
let registry = get_global_registry();
for (lib_name, lib_def) in &config.libraries {
for box_name in &lib_def.boxes {
@ -27,7 +27,7 @@ pub fn init_bid_plugins() {
}
}
if plugin_debug || cli_verbose {
println!(" v2 plugin system fully configured");
println!("✅ plugin host fully configured");
}
}
} else if plugin_debug || cli_verbose {