Struct wasm_encoder::Function [−][src]
pub struct Function { /* fields omitted */ }
Expand description
An encoder for a function body within the code section.
Example
use wasm_encoder::{CodeSection, Function, Instruction};
// Define the function body for:
//
// (func (param i32 i32) (result i32)
// local.get 0
// local.get 1
// i32.add)
let locals = vec![];
let mut func = Function::new(locals);
func.instruction(Instruction::LocalGet(0));
func.instruction(Instruction::LocalGet(1));
func.instruction(Instruction::I32Add);
// Add our function to the code section.
let mut code = CodeSection::new();
code.function(&func);
Implementations
pub fn new<L>(locals: L) -> Self where
L: IntoIterator<Item = (u32, ValType)>,
L::IntoIter: ExactSizeIterator,
pub fn new<L>(locals: L) -> Self where
L: IntoIterator<Item = (u32, ValType)>,
L::IntoIter: ExactSizeIterator,
Create a new function body with the given locals.
Write an instruction into this function body.
Add raw bytes to this function’s body.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Function
impl UnwindSafe for Function
Blanket Implementations
Mutably borrows from an owned value. Read more