feat: Unified registry and major code cleanup by ChatGPT5

- Unified Box Registry: Replaced 600+ line match statement with clean factory pattern
- Code cleanup: Removed unused imports, variables, and dead code
- Import fixes: Fixed RangeBox, NullBox, MapBox imports
- Transport Debug: Added Debug trait implementation for Transport interface
- WASM build: Successfully tested with wasm_playground preset ready for integration
- Performance: Build time stable, WASM package generated successfully (1.89MB)

This commit represents a major architectural improvement with the unified registry
system now fully operational, reducing code duplication and improving maintainability.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-21 14:28:24 +09:00
parent bf0229c24a
commit 2fc6ce3aa6
14 changed files with 743 additions and 222 deletions

View File

@ -15,7 +15,8 @@ use nyash_rust::{
mir::{MirCompiler, MirPrinter, MirInstruction},
backend::VM,
};
use nyash_rust::runtime::NyashRuntime;
use nyash_rust::runtime::{NyashRuntime, NyashRuntimeBuilder};
use nyash_rust::box_factory::builtin::BuiltinGroups;
use nyash_rust::interpreter::SharedState;
use nyash_rust::box_factory::user_defined::UserDefinedBoxFactory;
use nyash_rust::core::model::BoxDeclaration as CoreBoxDecl;
@ -226,7 +227,7 @@ impl NyashRunner {
eprintln!("🔍 DEBUG: Creating interpreter...");
// Execute the AST
let mut interpreter = NyashInterpreter::new();
let mut interpreter = NyashInterpreter::new_with_groups(BuiltinGroups::native_full());
eprintln!("🔍 DEBUG: Starting execution...");
match interpreter.execute(ast) {
Ok(result) => {
@ -321,7 +322,9 @@ impl NyashRunner {
// Prepare runtime and collect Box declarations for VM user-defined types
let runtime = {
let rt = NyashRuntime::new();
let rt = NyashRuntimeBuilder::new()
.with_builtin_groups(BuiltinGroups::native_full())
.build();
self.collect_box_declarations(&ast, &rt);
// Register UserDefinedBoxFactory backed by the same declarations
let mut shared = SharedState::new();
@ -643,7 +646,7 @@ impl NyashRunner {
let start = std::time::Instant::now();
for _ in 0..self.config.iterations {
if let Ok(ast) = NyashParser::parse_from_string(test_code) {
let mut interpreter = NyashInterpreter::new();
let mut interpreter = NyashInterpreter::new_with_groups(BuiltinGroups::native_full());
let _ = interpreter.execute(ast);
}
}
@ -866,7 +869,7 @@ fn demo_interpreter_system() {
match NyashParser::parse_from_string(simple_code) {
Ok(ast) => {
let mut interpreter = NyashInterpreter::new();
let mut interpreter = NyashInterpreter::new_with_groups(BuiltinGroups::native_full());
match interpreter.execute(ast) {
Ok(result) => {
println!(" ✅ Result: {}", result.to_string_box().value);
@ -891,7 +894,7 @@ fn demo_interpreter_system() {
match NyashParser::parse_from_string(expr_code) {
Ok(ast) => {
let mut interpreter = NyashInterpreter::new();
let mut interpreter = NyashInterpreter::new_with_groups(BuiltinGroups::native_full());
match interpreter.execute(ast) {
Ok(result) => {
println!(" ✅ Result: {}", result.to_string_box().value);