wabam
A crate for creating WebAssembly modules.
Example
let mut module = default;
module.types = vec!;
// Import WASI's `fd_write`, to print to the terminal
let fd_write = FuncImport ;
module.imports.functions.push;
// Define memory
let memory = Limit ;
module.memories.push;
let text = "Hello, wasm!";
let text_ptr = 12;
// Load the text into memory
let data = Active ;
module.datas.push;
let body = instrs!;
let func = Function ;
module.functions.push;
// Export the start function
let func_export = Export ;
// Export memory
let mem_export = Export ;
module.exports.functions.push;
module.exports.memories.push;
let output = module.build;
write.unwrap;
Then run it:
$ wasmtime ./hello.wasm
Hello, wasm!
Licensing
This project is licensed under either Apache License Version 2.0 or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.