Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Latest commit

 

History

History
82 lines (59 loc) · 1.82 KB

README.md

File metadata and controls

82 lines (59 loc) · 1.82 KB

WebAssembly Binary Interpreter

Wabi is a highly experimental interpreter of WebAssembly bytecode. Current functionality includes parsing, instantiating, and executing self contained, single-module WebAssembly.

Quick Start

Since the crate is not yet published, clone the repository and add it to your Cargo.toml:

[dependencies]
wabi = { version = "*", path = "path/to/wabi" }

Add some imports:

use wabi::{args, runtime::ModuleInstance};

Load a module from some bytes, create some arguments, and execute a function:

use wabi::{args, runtime::ModuleInstance};

fn main() {
    let input = byte_slice;
    let args = args![5_i32, 5_i32];

    let mut instance = ModuleInstance::builder()
        .bytes(input)
        .build()
        .unwrap();

    let res = instance.invoke("add", &args).unwrap();

    println!("{:?}", res);
}

Running a .wast file:

cargo run --bin run_wast -- -f ./path/to/testsuite/labels.wast

================ ./path/to/testsuite/labels.wast ================
[MODULE] Name: None
[0291] [PASSED] block
[0292] [PASSED] loop1
[0293] [PASSED] loop2
/* snip */
[0308] [PASSED] return
[0313] [PASSED] br
[0314] [PASSED] shadowing
[0315] [PASSED] redefinition

Pass in multiple files to run them all.





License

Licensed under either of

at your option.

Contribution

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.

Highly experimental, do not use!