feat(llvm): Complete plugin system unification and environment variable elimination
🎉 Major Achievement: LLVM Plugin Environment Variable Problem Completely Resolved ## ✅ Completed Major Features: 1. **Plugin Implementation** ✅ - nyash.plugin.invoke_* functions in nyrt library working 2. **Plugin Calls** ✅ - Method calls working without environment variables 3. **Return Value Type Inference Fix** ✅ - Added plugin method type inference to MIR builder 4. **by-id Unification Complete** ✅ - Removed by-name fallback, unified to method_id system 5. **Environment Variable Elimination** ✅ - Removed NYASH_LLVM_ALLOW_BY_NAME=1 requirement 6. **Simple Execution Achieved** ✅ - ./target/release/nyash --backend llvm program.nyash ## 🔧 Technical Changes: ### Core Fixes: - **src/mir/builder.rs**: Added plugin method return type inference - CounterBox.get() -> Integer - MathBox.sqrt() -> Float - FileBox.read() -> String - FileBox.exists() -> Bool - **src/backend/llvm/compiler.rs**: Removed by-name fallback completely - Deleted NYASH_LLVM_ALLOW_BY_NAME environment variable check - Removed ~50 lines of fallback logic - Unified to method_id-based calls only ### Documentation Updates: - **CLAUDE.md**: Updated all plugin examples to remove environment variables - **README.md/README.ja.md**: Removed environment variable documentation - **tools/llvm_smoke.sh**: Removed NYASH_LLVM_ALLOW_BY_NAME from all test scripts ### Performance & Maintainability: - **Better Performance**: method_id calls more efficient than by-name lookups - **Type Safety**: method_id system provides compile-time guarantees - **Code Simplification**: Removed complex fallback logic - **User Experience**: No environment variables to remember ## 🧪 Verification: - ✅ Plugin execution without environment variables - ✅ method_id injection working: [LLVM] method_id injected: 4-5 places - ✅ Type inference working: [BUILDER] Type inference: CounterBox get -> Integer - ✅ Compilation success with LLVM backend ## 🔍 Remaining Investigation: Plugin return value display issue identified as separate runtime layer problem (plugin methods execute and side effects work, but return values not displayed in print()) 🚀 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -106,13 +106,22 @@ impl MirBuilder {
|
||||
}
|
||||
if let Some(bt) = recv_box {
|
||||
let inferred: Option<super::MirType> = match (bt.as_str(), method.as_str()) {
|
||||
// Built-in box methods
|
||||
("StringBox", "length") | ("StringBox", "len") => Some(super::MirType::Integer),
|
||||
("StringBox", "is_empty") => Some(super::MirType::Bool),
|
||||
("StringBox", "charCodeAt") => Some(super::MirType::Integer),
|
||||
("ArrayBox", "length") => Some(super::MirType::Integer),
|
||||
|
||||
// Plugin box methods
|
||||
("CounterBox", "get") => Some(super::MirType::Integer),
|
||||
("MathBox", "sqrt") => Some(super::MirType::Float),
|
||||
("FileBox", "read") => Some(super::MirType::String),
|
||||
("FileBox", "exists") => Some(super::MirType::Bool),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(mt) = inferred { self.value_types.insert(d, mt); }
|
||||
if let Some(mt) = inferred {
|
||||
self.value_types.insert(d, mt);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user