instruction

package
v0.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package instruction defines WASM instruction types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	NoImmediateArgs
	Type   *types.ValueType
	Instrs []Instruction
}

Block represents a WASM block instruction.

func (Block) BlockType

func (i Block) BlockType() *types.ValueType

BlockType returns the type of the block's return value.

func (Block) Instructions

func (i Block) Instructions() []Instruction

Instructions returns the instructions contained in the block.

func (Block) Op

func (Block) Op() opcode.Opcode

Op returns the opcode of the instruction

type Br added in v0.11.0

type Br struct {
	Index uint32
}

Br represents a WASM br instruction.

func (Br) ImmediateArgs added in v0.11.0

func (i Br) ImmediateArgs() []interface{}

ImmediateArgs returns the block index to break to.

func (Br) Op added in v0.11.0

func (Br) Op() opcode.Opcode

Op returns the opcode of the instruction.

type BrIf

type BrIf struct {
	Index uint32
}

BrIf represents a WASM br_if instruction.

func (BrIf) ImmediateArgs

func (i BrIf) ImmediateArgs() []interface{}

ImmediateArgs returns the block index to break to.

func (BrIf) Op

func (BrIf) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Call

type Call struct {
	Index uint32
}

Call represents a WASM call instruction.

func (Call) ImmediateArgs

func (i Call) ImmediateArgs() []interface{}

ImmediateArgs returns the function index.

func (Call) Op

func (Call) Op() opcode.Opcode

Op returns the opcode of the instruction.

type CallIndirect added in v0.44.0

type CallIndirect struct {
	Index    uint32 // type index
	Reserved byte   // zero for now
}

CallIndirect represents a WASM call_indirect instruction.

func (CallIndirect) ImmediateArgs added in v0.44.0

func (i CallIndirect) ImmediateArgs() []interface{}

ImmediateArgs returns the function index.

func (CallIndirect) Op added in v0.44.0

func (CallIndirect) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Drop added in v0.44.0

type Drop struct {
	NoImmediateArgs
}

Drop reprsents a WASM drop instruction.

func (Drop) Op added in v0.44.0

func (Drop) Op() opcode.Opcode

Op returns the opcode of the instruction.

type End

type End struct {
	NoImmediateArgs
}

End represents the special WASM end instruction.

func (End) Op

func (End) Op() opcode.Opcode

Op returns the opcode of the instruction.

type F32Add added in v0.44.0

type F32Add struct {
	NoImmediateArgs
}

F32Add represents the WASM f32.add instruction.

func (F32Add) Op added in v0.44.0

func (F32Add) Op() opcode.Opcode

Op returns the opcode of the instruction.

type F32Const added in v0.44.0

type F32Const struct {
	Value int32
}

F32Const represents the WASM f32.const instruction.

func (F32Const) ImmediateArgs added in v0.44.0

func (i F32Const) ImmediateArgs() []interface{}

ImmediateArgs returns the f32 value to push onto the stack.

func (F32Const) Op added in v0.44.0

func (F32Const) Op() opcode.Opcode

Op returns the opcode of the instruction.

type F64Add added in v0.44.0

type F64Add struct {
	NoImmediateArgs
}

F64Add represents the WASM f64.add instruction.

func (F64Add) Op added in v0.44.0

func (F64Add) Op() opcode.Opcode

Op returns the opcode of the instruction.

type F64Const added in v0.44.0

type F64Const struct {
	Value float64
}

F64Const represents the WASM f64.const instruction.

func (F64Const) ImmediateArgs added in v0.44.0

func (i F64Const) ImmediateArgs() []interface{}

ImmediateArgs returns the f64 value to push onto the stack.

func (F64Const) Op added in v0.44.0

func (F64Const) Op() opcode.Opcode

Op returns the opcode of the instruction.

type GetLocal

type GetLocal struct {
	Index uint32
}

GetLocal represents the WASM get_local instruction.

func (GetLocal) ImmediateArgs

func (i GetLocal) ImmediateArgs() []interface{}

ImmediateArgs returns the index of the local variable to push onto the stack.

func (GetLocal) Op

func (GetLocal) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Add added in v0.44.0

type I32Add struct {
	NoImmediateArgs
}

I32Add represents the WASM i32.add instruction.

func (I32Add) Op added in v0.44.0

func (I32Add) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Const

type I32Const struct {
	Value int32
}

I32Const represents the WASM i32.const instruction.

func (I32Const) ImmediateArgs

func (i I32Const) ImmediateArgs() []interface{}

ImmediateArgs returns the i32 value to push onto the stack.

func (I32Const) Op

func (I32Const) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Eq added in v0.44.0

type I32Eq struct {
	NoImmediateArgs
}

I32Eq represents the WASM i32.eq instruction.

func (I32Eq) Op added in v0.44.0

func (I32Eq) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Eqz

type I32Eqz struct {
	NoImmediateArgs
}

I32Eqz represents the WASM i32.eqz instruction.

func (I32Eqz) Op

func (I32Eqz) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32GeS

type I32GeS struct {
	NoImmediateArgs
}

I32GeS represents the WASM i32.ge_s instruction.

func (I32GeS) Op

func (I32GeS) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32GtS

type I32GtS struct {
	NoImmediateArgs
}

I32GtS represents the WASM i32.gt_s instruction.

func (I32GtS) Op

func (I32GtS) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32LeS

type I32LeS struct {
	NoImmediateArgs
}

I32LeS represents the WASM i32.le_s instruction.

func (I32LeS) Op

func (I32LeS) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Load added in v0.44.0

