vm

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpPush byte = iota
	OpPop
	OpRot
	OpFetch
	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
	OpCall
	OpCallFast
	OpMethod
	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 AnyToInt

func AnyToInt(value interface{}) int

func FetchFn

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

func Run

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

Types

type Call

type Call struct {
	Name string `msgpack:"name"`
	Size int    `msgpack:"size"`
}

type Program

type Program struct {
	Source    *file.Source          `msgpack:"source"`
	Locations map[int]file.Location `msgpack:"locations"`
	Constants []interface{}         `msgpack:"constants"`
	Bytecode  []byte                `msgpack:"bytecode"`
}

func (*Program) Disassemble

func (program *Program) Disassemble() string

type PropertyProvider

type PropertyProvider interface {
	FetchProperty(property string) interface{}
}

type Scope

type Scope map[string]interface{}

type VM

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

func Debug

func Debug() *VM

func (*VM) Init

func (vm *VM) Init(program *Program, env interface{})

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()

type ValueProvider

type ValueProvider interface {
	GetValue() interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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