vm

package
v1.12.7 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncTypes = []interface{}{
	1:  new(func() time.Duration),
	2:  new(func() time.Month),
	3:  new(func() time.Time),
	4:  new(func() time.Weekday),
	5:  new(func() []uint8),
	6:  new(func() []interface{}),
	7:  new(func() bool),
	8:  new(func() uint8),
	9:  new(func() float64),
	10: new(func() int),
	11: new(func() int64),
	12: new(func() interface{}),
	13: new(func() map[string]interface{}),
	14: new(func() int32),
	15: new(func() string),
	16: new(func() uint),
	17: new(func() uint64),
	18: new(func(time.Duration) time.Duration),
	19: new(func(time.Duration) time.Time),
	20: new(func(time.Time) time.Duration),
	21: new(func(time.Time) bool),
	22: new(func([]interface{}, string) string),
	23: new(func([]string, string) string),
	24: new(func(bool) bool),
	25: new(func(bool) float64),
	26: new(func(bool) int),
	27: new(func(bool) string),
	28: new(func(float64) bool),
	29: new(func(float64) float64),
	30: new(func(float64) int),
	31: new(func(float64) string),
	32: new(func(int) bool),
	33: new(func(int) float64),
	34: new(func(int) int),
	35: new(func(int) string),
	36: new(func(int, int) int),
	37: new(func(int, int) string),
	38: new(func(int64) time.Time),
	39: new(func(string) []string),
	40: new(func(string) bool),
	41: new(func(string) float64),
	42: new(func(string) int),
	43: new(func(string) string),
	44: new(func(string, uint8) int),
	45: new(func(string, int) int),
	46: new(func(string, int32) int),
	47: new(func(string, string) bool),
	48: new(func(string, string) string),
	49: new(func(interface{}) bool),
	50: new(func(interface{}) float64),
	51: new(func(interface{}) int),
	52: new(func(interface{}) string),
	53: new(func(interface{}) interface{}),
	54: new(func(interface{}) []interface{}),
	55: new(func(interface{}) map[string]interface{}),
	56: new(func([]interface{}) interface{}),
	57: new(func([]interface{}) []interface{}),
	58: new(func([]interface{}) map[string]interface{}),
	59: new(func(interface{}, interface{}) bool),
	60: new(func(interface{}, interface{}) string),
	61: new(func(interface{}, interface{}) interface{}),
	62: new(func(interface{}, interface{}) []interface{}),
}
View Source
var MemoryBudget int = 1e6

Functions

func Run

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

Types

type Function added in v1.11.0

type Function = func(params ...interface{}) (interface{}, error)

type Opcode added in v1.10.0

type Opcode byte
const (
	OpInvalid Opcode = iota
	OpPush
	OpPushInt
	OpPop
	OpLoadConst
	OpLoadField
	OpLoadFast
	OpLoadMethod
	OpLoadFunc
	OpLoadEnv
	OpFetch
	OpFetchField
	OpMethod
	OpTrue
	OpFalse
	OpNil
	OpNegate
	OpNot
	OpEqual
	OpEqualInt
	OpEqualString
	OpJump
	OpJumpIfTrue
	OpJumpIfFalse
	OpJumpIfNil
	OpJumpIfNotNil
	OpJumpIfEnd
	OpJumpBackward
	OpIn
	OpLess
	OpMore
	OpLessOrEqual
	OpMoreOrEqual
	OpAdd
	OpSubtract
	OpMultiply
	OpDivide
	OpModulo
	OpExponent
	OpRange
	OpMatches
	OpMatchesConst
	OpContains
	OpStartsWith
	OpEndsWith
	OpSlice
	OpCall
	OpCall0
	OpCall1
	OpCall2
	OpCall3
	OpCallN
	OpCallFast
	OpCallTyped
	OpBuiltin
	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 {
	Node      ast.Node
	Source    *file.Source
	Locations []file.Location
	Constants []interface{}
	Bytecode  []Opcode
	Arguments []int
	Functions []Function
}

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 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{}) (_ 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