type I32Load struct {
	Offset int32
	Align  int32 // expressed as a power of two
}

I32Load represents the WASM i32.load instruction.

func (I32Load) ImmediateArgs added in v0.44.0

func (i I32Load) ImmediateArgs() []interface{}

ImmediateArgs returns the static offset and alignment operands.

func (I32Load) Op added in v0.44.0

func (I32Load) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32LtS

type I32LtS struct {
	NoImmediateArgs
}

I32LtS represents the WASM i32.lt_s instruction.

func (I32LtS) Op

func (I32LtS) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Mul added in v0.44.0

type I32Mul struct {
	NoImmediateArgs
}

I32Mul represents the WASM i32.mul instruction.

func (I32Mul) Op added in v0.44.0

func (I32Mul) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Ne added in v0.10.3

type I32Ne struct {
	NoImmediateArgs
}

I32Ne represents the WASM i32.ne instruction.

func (I32Ne) Op added in v0.10.3

func (I32Ne) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Store added in v0.44.0

type I32Store struct {
	Offset int32
	Align  int32 // expressed as a power of two
}

I32Store represents the WASM i32.store instruction.

func (I32Store) ImmediateArgs added in v0.44.0

func (i I32Store) ImmediateArgs() []interface{}

ImmediateArgs returns the static offset and alignment operands.

func (I32Store) Op added in v0.44.0

func (I32Store) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I32Sub added in v0.44.0

type I32Sub struct {
	NoImmediateArgs
}

I32Sub represents the WASM i32.sub instruction.

func (I32Sub) Op added in v0.44.0

func (I32Sub) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I64Add added in v0.44.0

type I64Add struct {
	NoImmediateArgs
}

I64Add represents the WASM i64.add instruction.

func (I64Add) Op added in v0.44.0

func (I64Add) Op() opcode.Opcode

Op returns the opcode of the instruction.

type I64Const

type I64Const struct {
	Value int64
}

I64Const represents the WASM i64.const instruction.

func (I64Const) ImmediateArgs

func (i I64Const) ImmediateArgs() []interface{}

ImmediateArgs returns the i64 value to push onto the stack.

func (I64Const) Op

func (I64Const) Op() opcode.Opcode

Op returns the opcode of the instruction.

type If added in v0.44.0

type If struct {
	NoImmediateArgs
	Type   *types.ValueType
	Instrs []Instruction
}

If represents a WASM if instruction. NOTE(sr): we only use if with one branch so far!

func (If) BlockType added in v0.44.0

func (i If) BlockType() *types.ValueType

BlockType returns the type of the if's THEN branch.

func (If) Instructions added in v0.44.0

func (i If) Instructions() []Instruction

Instructions represents the instructions contained in the if's THEN branch.

func (If) Op added in v0.44.0

func (If) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Instruction

type Instruction interface {
	Op() opcode.Opcode
	ImmediateArgs() []interface{}
}

Instruction represents a single WASM instruction.

type Loop

type Loop struct {
	NoImmediateArgs
	Type   *types.ValueType
	Instrs []Instruction
}

Loop represents a WASM loop instruction.

func (Loop) BlockType

func (i Loop) BlockType() *types.ValueType

BlockType returns the type of the loop's return value.

func (Loop) Instructions

func (i Loop) Instructions() []Instruction

Instructions represents the instructions contained in the loop.

func (Loop) Op

func (Loop) Op() opcode.Opcode

Op returns the opcode of the instruction.

type NoImmediateArgs

type NoImmediateArgs struct {
}

NoImmediateArgs indicates the instruction has no immediate arguments.

func (NoImmediateArgs) ImmediateArgs

func (NoImmediateArgs) ImmediateArgs() []interface{}

ImmediateArgs returns the immedate arguments of an instruction.

type Nop

type Nop struct {
	NoImmediateArgs
}

Nop represents a WASM no-op instruction.

func (Nop) Op

func (Nop) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Return

type Return struct {
	NoImmediateArgs
}

Return represents a WASM return instruction.

func (Return) Op

func (Return) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Select added in v0.44.0

type Select struct {
	NoImmediateArgs
}

Select reprsents a WASM select instruction.

func (Select) Op added in v0.44.0

func (Select) Op() opcode.Opcode

Op returns the opcode of the instruction.

type SetLocal

type SetLocal struct {
	Index uint32
}

SetLocal represents the WASM set_local instruction.

func (SetLocal) ImmediateArgs

func (i SetLocal) ImmediateArgs() []interface{}

ImmediateArgs returns the index of the local variable to set with the top of the stack.

func (SetLocal) Op

func (SetLocal) Op() opcode.Opcode

Op returns the opcode of the instruction.

type StructuredInstruction

type StructuredInstruction interface {
	Instruction
	BlockType() *types.ValueType
	Instructions() []Instruction
}

StructuredInstruction represents a structured control instruction like br_if.

type TeeLocal added in v0.44.0

type TeeLocal struct {
	Index uint32
}

TeeLocal represents the WASM tee_local instruction.

func (TeeLocal) ImmediateArgs added in v0.44.0

func (i TeeLocal) ImmediateArgs() []interface{}

ImmediateArgs returns the index of the local variable to "tee" with the top of the stack (like set, but retaining the top of the stack).

func (TeeLocal) Op added in v0.44.0

func (TeeLocal) Op() opcode.Opcode

Op returns the opcode of the instruction.

type Unreachable

type Unreachable struct {
	NoImmediateArgs
}

Unreachable represents a WASM unreachable instruction.

func (Unreachable) Op

func (Unreachable) Op() opcode.Opcode

Op returns the opcode of the instruction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL