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:
Moe Charm
2025-08-17 13:49:35 +09:00
parent bb3f2e8032
commit 3df87fb1ce
41 changed files with 4444 additions and 68 deletions

View File

@ -8,10 +8,13 @@
mod codegen;
mod memory;
mod runtime;
mod host;
mod executor;
pub use codegen::{WasmCodegen, WasmModule};
pub use memory::{MemoryManager, BoxLayout};
pub use runtime::RuntimeImports;
pub use executor::WasmExecutor;
use crate::mir::MirModule;
@ -23,6 +26,8 @@ pub enum WasmError {
UnsupportedInstruction(String),
WasmValidationError(String),
IOError(String),
RuntimeError(String),
CompilationError(String),
}
impl std::fmt::Display for WasmError {
@ -33,6 +38,8 @@ impl std::fmt::Display for WasmError {
WasmError::UnsupportedInstruction(msg) => write!(f, "Unsupported instruction: {}", msg),
WasmError::WasmValidationError(msg) => write!(f, "WASM validation error: {}", msg),
WasmError::IOError(msg) => write!(f, "IO error: {}", msg),
WasmError::RuntimeError(msg) => write!(f, "Runtime error: {}", msg),
WasmError::CompilationError(msg) => write!(f, "Compilation error: {}", msg),
}
}
}