/// Emit a variable instruction to the output.
///
/// See https://webassembly.github.io/spec/core/binary/instructions.html#variable-instructions
Emit a variable instruction to the output.
Emit a variable instruction to the output .
fn emit_variable_instruction<O: Write + ?Sized>(
    instruction: &VariableInstruction,
    output: &mut O,
) -> Result<usize, EmitError> {
    let mut bytes = 0;
    match instruction {
        VariableInstruction::LocalGet(index) => {
            bytes += emit_byte(0x20u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        VariableInstruction::LocalSet(index) => {
            bytes += emit_byte(0x21u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        VariableInstruction::LocalTee(index) => {
            bytes += emit_byte(0x22u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        VariableInstruction::GlobalGet(index) => {
            bytes += emit_byte(0x23u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        VariableInstruction::GlobalSet(index) => {
            bytes += emit_byte(0x24u8, output)?;
            bytes += emit_u32(index, output)?;
        }
    }
    Ok(bytes)
}
fn emit_variable_instruction < O : Write + ? Sized > ( instruction : & VariableInstruction , output : & mut O , ) -> Result < usize , EmitError > { let mut bytes = 0 ; match instruction { VariableInstruction :: LocalGet ( index ) => { bytes += emit_byte ( 0x20u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } VariableInstruction :: LocalSet ( index ) => { bytes += emit_byte ( 0x21u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } VariableInstruction :: LocalTee ( index ) => { bytes += emit_byte ( 0x22u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } VariableInstruction :: GlobalGet ( index ) => { bytes += emit_byte ( 0x23u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } VariableInstruction :: GlobalSet ( index ) => { bytes += emit_byte ( 0x24u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } } Ok ( bytes ) }
Emit a variable instruction to the output.
Emit a variable instruction to the output .
instruction
&VariableInstruction
output
&mut O