vm

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MemoryBudget int = 1e6
)

Functions

func Run

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

Types

type Opcode

type Opcode byte
const (
	OpPush Opcode = iota
	OpPushInt
	OpPop
	OpRot
	OpFetch
	OpFetchField
	OpFetchEnv
	OpFetchEnvField
	OpFetchEnvFast
	OpMethod
	OpMethodEnv
	OpTrue
	OpFalse
	OpNil
	OpNegate
	OpNot
	OpEqual
	OpEqualInt
	OpEqualString
	OpJump
	OpJumpIfTrue
	OpJumpIfFalse
	OpJumpIfNil
	OpJumpIfEnd
	OpJumpBackward
	OpIn
	OpLess
	OpMore
	OpLessOrEqual
	OpMoreOrEqual
	OpAdd
	OpSubtract
	OpMultiply
	OpDivide
	OpModulo
	OpExponent
	OpRange
	OpMatches
	OpMatchesConst
	OpContains
	OpStartsWith
	OpEndsWith
	OpSlice
	OpCall
	OpCallFast
	OpArray
	OpMap
	OpLen
	OpCast
	OpDeref
	OpIncrementIt
	OpIncrementCount
	OpGetCount
	OpGetLen
	OpPointer
	OpBegin
	OpEnd // This opcode must be at the end of this list.
)

type Program

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

func (*Program) Disassemble

func (program *Program) Disassemble() string

type Scope

type Scope struct {
	Array reflect.Value
	It    int
	Len   int
	Count int
}

type VM

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

func Debug

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