WIP: Phase 9.78b - Unified registry integration (import issues pending)

Progress made:
- Add unified registry call to objects.rs execute_new() method
- Initialize unified registry in runner.rs on startup
- Create global registry management in runtime/unified_registry.rs
- Add test case for unified registry validation
- Implement fallback to legacy match statement for compatibility

Current issue:
- Module import errors in runtime/unified_registry.rs preventing build
- Need to resolve box_factory module path visibility from runtime context

Next steps:
- Fix import paths for box_factory modules
- Test unified registry functionality
- Remove legacy match statement after validation

Technical details:
- execute_new() now tries unified registry first, falls back to legacy
- Registry initialized with BuiltinBoxFactory and PluginBoxFactory
- Maintains backward compatibility during transition

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-19 16:48:45 +09:00
parent 18d26ed130
commit fbb94aea17
4 changed files with 82 additions and 7 deletions

View File

@ -18,6 +18,41 @@ impl NyashInterpreter {
-> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!("🔍 execute_new called for class: {}, with {} arguments", class, arguments.len());
// 🏭 Phase 9.78b: Try unified registry first
eprintln!("🔍 Trying unified registry for class: {}", class);
// Convert ASTNode arguments to Box<dyn NyashBox>
let nyash_args: Result<Vec<Box<dyn NyashBox>>, RuntimeError> = arguments.iter()
.map(|arg| self.execute_expression(arg))
.collect();
match nyash_args {
Ok(args) => {
// Try unified registry
use crate::runtime::get_global_unified_registry;
let registry = get_global_unified_registry();
let registry_lock = registry.lock().unwrap();
match registry_lock.create_box(class, &args) {
Ok(box_instance) => {
eprintln!("🏭 Unified registry created: {}", class);
return Ok(box_instance);
},
Err(e) => {
eprintln!("🔍 Unified registry failed for {}: {}", class, e);
// Fall through to legacy match statement
}
}
},
Err(e) => {
eprintln!("🔍 Argument evaluation failed: {}", e);
// Fall through to legacy match statement which will re-evaluate args
}
}
// 🚧 Legacy implementation (will be removed in Phase 9.78e)
eprintln!("🔍 Falling back to legacy match statement for: {}", class);
// 組み込みBox型のチェック
eprintln!("🔍 Starting built-in Box type checks...");
match class {