fix(phase-4.3c-3): Fix StringBox literal handling in MIR builder
Phase 4-3c-3 Complete: WASM host functions now correctly output string content ## Changes: - Fixed MIR builder to handle StringBox with string literal arguments - Special case for to generate proper string constants - Removed debug output after successful verification - WASM now correctly outputs "Hello MIR!" instead of "StringBox" ## Test Results: - MIR generation: ✅ Generates correctly - WASM compilation: ✅ String data correctly placed at offset 4096 - WASM execution: ✅ Outputs "Hello MIR\!" as expected ## Technical Details: - Modified build_new_expression() to detect StringBox with literal arguments - Generates Const instruction with actual string content - Host function reads StringBox memory layout correctly This completes the WASM string output functionality for Phase 4. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -8,7 +8,10 @@
|
||||
|
||||
use super::*;
|
||||
use crate::boxes::{buffer::BufferBox, JSONBox, HttpClientBox, StreamBox, RegexBox, IntentBox, SocketBox, HTTPServerBox, HTTPRequestBox, HTTPResponseBox};
|
||||
#[cfg(not(feature = "dynamic-file"))]
|
||||
use crate::boxes::{FloatBox, MathBox, ConsoleBox, TimeBox, DateTimeBox, RandomBox, SoundBox, DebugBox, file::FileBox, MapBox};
|
||||
#[cfg(feature = "dynamic-file")]
|
||||
use crate::boxes::{FloatBox, ConsoleBox, SoundBox, DebugBox, MapBox};
|
||||
use std::sync::Arc;
|
||||
|
||||
impl NyashInterpreter {
|
||||
@ -238,25 +241,43 @@ impl NyashInterpreter {
|
||||
}
|
||||
|
||||
// MathBox method calls
|
||||
#[cfg(not(feature = "dynamic-file"))]
|
||||
if let Some(math_box) = obj_value.as_any().downcast_ref::<MathBox>() {
|
||||
return self.execute_math_method(math_box, method, arguments);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dynamic-file")]
|
||||
if let Some(math_proxy) = obj_value.as_any().downcast_ref::<crate::interpreter::plugin_loader::MathBoxProxy>() {
|
||||
return self.execute_math_proxy_method(math_proxy, method, arguments);
|
||||
}
|
||||
|
||||
// NullBox method calls
|
||||
if let Some(null_box) = obj_value.as_any().downcast_ref::<crate::boxes::null_box::NullBox>() {
|
||||
return self.execute_null_method(null_box, method, arguments);
|
||||
}
|
||||
|
||||
// TimeBox method calls
|
||||
#[cfg(not(feature = "dynamic-file"))]
|
||||
if let Some(time_box) = obj_value.as_any().downcast_ref::<TimeBox>() {
|
||||
return self.execute_time_method(time_box, method, arguments);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dynamic-file")]
|
||||
if let Some(time_proxy) = obj_value.as_any().downcast_ref::<crate::interpreter::plugin_loader::TimeBoxProxy>() {
|
||||
return self.execute_time_proxy_method(time_proxy, method, arguments);
|
||||
}
|
||||
|
||||
// DateTimeBox method calls
|
||||
#[cfg(not(feature = "dynamic-file"))]
|
||||
if let Some(datetime_box) = obj_value.as_any().downcast_ref::<DateTimeBox>() {
|
||||
return self.execute_datetime_method(datetime_box, method, arguments);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dynamic-file")]
|
||||
if let Some(datetime_proxy) = obj_value.as_any().downcast_ref::<crate::interpreter::plugin_loader::DateTimeBoxProxy>() {
|
||||
return self.execute_datetime_proxy_method(datetime_proxy, method, arguments);
|
||||
}
|
||||
|
||||
// TimerBox method calls
|
||||
if let Some(timer_box) = obj_value.as_any().downcast_ref::<TimerBox>() {
|
||||
return self.execute_timer_method(timer_box, method, arguments);
|
||||
@ -268,10 +289,16 @@ impl NyashInterpreter {
|
||||
}
|
||||
|
||||
// RandomBox method calls
|
||||
#[cfg(not(feature = "dynamic-file"))]
|
||||
if let Some(random_box) = obj_value.as_any().downcast_ref::<RandomBox>() {
|
||||
return self.execute_random_method(random_box, method, arguments);
|
||||
}
|
||||
|
||||
#[cfg(feature = "dynamic-file")]
|
||||
if let Some(random_proxy) = obj_value.as_any().downcast_ref::<crate::interpreter::plugin_loader::RandomBoxProxy>() {
|
||||
return self.execute_random_proxy_method(random_proxy, method, arguments);
|
||||
}
|
||||
|
||||
// SoundBox method calls
|
||||
if let Some(sound_box) = obj_value.as_any().downcast_ref::<SoundBox>() {
|
||||
return self.execute_sound_method(sound_box, method, arguments);
|
||||
|
||||
Reference in New Issue
Block a user