Struct wabt::Wasm2Wat [] [src]

pub struct Wasm2Wat { /* fields omitted */ }

A builder for converting wasm binary to wasm text format.

Examples

extern crate wabt;
use wabt::Wasm2Wat;

fn main() {
    let wasm_text = Wasm2Wat::new()
        .fold_exprs(true)
        .inline_export(true)
        .convert(
            &[
                0, 97, 115, 109, // \0ASM - magic
                1, 0, 0, 0       //  0x01 - version
            ]
        ).unwrap();
 
}

Methods

impl Wasm2Wat
[src]

[src]

Create Wasm2Wat with default configuration.

[src]

Read debug names in the binary file.

false by default.

[src]

Write folded expressions where possible.

Example of folded code (if true):

(module
    (func (param i32 i32) (result i32)
        (i32.add ;; Add loaded arguments
            (get_local 0) ;; Load first arg
            (get_local 1) ;; Load second arg
        )
    )
)

Example of straight code (if false):

(module
    (func (param i32 i32) (result i32)
        get_local 0 ;; Load first arg
        get_local 1 ;; Load second arg
        i32.add     ;; Add loaded arguments
    )
)

false by default.

[src]

Write all exports inline.

Example of code with inline exports (if true):

(module
(func $addTwo (export "addTwo") (param $p0 i32) (param $p1 i32) (result i32)
  (i32.add
    (get_local $p0)
    (get_local $p1))))

Example of code with separate exports (if false):

(module
  (func $addTwo (param $p0 i32) (param $p1 i32) (result i32)
    (i32.add
      (get_local $p0)
      (get_local $p1)))
  (export "addTwo" (func $addTwo)))

false by default.

[src]

Perform conversion.