Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrFuncInvalidInputType = errors.New("invalid func input type") ErrFuncInvalidReturnType = errors.New("invalid func return type") )
errors of func
var ( ErrExportedFuncNotFound = errors.New("exported func is not found") ErrFuncIndexOutOfRange = errors.New("function index out of range") ErrInvalidArgNum = errors.New("invalid number of arguments") )
errors on exec func
var ( ErrUnreachable = errors.New("unreachable") ErrBlockNotInitialized = errors.New("block not initialized") ErrBlockNotFound = errors.New("block not found") ErrFuncSignMismatch = errors.New("function signature mismatch") ErrLabelNotFound = errors.New("label not found") ErrTableIndexOutOfRange = errors.New("table index out of range") ErrTableInstanceNotInitialized = errors.New("table entry not initialized") )
errors on control instr
var ( ErrInvalidMagicNumber = errors.New("invalid magic number") ErrInvalidVersion = errors.New("invalid version header") )
errors on parsing module
var ErrPtrOutOfBounds = errors.New("pointer is out of bounds")
ErrPtrOutOfBounds will be throw when the pointer visiting a pos out of the range of memory
var ErrUndefined = errors.New("undefined")
ErrUndefined is a panic error
Functions ¶
func MemoryPagesToBytesNum ¶
MemoryPagesToBytesNum converts the given pages into the number of bytes contained in these pages.
Types ¶
type Frame ¶
type Frame struct { PC uint64 Func *wasmFunc Locals []uint64 LabelStack *stacks.Stack[*stacks.Label] }
Frame is the context data of one instance
type Global ¶
type Global struct { *types.GlobalType Val interface{} }
Global is an instance of the global value
type HostFunc ¶
type HostFunc struct { Signature *types.FuncType // the shape of func (defined by inputs and outputs) // Generator is a func defined by other dev which acts as a Generator to the function // (generate when NewInstance's func initializing Generator func(ins *Instance) interface{} // contains filtered or unexported fields }
HostFunc is an implement of wasm.Fn, which represents all the functions defined under host(golang) environment
type IndexSpace ¶
IndexSpace is the indeices to the imports
type Instance ¶
type Instance struct { *Module Active *Frame FrameStack *stacks.Stack[*Frame] Functions []fn Memory *Memory Globals []uint64 OperandStack *stacks.Stack[uint64] }
Instance is an instantiated module
func NewInstance ¶
NewInstance will instantiate the module with extern modules
type Memory ¶
type Memory struct { types.MemoryType Value []byte }
Memory is an instance of the memory value
type Module ¶
type Module struct { config.ModuleConfig // sections TypeSection []*types.FuncType ImportSection []*segments.ImportSegment FunctionSection []uint32 TableSection []*types.TableType MemorySection []*types.MemoryType GlobalSection []*segments.GlobalSegment ExportSection map[string]*segments.ExportSegment StartSection []uint32 ElementsSection []*segments.ElemSegment CodeSection []*segments.CodeSegment DataSection []*segments.DataSegment // index spaces IndexSpace *IndexSpace }
Module is a standard wasm module implement according to wasm v1, https://www.w3.org/TR/wasm-core-1/#syntax-module%E2%91%A0