{"modulePath":"github.com/expr-lang/expr","version":"v1.18.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package vm\n\n## Variables\n\n```go\nvar FuncTypes = []any{\n\t1:  new(func() time.Duration),\n\t2:  new(func() time.Month),\n\t3:  new(func() time.Time),\n\t4:  new(func() time.Weekday),\n\t5:  new(func() []interface{}),\n\t6:  new(func() []uint8),\n\t7:  new(func() interface{}),\n\t8:  new(func() bool),\n\t9:  new(func() uint8),\n\t10: new(func() float32),\n\t11: new(func() float64),\n\t12: new(func() int),\n\t13: new(func() int16),\n\t14: new(func() int32),\n\t15: new(func() int64),\n\t16: new(func() int8),\n\t17: new(func() map[string]interface{}),\n\t18: new(func() int32),\n\t19: new(func() string),\n\t20: new(func() uint),\n\t21: new(func() uint16),\n\t22: new(func() uint32),\n\t23: new(func() uint64),\n\t24: new(func() uint8),\n\t25: new(func(time.Duration) time.Duration),\n\t26: new(func(time.Duration) time.Time),\n\t27: new(func(time.Time) time.Duration),\n\t28: new(func(time.Time) bool),\n\t29: new(func([]interface{}) []interface{}),\n\t30: new(func([]interface{}) interface{}),\n\t31: new(func([]interface{}) map[string]interface{}),\n\t32: new(func([]interface{}, string) string),\n\t33: new(func([]uint8) string),\n\t34: new(func([]string, string) string),\n\t35: new(func(interface{}) []interface{}),\n\t36: new(func(interface{}) interface{}),\n\t37: new(func(interface{}) bool),\n\t38: new(func(interface{}) float64),\n\t39: new(func(interface{}) int),\n\t40: new(func(interface{}) map[string]interface{}),\n\t41: new(func(interface{}) string),\n\t42: new(func(interface{}, interface{}) []interface{}),\n\t43: new(func(interface{}, interface{}) interface{}),\n\t44: new(func(interface{}, interface{}) bool),\n\t45: new(func(interface{}, interface{}) string),\n\t46: new(func(bool) bool),\n\t47: new(func(bool) float64),\n\t48: new(func(bool) int),\n\t49: new(func(bool) string),\n\t50: new(func(bool, bool) bool),\n\t51: new(func(float32) float64),\n\t52: new(func(float64) bool),\n\t53: new(func(float64) float32),\n\t54: new(func(float64) float64),\n\t55: new(func(float64) int),\n\t56: new(func(float64) string),\n\t57: new(func(float64, float64) bool),\n\t58: new(func(int) bool),\n\t59: new(func(int) float64),\n\t60: new(func(int) int),\n\t61: new(func(int) string),\n\t62: new(func(int, int) bool),\n\t63: new(func(int, int) int),\n\t64: new(func(int, int) string),\n\t65: new(func(int16) int32),\n\t66: new(func(int32) float64),\n\t67: new(func(int32) int),\n\t68: new(func(int32) int64),\n\t69: new(func(int64) time.Time),\n\t70: new(func(int8) int),\n\t71: new(func(int8) int16),\n\t72: new(func(string) []uint8),\n\t73: new(func(string) []string),\n\t74: new(func(string) bool),\n\t75: new(func(string) float64),\n\t76: new(func(string) int),\n\t77: new(func(string) string),\n\t78: new(func(string, uint8) int),\n\t79: new(func(string, int) int),\n\t80: new(func(string, int32) int),\n\t81: new(func(string, string) bool),\n\t82: new(func(string, string) string),\n\t83: new(func(uint) float64),\n\t84: new(func(uint) int),\n\t85: new(func(uint) uint),\n\t86: new(func(uint16) uint),\n\t87: new(func(uint32) uint64),\n\t88: new(func(uint64) float64),\n\t89: new(func(uint64) int64),\n\t90: new(func(uint8) uint8),\n}\n```\n\n## Functions\n\n```go\nfunc DecodeBuiltinSafe(arg int) (id, argc int)\n```\nDecodeBuiltinSafe unpacks the argument of OpCallBuiltinSafe.\n\n```go\nfunc EncodeBuiltinSafe(id, argc int) (int, bool)\n```\nEncodeBuiltinSafe packs a builtin index and its number of arguments into the argument of OpCallBuiltinSafe. It reports false if they do not fit.\n\n```go\nfunc Run(program *Program, env any) (any, error)\n```\n\n## Types\n\n```go\ntype Function = func(params ...any) (any, error)\n```\n\n```go\ntype Opcode byte\n```\n\n```go\nconst (\n\tOpInvalid Opcode = iota\n\tOpPush\n\tOpInt\n\tOpPop\n\tOpStore\n\tOpLoadVar\n\tOpLoadConst\n\tOpLoadField\n\tOpLoadFast\n\tOpLoadMethod\n\tOpLoadFunc\n\tOpLoadEnv\n\tOpFetch\n\tOpFetchField\n\tOpMethod\n\tOpTrue\n\tOpFalse\n\tOpNil\n\tOpNegate\n\tOpNot\n\tOpEqual\n\tOpEqualInt\n\tOpEqualString\n\tOpJump\n\tOpJumpIfTrue\n\tOpJumpIfFalse\n\tOpJumpIfNil\n\tOpJumpIfNotNil\n\tOpJumpIfEnd\n\tOpJumpBackward\n\tOpIn\n\tOpLess\n\tOpMore\n\tOpLessOrEqual\n\tOpMoreOrEqual\n\tOpAdd\n\tOpSubtract\n\tOpMultiply\n\tOpDivide\n\tOpModulo\n\tOpExponent\n\tOpRange\n\tOpMatches\n\tOpMatchesConst\n\tOpContains\n\tOpStartsWith\n\tOpEndsWith\n\tOpSlice\n\tOpCall\n\tOpCall0\n\tOpCall1\n\tOpCall2\n\tOpCall3\n\tOpCallN\n\tOpCallFast\n\tOpCallSafe\n\tOpCallTyped\n\tOpCallBuiltin1\n\tOpArray\n\tOpMap\n\tOpLen\n\tOpCast\n\tOpDeref\n\tOpIncrementIndex\n\tOpDecrementIndex\n\tOpIncrementCount\n\tOpGetIndex\n\tOpGetCount\n\tOpGetLen\n\tOpGetAcc\n\tOpSetAcc\n\tOpSetIndex\n\tOpPointer\n\tOpThrow\n\tOpCreate\n\tOpGroupBy\n\tOpSortBy\n\tOpSort\n\tOpProfileStart\n\tOpProfileEnd\n\tOpBegin\n\tOpAnd\n\tOpOr\n\tOpCallBuiltinSafe\n\tOpEnd // This opcode must be at the end of this list.\n)\n```\n\n```go\ntype Program struct {\n\tBytecode  []Opcode\n\tArguments []int\n\tConstants []any\n\t// contains filtered or unexported fields\n}\n```\nProgram represents a compiled expression.\n\n```go\nfunc NewProgram(\n\tsource file.Source,\n\tnode ast.Node,\n\tlocations []file.Location,\n\tvariables int,\n\tconstants []any,\n\tbytecode []Opcode,\n\targuments []int,\n\tfunctions []Function,\n\tdebugInfo map[string]string,\n\tspan *Span,\n) *Program\n```\nNewProgram returns a new Program. It's used by the compiler.\n\n```go\nfunc (program *Program) Disassemble() string\n```\nDisassemble returns opcodes as a string.\n\n```go\nfunc (program *Program) DisassembleWriter(w io.Writer)\n```\nDisassembleWriter takes a writer and writes opcodes to it.\n\n```go\nfunc (program *Program) Locations() []file.Location\n```\nLocations returns a slice of bytecode's locations.\n\n```go\nfunc (program *Program) Node() ast.Node\n```\nNode returns origin ast.Node.\n\n```go\nfunc (program *Program) Source() file.Source\n```\nSource returns origin file.Source.\n\n```go\ntype SafeFunction = func(budget uint, params ...any) (any, uint, error)\n```\nSafeFunction is a function that reports the memory it allocates. It receives the remaining memory budget, so it can check the size of an allocation before making it.\n\n```go\ntype Scope struct {\n\tArray reflect.Value\n\tIndex int\n\tLen   int\n\tCount int\n\tAcc   any\n\t// Fast paths\n\tInts    []int\n\tFloats  []float64\n\tStrings []string\n\tAnys    []any\n}\n```\n\n```go\nfunc (s *Scope) Item() any\n```\nItem returns the current element from the scope using fast paths when available.\n\n```go\ntype Span struct {\n\tName       string  `json:\"name\"`\n\tExpression string  `json:\"expression\"`\n\tDuration   int64   `json:\"duration\"`\n\tChildren   []*Span `json:\"children\"`\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc GetSpan(program *Program) *Span\n```\n\n```go\ntype VM struct {\n\tStack        []any\n\tScopes       []*Scope\n\tVariables    []any\n\tMemoryBudget uint\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc Debug() *VM\n```\n\n```go\nfunc (vm *VM) Position() chan int\n```\n\n```go\nfunc (vm *VM) Run(program *Program, env any) (_ any, err error)\n```\n\n```go\nfunc (vm *VM) Step()\n```\n\n","path":"github.com/expr-lang/expr/vm","name":"vm","synopsis":"","isRedistributable":true}
