๐ Phase 9.7: Box FFI/ABI + ExternCall Demo
โ
ExternCall Implementation Complete!
Universal Library Integration via WASM Runtime Imports
๐ฏ Architecture Overview
// Nyash External Call Pattern
console.log("Hello from Nyash!")
canvas.fillRect("demo-canvas", 50, 50, 100, 100, "red")
// Generated MIR ExternCall Instructions:
ExternCall {
dst: None,
iface_name: "env.console",
method_name: "log",
args: [string_ptr, string_len],
effects: IO
}
// Generated WASM Imports:
(import "env" "console_log" (func $console_log (param i32 i32)))
(import "env" "canvas_fillRect" (func $canvas_fillRect (param i32 i32 i32 i32 i32 i32 i32 i32)))
๐ฎ Interactive Demo
๐ Console Output:
๐ง Implementation Status
โ
Core Components Complete:
โข MIR ExternCall instruction with effect tracking
โข WASM RuntimeImports with console/canvas operations
โข JavaScript import object generation
โข BID specification compliance (console.yaml, canvas.yaml)
โข String handling via (ptr, len) parameters
๐ Ready for Universal Exchange:
External libraries can now be integrated via Box FFI/ABI!