Struct wasmprinter::Config
source · pub struct Config { /* private fields */ }
Expand description
Configuration used to print a WebAssembly binary.
This structure is used to control the overal structure of how wasm binaries are printed and tweaks various ways that configures the output.
Implementations§
source§impl Config
impl Config
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Config
object that’s ready to start printing wasm
binaries to strings.
sourcepub fn print_offsets(&mut self, print: bool) -> &mut Self
pub fn print_offsets(&mut self, print: bool) -> &mut Self
Whether or not to print binary offsets of each item as comments in the text format whenever a newline is printed.
sourcepub fn print_skeleton(&mut self, print: bool) -> &mut Self
pub fn print_skeleton(&mut self, print: bool) -> &mut Self
Whether or not to print only a “skeleton” which skips function bodies, data segment contents, element segment contents, etc.
sourcepub fn name_unnamed(&mut self, enable: bool) -> &mut Self
pub fn name_unnamed(&mut self, enable: bool) -> &mut Self
Assign names to all unnamed items.
If enabled then any previously unnamed item will have a name synthesized
that looks like $#func10
for example. The leading #
indicates that
it’s wasmprinter
-generated. The func
is the namespace of the name
and provides extra context about the item when referenced. The 10 is the
local index of the item.
Note that if the resulting text output is converted back to binary the
resulting name
custom section will not be the same as before.
sourcepub fn fold_instructions(&mut self, enable: bool) -> &mut Self
pub fn fold_instructions(&mut self, enable: bool) -> &mut Self
Print instructions in folded form where possible.
This will cause printing to favor the s-expression (parenthesized) form
of WebAssembly instructions. For example this output would be generated
for a simple add
function:
(module
(func $foo (param i32 i32) (result i32)
(i32.add
(local.get 0)
(local.get 1))
)
)