[−][src]Struct wabt::Wasm2Wat
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]
impl Wasm2Wat
pub fn new() -> Wasm2Wat
[src]
pub fn new() -> Wasm2Wat
Create Wasm2Wat
with default configuration.
pub fn read_debug_names(&mut self, read_debug_names: bool) -> &mut Wasm2Wat
[src]
pub fn read_debug_names(&mut self, read_debug_names: bool) -> &mut Wasm2Wat
Read debug names in the binary file.
false
by default.
pub fn fold_exprs(&mut self, fold_exprs: bool) -> &mut Wasm2Wat
[src]
pub fn fold_exprs(&mut self, fold_exprs: bool) -> &mut Wasm2Wat
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.
pub fn inline_export(&mut self, inline_export: bool) -> &mut Wasm2Wat
[src]
pub fn inline_export(&mut self, inline_export: bool) -> &mut Wasm2Wat
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.
pub fn convert<S: AsRef<[u8]>>(&self, wasm: S) -> Result<WabtBuf, Error>
[src]
pub fn convert<S: AsRef<[u8]>>(&self, wasm: S) -> Result<WabtBuf, Error>
Perform conversion.
Auto Trait Implementations
Blanket Implementations
impl<T> FromBits for T
[src]
impl<T> FromBits for T
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
🔬 This is a nightly-only experimental API. (
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,