vm

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncTypes = []any{
	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() []any),
	7:  new(func() bool),
	8:  new(func() uint8),
	9:  new(func() float64),
	10: new(func() int),
	11: new(func() int64),
	12: new(func() any),
	13: new(func() map[string]any),
	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([]any, 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(any) bool),
	50: new(func(any) float64),
	51: new(func(any) int),
	52: new(func(any) string),
	53: new(func(any) any),
	54: new(func(any) []any),
	55: new(func(any) map[string]any),
	56: new(func([]any) any),
	57: new(func([]any) []any),
	58: new(func([]any) map[string]any),
	59: new(func(any, any) bool),
	60: new(func(any, any) string),
	61: new(func(any, any) any),
	62: new(func(any, any) []any),
}
View Source
var MemoryBudget uint = 1e6

Functions

func Run

func Run(program *Program, env any) (any, error)

Types

type Function added in v1.11.0

type Function = func(params ...any) (any, error)

type Opcode added in v1.10.0

type Opcode byte
const (
	OpInvalid Opcode = iota
	OpPush
	OpInt
	OpPop
	OpStore
	OpLoadVar
	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
	OpCallBuiltin1
	OpArray
	OpMap
	OpLen
	OpCast
	OpDeref
	OpIncrementIndex
	OpDecrementIndex
	OpIncrementCount
	OpGetIndex
	OpSetIndex
	OpGetCount
	OpGetLen
	OpGetGroupBy
	OpGetAcc
	OpPointer
	OpThrow
	OpGroupBy
	OpSetAcc
	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
	Variables []any
	Constants []any
	Bytecode  []Opcode
	Arguments []int
	Functions []Function
	DebugInfo map[string]string
}

func (*Program) Disassemble

func (program *Program) Disassemble() string

func (*Program) Opcodes added in v1.14.0

func (program *Program) Opcodes(w io.Writer)

type Scope

type Scope struct {
	Array   reflect.Value
	Index   int
	Len     int
	Count   int
	GroupBy map[any][]any
	Acc     any
}

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 any) (_ any, err error)

func (*VM) Scope

func (vm *VM) Scope() *Scope

func (*VM) Stack

func (vm *VM) Stack() []any

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