Struct wabt::Wat2Wasm [] [src]

pub struct Wat2Wasm { /* fields omitted */ }

A builder for translate wasm text source to wasm binary format.

This version allows you to tweak parameters. If you need simple version check out wat2wasm.

Examples

extern crate wabt;
use wabt::Wat2Wasm;

fn main() {
    let wasm_binary = Wat2Wasm::new()
        .canonicalize_lebs(false)
        .write_debug_names(true)
        .convert(
            r#"
                (module
                    (import "spectest" "print" (func $print (param i32)))
                    (func (export "main")
                        i32.const 1312
                        call $print
                    )
                )
            "#
        ).unwrap();
 
}

Methods

impl Wat2Wasm
[src]

[src]

Create Wat2Wasm with default configuration.

[src]

Write canonicalized LEB128 for var ints.

Set this to false to write all LEB128 sizes as 5-bytes instead of their minimal size. true by default.

[src]

Create a relocatable wasm binary

(suitable for linking with wasm-link). false by default.

[src]

Write debug names to the generated binary file

false by default.

[src]

Check for validity of module before writing.

true by default.

[src]

Perform conversion.