diff --git a/src/main.rs b/src/main.rs index 779b5c4..6922629 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use wabt; +// use wabt; use wasmi::{ Error, Externals, FuncInstance, FuncRef, ImportsBuilder, ModuleImportResolver, ModuleInstance, RuntimeArgs, RuntimeValue, Signature, Trap, ValueType, @@ -33,11 +33,11 @@ impl Externals for HostFunctions { /// Do nothing SysCall::EMPTY => Ok(None), SysCall::EXIT => Ok(None), - // SysCall::CONSOLE_RESET => {} - // SysCall::CONSOLE_IN => {} - // SysCall::CONSOLE_OUT => {} - // SysCall::CONSOLE_GET_TITLE => {} - // SysCall::CONSOLE_SET_TITLE => {} + SysCall::CONSOLE_RESET => Ok(None), + SysCall::CONSOLE_IN => Ok(None), + SysCall::CONSOLE_OUT => Ok(None), + SysCall::CONSOLE_GET_TITLE => Ok(None), + SysCall::CONSOLE_SET_TITLE => Ok(None), _ => panic!("Unimplemented function at {}", index), } } @@ -71,21 +71,10 @@ impl ModuleImportResolver for HostFunctions { } fn main() { - // Parse WAT (WebAssembly Text format) into wasm bytecode. - // let wasm_binary = wabt::wat2wasm(include_str!("../wasm/test.wat")); - let wasm_binary = //wabt::wat2wasm( - include_bytes!("../wasm/ableos-wasm-test.wasm"); //.unwrap(); - // ); - /* - let wasm_binary = match wasm_binary { - Ok(abc) => abc, - Err(abc) => { - println!("{}", abc); - return; - } - }; - */ - // .expect("failed to parse wat"); + let wasm_binary = include_bytes!("../wasm/rust.wasm"); + // include_bytes!("../wasm/zig.wasm"); + // include_bytes!("../wasm/c.wasm"); + // include_bytes!("../wasm/wasm.wasm"); // Load wasm binary and prepare it for instantiation. let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm"); diff --git a/wasm/ableos-wasm-test.wasm b/wasm/ableos-wasm-test.wasm deleted file mode 100755 index 808cd28..0000000 Binary files a/wasm/ableos-wasm-test.wasm and /dev/null differ diff --git a/wasm/c.wasm b/wasm/c.wasm new file mode 100644 index 0000000..9448d4a Binary files /dev/null and b/wasm/c.wasm differ diff --git a/wasm/rust.wasm b/wasm/rust.wasm new file mode 100755 index 0000000..d3da416 Binary files /dev/null and b/wasm/rust.wasm differ diff --git a/wasm/test.wat b/wasm/test.wat deleted file mode 100644 index 77f65c4..0000000 --- a/wasm/test.wat +++ /dev/null @@ -1,8 +0,0 @@ -(module - (import "host" "add" (func $add (param i32 i32)(result i32))) - (; (import "host" "empty" (func $empty)) ;) - (func (export "main") (result i32) - (; (call $empty) ;) - (call $add (i32.const 123) (i32.const 456)) - ) -) diff --git a/wasm/wasm.wasm b/wasm/wasm.wasm new file mode 100644 index 0000000..1d68a46 Binary files /dev/null and b/wasm/wasm.wasm differ diff --git a/wasm/zig.wasm b/wasm/zig.wasm new file mode 100644 index 0000000..72a2519 Binary files /dev/null and b/wasm/zig.wasm differ