Documentation ¶
Index ¶
- Constants
- Variables
- func Array(args []interface{}) interface{}
- func Date(argument []interface{}) interface{}
- func RegisterBuiltins(g *Global)
- func Throw(fmtstr string, args ...interface{})
- func ThrowException(e *Exception)
- func Uint8Array(args []interface{}) interface{}
- type Exception
- type Global
- type Memory
- type PropertyGetter
- type Ref
- type VM
- func (vm *VM) Call(ref Ref, method string, args []Ref) Ref
- func (vm *VM) CatchException(e *Ref)
- func (vm *VM) DebugStr(ref Ref) string
- func (vm *VM) Exception(e *Exception) Ref
- func (vm *VM) Invoke(ref Ref, args []Ref) Ref
- func (vm *VM) New(ref Ref, args []Ref) Ref
- func (vm *VM) Property(ref Ref, name string) Ref
- func (vm *VM) Store(x interface{}) Ref
- func (vm *VM) Value(ref Ref) *Value
- type VMConfig
- type Value
Constants ¶
const (
// ValueUndefined is the ref of Undefined
ValueUndefined = 0
)
Variables ¶
var ( // ExceptionNotfound wraps the EEXIS errno ExceptionNotfound = NewException("EEXIS", "not found") // ExceptionNoSys wraps the ENOSYS errno ExceptionNoSys = NewException("ENOSYS", "not implemention") // ExceptionInvalidArgument wraps the EINVAL errno ExceptionInvalidArgument = NewException("EINVAL", "invalid argument") // ExceptionUndefined wraps the EINVAL errno ExceptionUndefined = NewException("EINVAL", "undefined") )
Functions ¶
func RegisterBuiltins ¶
func RegisterBuiltins(g *Global)
RegisterBuiltins register js builtins to Global object
func Throw ¶
func Throw(fmtstr string, args ...interface{})
Throw uses a fmt like style to throw an exception
func Uint8Array ¶
func Uint8Array(args []interface{}) interface{}
Uint8Array simulates Uint8Array function
Types ¶
type Exception ¶
Exception simulates js Exception
func ExceptionRefNotFound ¶
ExceptionRefNotFound is the Exception throwed when Ref is not found by VM
func NewException ¶
NewException instances a Exception
type Global ¶
type Global struct {
// contains filtered or unexported fields
}
Global simulates js'global object
func (*Global) GetProperty ¶
GetProperty implements js.PropertyGetter interface
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory simulates the Memory object in wasm_exec.js
func (*Memory) GetProperty ¶
GetProperty implements the PropertyGetter interface
type PropertyGetter ¶
A PropertyGetter can get property from GetProperty method
type Ref ¶
type Ref int64
Ref represents the unique id of a js object
const ( // ValueNaN is the ref of Nan ValueNaN Ref = nanHead<<32 | iota // ValueZero is the ref of number 0 ValueZero // ValueNull is the ref of Null ValueNull // ValueTrue is the ref of True ValueTrue // ValueFalse is the ref of False ValueFalse // ValueGlobal is the ref of global ValueGlobal // ValueMemory is the ref of wasm Memory object ValueMemory // ValueGo is the ref of Go object ValueGo )
type VM ¶
VM simulates the js runtime
func (*VM) CatchException ¶
CatchException will recover panic and store the value to e only if the recovered type is *Exception otherwise panic will go on