Remove all checked in *.wasm files to the repo (#563)
* Tidy up the `hello` example for `wasmtime` * Remove the `*.wat` and `*.wasm` files and instead just inline the `*.wat` into the example. * Touch up comments so they're not just a repeat of the `println!` below. * Move `*.wat` for `memory` example inline No need to handle auxiliary files with the ability to parse it inline! * Move `multi.wasm` inline into `multi.rs` example * Move `*.wasm` for gcd example inline * Move `*.wat` inline with `import_calling_export` test * Remove checked in `lightbeam/test.wasm` Instead move the `*.wat` into the source and parse it into wasm there. * Run rustfmt
This commit is contained in:
@@ -2,11 +2,40 @@
|
||||
//! invoking its exported function.
|
||||
|
||||
use anyhow::{format_err, Result};
|
||||
use std::fs::read;
|
||||
use wasmtime_api::*;
|
||||
|
||||
const WAT: &str = r#"
|
||||
(module
|
||||
(func $gcd (param i32 i32) (result i32)
|
||||
(local i32)
|
||||
block ;; label = @1
|
||||
block ;; label = @2
|
||||
local.get 0
|
||||
br_if 0 (;@2;)
|
||||
local.get 1
|
||||
local.set 2
|
||||
br 1 (;@1;)
|
||||
end
|
||||
loop ;; label = @2
|
||||
local.get 1
|
||||
local.get 0
|
||||
local.tee 2
|
||||
i32.rem_u
|
||||
local.set 0
|
||||
local.get 2
|
||||
local.set 1
|
||||
local.get 0
|
||||
br_if 0 (;@2;)
|
||||
end
|
||||
end
|
||||
local.get 2
|
||||
)
|
||||
(export "gcd" (func $gcd))
|
||||
)
|
||||
"#;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let wasm = read("examples/gcd.wasm")?;
|
||||
let wasm = wat::parse_str(WAT)?;
|
||||
|
||||
// Instantiate engine and store.
|
||||
let engine = HostRef::new(Engine::default());
|
||||
|
||||
Reference in New Issue
Block a user