feat(phase-9.75f-1): Complete FileBox dynamic library implementation

- Implement C ABI plugin system with workspace configuration
- Create FileBox plugin with full read/write/exists/toString support
- Fix critical memory management issues (double free) with Arc
- Add comprehensive test suite for dynamic FileBox functionality
- Achieve 98% build time improvement for plugin (2.87s vs 2-3min)
- Maintain full backward compatibility with feature flags

FileBox now loads dynamically, drastically reducing build times while
maintaining all functionality. Next: Math/Time dynamic migration.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Moe Charm
2025-08-17 09:31:35 +09:00
parent bd20c91b67
commit 2b2dcc5647
19 changed files with 347 additions and 207 deletions

View File

@ -25,6 +25,7 @@ impl NyashInterpreter {
#[cfg(feature = "dynamic-file")]
pub(in crate::interpreter) fn execute_file_proxy_method(&mut self, file_box: &FileBoxProxy, method: &str, arguments: &[ASTNode])
-> Result<Box<dyn NyashBox>, RuntimeError> {
eprintln!("🔍 DEBUG: execute_file_proxy_method called with method: '{}'", method);
match method {
"read" => {
if !arguments.is_empty() {
@ -51,9 +52,16 @@ impl NyashInterpreter {
}
file_box.exists()
}
_ => Err(RuntimeError::UndefinedMethod {
method: method.to_string(),
box_type: "FileBox".to_string(),
"toString" => {
if !arguments.is_empty() {
return Err(RuntimeError::InvalidOperation {
message: format!("toString() expects 0 arguments, got {}", arguments.len()),
});
}
Ok(Box::new(file_box.to_string_box()))
}
_ => Err(RuntimeError::InvalidOperation {
message: format!("Undefined method '{}' for FileBox", method),
}),
}
}
@ -110,6 +118,14 @@ impl NyashInterpreter {
})
}
}
"toString" => {
if !arguments.is_empty() {
return Err(RuntimeError::InvalidOperation {
message: format!("toString() expects 0 arguments, got {}", arguments.len()),
});
}
Ok(Box::new(file_box.to_string_box()))
}
_ => Err(RuntimeError::InvalidOperation {
message: format!("Unknown method '{}' for FileBox", method),
})