fn emit_table_instruction<O: Write + ?Sized>(
    instruction: &TableInstruction,
    output: &mut O,
) -> Result<usize, EmitError> {
    let mut bytes = 0;

    match instruction {
        TableInstruction::Get(index) => {
            bytes += emit_byte(0x25u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Set(index) => {
            bytes += emit_byte(0x26u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Init(element, table) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(12u32, output)?;
            bytes += emit_u32(element, output)?;
            bytes += emit_u32(table, output)?;
        }
        TableInstruction::ElementDrop(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(13u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Copy(table_a, table_b) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(14u32, output)?;
            bytes += emit_u32(table_a, output)?;
            bytes += emit_u32(table_b, output)?;
        }
        TableInstruction::Grow(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(15u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Size(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(16u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Fill(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(17u32, output)?;
            bytes += emit_u32(index, output)?;
        }
    }

    Ok(bytes)
}
/// Emit a table instruction to the output.
///
/// See https://webassembly.github.io/spec/core/binary/instructions.html#table-instructions
Emit a table instruction to the output.
Emit a table instruction to the output .
fn emit_table_instruction<O: Write + ?Sized>(
    instruction: &TableInstruction,
    output: &mut O,
) -> Result<usize, EmitError> {
    let mut bytes = 0;
    match instruction {
        TableInstruction::Get(index) => {
            bytes += emit_byte(0x25u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Set(index) => {
            bytes += emit_byte(0x26u8, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Init(element, table) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(12u32, output)?;
            bytes += emit_u32(element, output)?;
            bytes += emit_u32(table, output)?;
        }
        TableInstruction::ElementDrop(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(13u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Copy(table_a, table_b) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(14u32, output)?;
            bytes += emit_u32(table_a, output)?;
            bytes += emit_u32(table_b, output)?;
        }
        TableInstruction::Grow(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(15u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Size(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(16u32, output)?;
            bytes += emit_u32(index, output)?;
        }
        TableInstruction::Fill(index) => {
            bytes += emit_byte(0xFCu8, output)?;
            bytes += emit_u32(17u32, output)?;
            bytes += emit_u32(index, output)?;
        }
    }
    Ok(bytes)
}
fn emit_table_instruction < O : Write + ? Sized > ( instruction : & TableInstruction , output : & mut O , ) -> Result < usize , EmitError > { let mut bytes = 0 ; match instruction { TableInstruction :: Get ( index ) => { bytes += emit_byte ( 0x25u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } TableInstruction :: Set ( index ) => { bytes += emit_byte ( 0x26u8 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } TableInstruction :: Init ( element , table ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 12u32 , output ) ? ; bytes += emit_u32 ( element , output ) ? ; bytes += emit_u32 ( table , output ) ? ; } TableInstruction :: ElementDrop ( index ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 13u32 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } TableInstruction :: Copy ( table_a , table_b ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 14u32 , output ) ? ; bytes += emit_u32 ( table_a , output ) ? ; bytes += emit_u32 ( table_b , output ) ? ; } TableInstruction :: Grow ( index ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 15u32 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } TableInstruction :: Size ( index ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 16u32 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } TableInstruction :: Fill ( index ) => { bytes += emit_byte ( 0xFCu8 , output ) ? ; bytes += emit_u32 ( 17u32 , output ) ? ; bytes += emit_u32 ( index , output ) ? ; } } Ok ( bytes ) }
Emit a table instruction to the output.
Emit a table instruction to the output .
instruction
&TableInstruction
output
&mut O
instruction
&TableInstruction
output
&mut O