vm

package
Version: v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 7 Imported by: 90

Documentation

Index

Constants

View Source
const (
	OpPush byte = iota
	OpPop
	OpRot
	OpFetch
	OpFetchNilSafe
	OpFetchMap
	OpTrue
	OpFalse
	OpNil
	OpNegate
	OpNot
	OpEqual
	OpEqualInt
	OpEqualString
	OpJump
	OpJumpIfTrue
	OpJumpIfFalse
	OpJumpBackward
	OpIn
	OpLess
	OpMore
	OpLessOrEqual
	OpMoreOrEqual
	OpAdd
	OpSubtract
	OpMultiply
	OpDivide
	OpModulo
	OpExponent
	OpRange
	OpMatches
	OpMatchesConst
	OpContains
	OpStartsWith
	OpEndsWith
	OpIndex
	OpSlice
	OpProperty
	OpPropertyNilSafe
	OpCall
	OpCallFast
	OpMethod
	OpMethodNilSafe
	OpArray
	OpMap
	OpLen
	OpCast
	OpStore
	OpLoad
	OpInc
	OpBegin
	OpEnd // This opcode must be at the end of this list.
)

Variables

View Source
var (
	MemoryBudget int = 1e6
)

Functions

func FetchFn added in v1.6.0

func FetchFn(from interface{}, name string) reflect.Value

func FetchFnNil added in v1.9.0

func FetchFnNil(from interface{}, name string) reflect.Value

func Run

func Run(program *Program, env interface{}) (interface{}, error)

Types

type Call

type Call struct {
	Name string
	Size int
}

type Fetcher added in v1.9.0

type Fetcher interface {
	Fetch(interface{}) interface{}
}

type Program

type Program struct {
	Source    *file.Source
	Locations map[int]file.Location
	Constants []interface{}
	Bytecode  []byte
}

func (*Program) Disassemble

func (program *Program) Disassemble() string

type Scope

type Scope map[string]interface{}

type VM

type VM struct {
	// contains filtered or unexported fields
}

func Debug added in v1.8.3

func Debug() *VM

func (*VM) Position

func (vm *VM) Position() chan int

func (*VM) Run

func (vm *VM) Run(program *Program, env interface{}) (out interface{}, err error)

func (*VM) Scope

func (vm *VM) Scope() Scope

func (*VM) Stack

func (vm *VM) Stack() []interface{}

func (*VM) Step

func (vm *VM) Step()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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