Documentation ¶
Overview ¶
Package instruction contains the handlers for specific groups of instructions. Each instruction object knows how to process itself in the context of some executors that work on instructions like WasmReader, WasmWriter, WasmAnalyzer, and WasmRunner.
Externally each instruction is seen through a simple Instruction interface. Internally they are seen through the instruction.ctxInstruction interface, which provides the extra interface methods each object needs to be handled by their corresponding executor. In addition each instruction object contains a Base object that provides common methods and fields for each instruction.
The following instruction groups are defined:
Binary - operate on 2 same-type arguments and return a result of that same type. Block - block type pseudo-instructions (block, loop, and if) Bool - compare 2 same-type arguments and return a boolean (i32) type. Branch - branching instructions (br, br_if, and br_table, return). Call - function call instructions (call, call_indirect, memory.grow, and memory.size). Const - define constant values (const.i32, const.i64, const.f32, and const.f64). Convert - convert from one type to another type Mem - access memory locations (load and store). Unary - operate on 1 argument and return a result of the same type as the argument. Var - get or set local or global variables. Misc - the few remaining instructions that fall outside the above groups. (unreachable, nop, else, end, drop, select)
Index ¶
- Constants
- Variables
- func AnalyzeBlock(a *context.Analyzer)
- func CreateInstruction(opcode byte) helper.Instruction
- func NewBinary() helper.Instruction
- func NewBlock() helper.Instruction
- func NewBool() helper.Instruction
- func NewBranch() helper.Instruction
- func NewCall() helper.Instruction
- func NewConst() helper.Instruction
- func NewConvert() helper.Instruction
- func NewMem() helper.Instruction
- func NewMisc() helper.Instruction
- func NewUnary() helper.Instruction
- func NewVar() helper.Instruction
- func ReadBlock(r *context.Reader) []helper.Instruction
- func RunBlock(vm *Runner, block []helper.Instruction) error
- func WriteBlock(w *context.Writer, block []helper.Instruction)
- type Base
- func (o *Base) Analyze(_ *context.Analyzer)
- func (o *Base) GetIP() int
- func (o *Base) Mnemonic() string
- func (o *Base) Opcode() byte
- func (o *Base) Read(_ *context.Reader)
- func (o *Base) Run(vm *Runner)
- func (o *Base) StackChange() int
- func (o *Base) String() string
- func (o *Base) Write(_ *context.Writer)
- type Binary
- type Block
- type Bool
- type Branch
- type Call
- type Const
- type Convert
- type Mem
- type Misc
- type Operation
- type Runner
- type Unary
- type Var
Constants ¶
const BLOCK_EMPTY = int32(-0x40)
Variables ¶
var Operations [256]Operation
Functions ¶
func AnalyzeBlock ¶
func CreateInstruction ¶
func CreateInstruction(opcode byte) helper.Instruction
func NewBinary ¶
func NewBinary() helper.Instruction
func NewBlock ¶
func NewBlock() helper.Instruction
func NewBool ¶
func NewBool() helper.Instruction
func NewBranch ¶
func NewBranch() helper.Instruction
func NewCall ¶
func NewCall() helper.Instruction
func NewConst ¶
func NewConst() helper.Instruction
func NewConvert ¶
func NewConvert() helper.Instruction
func NewMem ¶
func NewMem() helper.Instruction
func NewMisc ¶
func NewMisc() helper.Instruction
func NewUnary ¶
func NewUnary() helper.Instruction
func NewVar ¶
func NewVar() helper.Instruction
func WriteBlock ¶
func WriteBlock(w *context.Writer, block []helper.Instruction)
Types ¶
type Base ¶
Base implements basic behavior for all Instruction types. This class is not to be instantiated by itself. Use one of the concrete instruction types instead.
func (*Base) StackChange ¶
type Call ¶
type Call struct { Base // contains filtered or unexported fields }