runtime

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImportTypeScript = "script"
	ImportTypeText   = "text"
	ImportTypeBytes  = "bytes"
	ImportTypeCsv    = "csv"
	ImportTypeJson   = "json"
)

Variables

View Source
var (
	TypeUndefined = NewType(builtinTypeUndefined, "Undefined")
	TypeNil       = NewType(builtinTypeNil, "Nil")
	TypeInt       = NewType(builtinTypeInt, "Int")
	TypeBigNum    = NewType(builtinTypeBigNum, "BigNum")
	TypeFloat     = NewType(builtinTypeFloat, "Float")
	TypeBool      = NewType(builtinTypeBool, "Bool")
	TypeStr       = NewType(builtinTypeStr, "Str")
	TypeBytes     = NewType(builtinTypeBytes, "Bytes")
	TypeFunc      = NewType(builtinTypeFunc, "Func")
	TypeArray     = NewType(builtinTypeArray, "Array")
	TypeObject    = NewType(builtinTypeObject, "Object")
	TypeMap       = NewTypeWithCreator(builtinTypeObject, "Map", NewMapWithPairs)
	TypeType      = NewType(builtinTypeType, "Type")
	TypeGoValue   = NewType(builtinTypeGoValue, "GoValue")
	TypeGoType    = NewType(builtinTypeGoType, "GoType")
	// Any Types
	TypeCallable = NewType(builtinTypeCallable, "AnyCallable")
	TypeAny      = NewType(builtinTypeAny, "Any")
)
View Source
var (
	CantRunInReadonlyMode = errors.New("Cannot run in readonly mode")
)
View Source
var MakeMember = makeMember
View Source
var ToGoValue = toGoValue

Functions

func Args

func Args(v ...Value) func() []Value

func CanBeNil

func CanBeNil(v reflect.Value) bool

func EnsureFuncParams

func EnsureFuncParams(c *Context, funcName string, args []Value, rules ...ArgRule)

func GetImportPaths

func GetImportPaths() []string

func IsUndefined

func IsUndefined(v Value) bool

func MakeGoValueByArg

func MakeGoValueByArg(c *Context, val Value, typ reflect.Type) reflect.Value

func NextTypeId

func NextTypeId() int

func Nullish

func Nullish(v Value) bool

Types

type ArgRule

type ArgRule interface {
	// contains filtered or unexported methods
}

func ArgRuleOneOf

func ArgRuleOneOf(
	argName string,
	expectedTypes []ValueType,
	storeTos []interface{},
	selected *int,
	defaultStore interface{},
	defaultValue Value,
) ArgRule

func ArgRuleOptional

func ArgRuleOptional(name string, expectedType ValueType, storeTo interface{}, defaultValue Value) ArgRule

func ArgRuleRequired

func ArgRuleRequired(name string, expectedType ValueType, storeTo interface{}) ArgRule

type ArraySort

type ArraySort struct {
	Array   ValueArray
	LessFn  ValueCallable
	Context *Context
}

func (*ArraySort) Len

func (s *ArraySort) Len() int

func (*ArraySort) Less

func (s *ArraySort) Less(i, j int) bool

func (*ArraySort) Swap

func (s *ArraySort) Swap(i, j int)

type CanHash added in v1.0.13

type CanHash interface {
	Hash() int64
}

type CanLen

type CanLen interface {
	Len() int
}

type CanSetIndex

type CanSetIndex interface {
	SetIndex(int, Value, *Context)
}

type CanSetMember

type CanSetMember interface {
	SetMember(string, Value, *Context)
}

type ClassBuilder

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

func NewClassBuilder

func NewClassBuilder(name string, bases ...ValueType) *ClassBuilder

func (*ClassBuilder) Build

func (h *ClassBuilder) Build() ValueType

func (*ClassBuilder) Constructor

func (h *ClassBuilder) Constructor(f func(*Context, ValueObject, []Value)) *ClassBuilder

func (*ClassBuilder) Method

func (h *ClassBuilder) Method(name string, f func(*Context, ValueObject, []Value) Value, args ...string) *ClassBuilder

func (*ClassBuilder) Methods added in v1.0.16

func (h *ClassBuilder) Methods(names []string, f func(*Context, ValueObject, []Value) Value, args ...string) *ClassBuilder

func (*ClassBuilder) StaticMethod added in v1.0.4

func (h *ClassBuilder) StaticMethod(name string, f func(*Context, Value, []Value) Value, args ...string) *ClassBuilder

type CompareResult

type CompareResult int
const (
	CompareResultNotEqual CompareResult = 0
	CompareResultEqual    CompareResult = 1
	CompareResultLess     CompareResult = 2
	CompareResultGreater  CompareResult = 4
)

type Context

type Context struct {
	IsDebug         bool
	Path            string
	ImportPaths     []string
	Args            []string
	RetVal          Value
	Breaking        bool
	BreakingLabel   string
	Stdout          io.Writer
	Stderr          io.Writer
	Stdin           io.Reader
	Continuing      bool
	ContinuingLabel string
	Returned        bool
	ExportValue     ValueObject
	ImportFunc      func(*Context, string, string, string, bool) (Value, int64, bool)
	CanEval         bool
	// contains filtered or unexported fields
}

func NewContext

func NewContext(isMain bool, isDebug, canEval bool) *Context

func (*Context) AddBlockDefer

func (c *Context) AddBlockDefer(callee Value, args []Value, optional bool)

func (*Context) AddDefer

func (c *Context) AddDefer(callee Value, args []Value, optional bool)

func (*Context) AddModule

func (c *Context) AddModule(name string, val Value, modTime int64)

func (*Context) AssertArgNum

func (c *Context) AssertArgNum(num, min, max int, funcName string)

func (*Context) AutoImport

func (c *Context) AutoImport()

func (*Context) Clone

func (c *Context) Clone() *Context

func (*Context) CloneFrames

func (c *Context) CloneFrames() (cur, funcRoot, root *contextFrame)

func (*Context) DebugLog

func (c *Context) DebugLog(msg string, args ...interface{})

func (*Context) EnsureNotReadonly added in v1.0.12

func (c *Context) EnsureNotReadonly()

func (*Context) Eval

func (c *Context) Eval(code string, force bool) Value

func (*Context) EvalConst added in v1.0.12

func (c *Context) EvalConst(n IEval)

func (*Context) FindValue

func (c *Context) FindValue(name string) (Value, bool)

func (*Context) ForceSetLocalValue

func (c *Context) ForceSetLocalValue(name string, value Value)

func (*Context) GetCallable added in v1.0.8

func (c *Context) GetCallable(value interface{}) (ValueCallable, bool)

func (*Context) GetModule added in v1.0.4

func (c *Context) GetModule(name string) (Value, int64)

func (*Context) GetPosition added in v1.0.4

func (c *Context) GetPosition() (filename string, lineNum int)

func (*Context) ImportModule

func (c *Context) ImportModule(modPath string, reloadIfNewer bool, importType string) Value

func (*Context) Invoke

func (c *Context) Invoke(calleeVal Value, this Value, getArgs func() []Value) bool

func (*Context) InvokeMethod

func (c *Context) InvokeMethod(this Value, method string, getArgs func() []Value) Value

func (*Context) IsCallable

func (c *Context) IsCallable(value Value) bool

func (*Context) IsInFunc

func (c *Context) IsInFunc() bool

func (*Context) IsModuleTop

func (c *Context) IsModuleTop() bool

func (*Context) ModifyValue

func (c *Context) ModifyValue(name string, value Value)

func (*Context) MustArray

func (c *Context) MustArray(v Value, name ...string) ValueArray

func (*Context) MustBool

func (c *Context) MustBool(v Value, name ...string) bool

func (*Context) MustCallable

func (c *Context) MustCallable(v Value, name ...string) ValueCallable

func (*Context) MustFloat

func (c *Context) MustFloat(v Value, name ...string) float64

func (*Context) MustInt

func (c *Context) MustInt(v Value, name ...string) int64

func (*Context) MustObject

func (c *Context) MustObject(v Value, name ...string) ValueObject

func (*Context) MustStr

func (c *Context) MustStr(v Value, name ...string) string

func (*Context) PopStack

func (c *Context) PopStack()

func (*Context) PrintStack

func (c *Context) PrintStack()

func (*Context) PushFuncStack

func (c *Context) PushFuncStack(funcName string)

func (*Context) PushStack

func (c *Context) PushStack()

func (*Context) RaiseRuntimeError added in v1.0.4

func (c *Context) RaiseRuntimeError(msg string, args ...interface{})

func (*Context) Recover

func (c *Context) Recover()

func (*Context) Reset

func (c *Context) Reset(resetVars ...bool)

func (*Context) ReturnTrue

func (c *Context) ReturnTrue() bool

Helpful functions

func (*Context) RunDefers

func (c *Context) RunDefers()

func (*Context) SetLocalValue

func (c *Context) SetLocalValue(name string, value Value)

func (*Context) SetPosition

func (c *Context) SetPosition(filename string, lineNum int)

func (*Context) StartThread

func (c *Context) StartThread(callee Value, this Value, args []Value) func() Value

func (*Context) ValuesEqual

func (c *Context) ValuesEqual(v1, v2 Value) bool

func (*Context) ValuesGreater

func (c *Context) ValuesGreater(v1, v2 Value) bool

func (*Context) ValuesGreaterEqual

func (c *Context) ValuesGreaterEqual(v1, v2 Value) bool

func (*Context) ValuesLess

func (c *Context) ValuesLess(v1, v2 Value) bool

func (*Context) ValuesLessEqual

func (c *Context) ValuesLessEqual(v1, v2 Value) bool

func (*Context) ValuesNotEqual

func (c *Context) ValuesNotEqual(v1, v2 Value) bool

type Exception

type Exception interface {
	GetStack() []Stack
	GetMessage() string
	MessageWithStack() string
	Error() string
}

type GoFunc

type GoFunc struct {
	GoValue
	// contains filtered or unexported fields
}

func (GoFunc) GetArgNames

func (v GoFunc) GetArgNames(*Context) []string

func (GoFunc) GetName

func (v GoFunc) GetName() string

func (GoFunc) GetRefs

func (v GoFunc) GetRefs() []string

func (GoFunc) Invoke

func (v GoFunc) Invoke(c *Context, this Value, args []Value)

type GoType

type GoType = *goType

func NewGoType

func NewGoType(typ reflect.Type) GoType

func (GoType) CompareTo

func (t GoType) CompareTo(other Value, c *Context) CompareResult

func (GoType) GetArgNames

func (t GoType) GetArgNames(*Context) []string

func (GoType) GetIndex

func (GoType) GetIndex(int, *Context) Value

func (GoType) GetMember

func (t GoType) GetMember(name string, c *Context) Value

func (GoType) GetName

func (t GoType) GetName() string

func (GoType) GetRefs

func (t GoType) GetRefs() []string

func (GoType) GoType

func (t GoType) GoType() reflect.Type

func (GoType) Invoke

func (t GoType) Invoke(c *Context, this Value, args []Value)

func (GoType) IsTrue

func (GoType) IsTrue() bool

func (GoType) ToGoValue

func (t GoType) ToGoValue() interface{}

func (GoType) ToString

func (t GoType) ToString(*Context) string

func (GoType) Type

func (GoType) Type() ValueType

type GoValue

type GoValue struct {
	*ValueBase
	// contains filtered or unexported fields
}

func (GoValue) CompareTo

func (v GoValue) CompareTo(other Value, c *Context) CompareResult

func (GoValue) GetIndex

func (v GoValue) GetIndex(index int, c *Context) Value

func (GoValue) GetMember

func (v GoValue) GetMember(key string, c *Context) Value

func (GoValue) GoType

func (v GoValue) GoType() reflect.Type

func (GoValue) IsTrue

func (v GoValue) IsTrue() bool

func (GoValue) Len

func (v GoValue) Len() int

func (GoValue) ReflectedValue

func (v GoValue) ReflectedValue() reflect.Value

func (GoValue) SetIndex

func (v GoValue) SetIndex(index int, val Value, c *Context)

func (GoValue) SetMember

func (v GoValue) SetMember(key string, val Value, c *Context)

func (GoValue) ToGoValue

func (v GoValue) ToGoValue() interface{}

func (GoValue) ToString

func (v GoValue) ToString(*Context) string

func (GoValue) Type

func (v GoValue) Type() ValueType

type IEval

type IEval interface {
	Eval(*Context)
}

type ModuleInfo

type ModuleInfo struct {
	Value      Value
	ModifyTime int64
}

type RuntimeError

type RuntimeError struct {
	Stack   []Stack
	Message string
}

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

func (*RuntimeError) GetMessage

func (e *RuntimeError) GetMessage() string

func (*RuntimeError) GetStack

func (e *RuntimeError) GetStack() []Stack

func (*RuntimeError) MessageWithStack

func (e *RuntimeError) MessageWithStack() string

type Stack

type Stack struct {
	FileName string
	Line     int
	Function string
}

type Value

type Value interface {
	GetOwner() Value
	SetOwner(Value)
	Type() ValueType
	CompareTo(Value, *Context) CompareResult
	ToString(*Context) string
	ToGoValue() interface{}
	GoType() reflect.Type
	IsTrue() bool
	GetIndex(int, *Context) Value
	GetMember(string, *Context) Value
}

func ExceptionToValue

func ExceptionToValue(e Exception, c *Context) Value

func FromGoValue

func FromGoValue(v reflect.Value, c *Context) Value

func GetValueByPath added in v1.0.4

func GetValueByPath(c *Context, v Value, path string) Value

func NewGoValue

func NewGoValue(v interface{}) Value

func NewMapWithPairs added in v1.0.13

func NewMapWithPairs(c *Context, kvs []Value) Value

func NewReflectedGoValue

func NewReflectedGoValue(v reflect.Value) Value

func NoArgs

func NoArgs() []Value

func Unbound

func Unbound(v Value) Value

type ValueArray

type ValueArray struct {
	*ValueBase
	Values *[]Value
}

func NewArray

func NewArray(n ...int) ValueArray

func NewArrayByValues

func NewArrayByValues(values ...Value) ValueArray

func (ValueArray) CompareTo

func (v ValueArray) CompareTo(other Value, c *Context) CompareResult

func (ValueArray) GetIndex

func (v ValueArray) GetIndex(index int, c *Context) Value

func (ValueArray) GetMember

func (v ValueArray) GetMember(name string, c *Context) Value

func (ValueArray) GoType

func (ValueArray) GoType() reflect.Type

func (ValueArray) IsTrue

func (v ValueArray) IsTrue() bool

func (ValueArray) Len

func (v ValueArray) Len() int

func (ValueArray) PushBack

func (v ValueArray) PushBack(el Value)

func (ValueArray) SetIndex

func (v ValueArray) SetIndex(index int, value Value, c *Context)

func (ValueArray) ToGoValue

func (v ValueArray) ToGoValue() interface{}

func (ValueArray) ToString

func (v ValueArray) ToString(c *Context) string

func (ValueArray) Type

func (v ValueArray) Type() ValueType

type ValueBase

type ValueBase struct {
	Owner Value
}

func (*ValueBase) GetOwner

func (v *ValueBase) GetOwner() Value

func (*ValueBase) SetOwner

func (v *ValueBase) SetOwner(owner Value)

type ValueBigNum

type ValueBigNum struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewBigNum

func NewBigNum(v *big.Float) ValueBigNum

func (ValueBigNum) CompareTo

func (v ValueBigNum) CompareTo(other Value, c *Context) CompareResult

func (ValueBigNum) GetIndex

func (ValueBigNum) GetIndex(int, *Context) Value

func (ValueBigNum) GetMember

func (v ValueBigNum) GetMember(name string, c *Context) Value

func (ValueBigNum) GoType

func (v ValueBigNum) GoType() reflect.Type

func (ValueBigNum) IsTrue

func (v ValueBigNum) IsTrue() bool

func (ValueBigNum) ToGoValue

func (v ValueBigNum) ToGoValue() interface{}

func (ValueBigNum) ToString

func (v ValueBigNum) ToString(*Context) string

func (ValueBigNum) Type

func (ValueBigNum) Type() ValueType

func (ValueBigNum) Value

func (v ValueBigNum) Value() *big.Float

type ValueBool

type ValueBool struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewBool

func NewBool(v bool) ValueBool

func (ValueBool) CompareTo

func (v ValueBool) CompareTo(other Value, c *Context) CompareResult

func (ValueBool) GetIndex

func (ValueBool) GetIndex(int, *Context) Value

func (ValueBool) GetMember

func (v ValueBool) GetMember(name string, c *Context) Value

func (ValueBool) GoType

func (v ValueBool) GoType() reflect.Type

func (ValueBool) Hash added in v1.0.13

func (v ValueBool) Hash() int64

func (ValueBool) IsTrue

func (v ValueBool) IsTrue() bool

func (ValueBool) ToGoValue

func (v ValueBool) ToGoValue() interface{}

func (ValueBool) ToString

func (v ValueBool) ToString(*Context) string

func (ValueBool) Type

func (ValueBool) Type() ValueType

func (ValueBool) Value

func (v ValueBool) Value() bool

type ValueBoundMethod

type ValueBoundMethod struct {
	*ValueBase
	Value ValueCallable
}

func NewBoundMethod

func NewBoundMethod(owner Value, value ValueCallable) ValueBoundMethod

func (ValueBoundMethod) CompareTo

func (v ValueBoundMethod) CompareTo(other Value, c *Context) CompareResult

func (ValueBoundMethod) GetArgNames

func (v ValueBoundMethod) GetArgNames(c *Context) []string

func (ValueBoundMethod) GetIndex

func (v ValueBoundMethod) GetIndex(index int, c *Context) Value

func (ValueBoundMethod) GetMember

func (v ValueBoundMethod) GetMember(name string, c *Context) Value

func (ValueBoundMethod) GetName

func (v ValueBoundMethod) GetName() string

func (ValueBoundMethod) GoType

func (v ValueBoundMethod) GoType() reflect.Type

func (ValueBoundMethod) Invoke

func (v ValueBoundMethod) Invoke(c *Context, thisVal Value, args []Value)

func (ValueBoundMethod) IsTrue

func (v ValueBoundMethod) IsTrue() bool

func (ValueBoundMethod) ToGoValue

func (v ValueBoundMethod) ToGoValue() interface{}

func (ValueBoundMethod) ToString

func (v ValueBoundMethod) ToString(c *Context) string

func (ValueBoundMethod) Type

func (v ValueBoundMethod) Type() ValueType

type ValueBuiltinFunction

type ValueBuiltinFunction struct {
	ValueBase
	// contains filtered or unexported fields
}

func NewNativeFunction

func NewNativeFunction(name string, body func(*Context, Value, []Value) Value, args ...string) *ValueBuiltinFunction

func WrapGoFunction

func WrapGoFunction(f interface{}) *ValueBuiltinFunction

func (*ValueBuiltinFunction) CompareTo

func (f *ValueBuiltinFunction) CompareTo(other Value, c *Context) CompareResult

func (*ValueBuiltinFunction) GetArgNames

func (f *ValueBuiltinFunction) GetArgNames(*Context) []string

func (*ValueBuiltinFunction) GetIndex

func (f *ValueBuiltinFunction) GetIndex(int, *Context) Value

func (*ValueBuiltinFunction) GetMember

func (f *ValueBuiltinFunction) GetMember(name string, c *Context) Value

func (*ValueBuiltinFunction) GetName

func (f *ValueBuiltinFunction) GetName() string

func (*ValueBuiltinFunction) GetRefs

func (f *ValueBuiltinFunction) GetRefs() []string

func (*ValueBuiltinFunction) GoType

func (f *ValueBuiltinFunction) GoType() reflect.Type

func (*ValueBuiltinFunction) Invoke

func (f *ValueBuiltinFunction) Invoke(c *Context, thisArg Value, args []Value)

func (*ValueBuiltinFunction) IsTrue

func (f *ValueBuiltinFunction) IsTrue() bool

func (*ValueBuiltinFunction) ToGoValue

func (f *ValueBuiltinFunction) ToGoValue() interface{}

func (*ValueBuiltinFunction) ToString

func (f *ValueBuiltinFunction) ToString(*Context) string

func (*ValueBuiltinFunction) Type

func (f *ValueBuiltinFunction) Type() ValueType

type ValueBytes

type ValueBytes struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewBytes

func NewBytes(v []byte) ValueBytes

func (ValueBytes) CompareTo

func (v ValueBytes) CompareTo(other Value, c *Context) CompareResult

func (ValueBytes) GetIndex

func (v ValueBytes) GetIndex(index int, c *Context) Value

func (ValueBytes) GetMember

func (v ValueBytes) GetMember(name string, c *Context) Value

func (ValueBytes) GoType

func (v ValueBytes) GoType() reflect.Type

func (ValueBytes) IsTrue

func (v ValueBytes) IsTrue() bool

func (ValueBytes) Len

func (v ValueBytes) Len() int

func (ValueBytes) SetIndex

func (v ValueBytes) SetIndex(index int, value Value, c *Context)

func (ValueBytes) ToGoValue

func (v ValueBytes) ToGoValue() interface{}

func (ValueBytes) ToString

func (v ValueBytes) ToString(*Context) string

func (ValueBytes) Type

func (ValueBytes) Type() ValueType

func (ValueBytes) Value

func (v ValueBytes) Value() []byte

type ValueCallable

type ValueCallable interface {
	Value
	GetName() string
	GetArgNames(*Context) []string
	Invoke(*Context, Value, []Value)
}

type ValueFloat

type ValueFloat struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewFloat

func NewFloat(v float64) ValueFloat

func (ValueFloat) CompareTo

func (v ValueFloat) CompareTo(other Value, c *Context) CompareResult

func (ValueFloat) GetIndex

func (ValueFloat) GetIndex(int, *Context) Value

func (ValueFloat) GetMember

func (v ValueFloat) GetMember(name string, c *Context) Value

func (ValueFloat) GoType

func (v ValueFloat) GoType() reflect.Type

func (ValueFloat) Hash added in v1.0.13

func (v ValueFloat) Hash() int64

func (ValueFloat) IsTrue

func (v ValueFloat) IsTrue() bool

func (ValueFloat) ToGoValue

func (v ValueFloat) ToGoValue() interface{}

func (ValueFloat) ToString

func (v ValueFloat) ToString(*Context) string

func (ValueFloat) Type

func (ValueFloat) Type() ValueType

func (ValueFloat) Value

func (v ValueFloat) Value() float64

type ValueFunc

type ValueFunc struct {
	*ValueBase
	Name string
	Args []string

	ExpandLast bool
	This       Value
	Body       IEval
	BelongType ValueType
	// contains filtered or unexported fields
}

func NewFunc

func NewFunc(name string, args []string, expandLast bool, body IEval) *ValueFunc

func (*ValueFunc) CloneWithEnv

func (v *ValueFunc) CloneWithEnv(c *Context) *ValueFunc

func (*ValueFunc) CompareTo

func (v *ValueFunc) CompareTo(other Value, c *Context) CompareResult

func (*ValueFunc) GetArgNames

func (v *ValueFunc) GetArgNames(*Context) []string

func (*ValueFunc) GetIndex

func (v *ValueFunc) GetIndex(index int, c *Context) Value

func (*ValueFunc) GetMember

func (v *ValueFunc) GetMember(name string, c *Context) Value

func (*ValueFunc) GetName

func (v *ValueFunc) GetName() string

func (*ValueFunc) GoType

func (v *ValueFunc) GoType() reflect.Type

func (*ValueFunc) Invoke

func (v *ValueFunc) Invoke(c *Context, thisArg Value, args []Value)

func (*ValueFunc) IsTrue

func (v *ValueFunc) IsTrue() bool

func (*ValueFunc) ToGoValue

func (v *ValueFunc) ToGoValue() interface{}

func (*ValueFunc) ToString

func (v *ValueFunc) ToString(*Context) string

func (*ValueFunc) Type

func (v *ValueFunc) Type() ValueType

type ValueInt

type ValueInt struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewInt

func NewInt(v int64) ValueInt

func (ValueInt) AsInt

func (v ValueInt) AsInt() int

func (ValueInt) CompareTo

func (v ValueInt) CompareTo(other Value, c *Context) CompareResult

func (ValueInt) GetIndex

func (ValueInt) GetIndex(int, *Context) Value

func (ValueInt) GetMember

func (v ValueInt) GetMember(name string, c *Context) Value

func (ValueInt) GoType

func (v ValueInt) GoType() reflect.Type

func (ValueInt) Hash added in v1.0.13

func (v ValueInt) Hash() int64

func (ValueInt) IsTrue

func (v ValueInt) IsTrue() bool

func (ValueInt) ToGoValue

func (v ValueInt) ToGoValue() interface{}

func (ValueInt) ToString

func (v ValueInt) ToString(*Context) string

func (ValueInt) Type

func (ValueInt) Type() ValueType

func (ValueInt) Value

func (v ValueInt) Value() int64

type ValueMap added in v1.0.13

type ValueMap = *valueMap

func NewMap added in v1.0.13

func NewMap() ValueMap

func NewSet added in v1.0.13

func NewSet() ValueMap

func (ValueMap) CompareTo added in v1.0.13

func (m ValueMap) CompareTo(other Value, c *Context) CompareResult

func (ValueMap) Each added in v1.0.13

func (m ValueMap) Each(handle func(key, value Value) bool)

func (ValueMap) GetIndex added in v1.0.13

func (m ValueMap) GetIndex(int, *Context) Value

func (ValueMap) GetMember added in v1.0.13

func (m ValueMap) GetMember(name string, c *Context) Value

func (ValueMap) GoType added in v1.0.13

func (m ValueMap) GoType() reflect.Type

func (ValueMap) IsTrue added in v1.0.13

func (m ValueMap) IsTrue() bool

func (ValueMap) Len added in v1.0.13

func (m ValueMap) Len() int

Implements CanLen

func (ValueMap) ToGoValue added in v1.0.13

func (m ValueMap) ToGoValue() interface{}

func (ValueMap) ToString added in v1.0.13

func (m ValueMap) ToString(c *Context) string

func (ValueMap) Type added in v1.0.13

func (m ValueMap) Type() ValueType

type ValueNil

type ValueNil struct {
	*ValueBase
}

func Nil

func Nil() ValueNil

func (ValueNil) CompareTo

func (ValueNil) CompareTo(other Value, c *Context) CompareResult

func (ValueNil) GetIndex

func (ValueNil) GetIndex(int, *Context) Value

func (ValueNil) GetMember

func (v ValueNil) GetMember(name string, c *Context) Value

func (ValueNil) GoType

func (v ValueNil) GoType() reflect.Type

func (ValueNil) IsTrue

func (ValueNil) IsTrue() bool

func (ValueNil) ToGoValue

func (ValueNil) ToGoValue() interface{}

func (ValueNil) ToString

func (ValueNil) ToString(*Context) string

func (ValueNil) Type

func (ValueNil) Type() ValueType

type ValueObject

type ValueObject struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewObject

func NewObject(objType ...ValueType) ValueObject

func NewObjectAndInit

func NewObjectAndInit(objType ValueType, c *Context, initArgs ...Value) ValueObject

func (ValueObject) CompareTo

func (v ValueObject) CompareTo(other Value, c *Context) CompareResult

func (ValueObject) Each

func (v ValueObject) Each(f func(string, Value) bool)

func (ValueObject) GetArgNames

func (ValueObject) GetArgNames(*Context) []string

func (ValueObject) GetIndex

func (v ValueObject) GetIndex(index int, c *Context) Value

func (ValueObject) GetMember

func (v ValueObject) GetMember(name string, c *Context) Value

func (ValueObject) GetName

func (v ValueObject) GetName() string

func (ValueObject) GetRefs

func (ValueObject) GetRefs() []string

func (ValueObject) GoType

func (v ValueObject) GoType() reflect.Type

func (*ValueObject) Init

func (v *ValueObject) Init(c *Context, args []Value)

func (ValueObject) Invoke

func (v ValueObject) Invoke(c *Context, this Value, args []Value)

func (ValueObject) IsTrue

func (v ValueObject) IsTrue() (isTrue bool)

func (ValueObject) Iterate

func (v ValueObject) Iterate(f func(key string, value Value))

func (ValueObject) Len

func (v ValueObject) Len() int

func (ValueObject) SetMember

func (v ValueObject) SetMember(name string, value Value, c *Context)

func (*ValueObject) Super

func (v *ValueObject) Super(fromType ValueType) ValueObject

func (ValueObject) ToGoValue

func (v ValueObject) ToGoValue() interface{}

func (ValueObject) ToString

func (v ValueObject) ToString(c *Context) string

func (ValueObject) Type

func (v ValueObject) Type() ValueType

type ValueSet added in v1.0.13

type ValueSet = *valueSet

func (ValueSet) CompareTo added in v1.0.13

func (m ValueSet) CompareTo(other Value, c *Context) CompareResult

func (ValueSet) Each added in v1.0.13

func (m ValueSet) Each(handle func(key, value Value) bool)

func (ValueSet) GetIndex added in v1.0.13

func (m ValueSet) GetIndex(int, *Context) Value

func (ValueSet) GetMember added in v1.0.13

func (m ValueSet) GetMember(name string, c *Context) Value

func (ValueSet) GoType added in v1.0.13

func (m ValueSet) GoType() reflect.Type

func (ValueSet) IsTrue added in v1.0.13

func (m ValueSet) IsTrue() bool

func (ValueSet) Len added in v1.0.13

func (m ValueSet) Len() int

Implements CanLen

func (ValueSet) ToGoValue added in v1.0.13

func (m ValueSet) ToGoValue() interface{}

func (ValueSet) ToString added in v1.0.13

func (m ValueSet) ToString(c *Context) string

func (ValueSet) Type added in v1.0.13

func (m ValueSet) Type() ValueType

type ValueStr

type ValueStr struct {
	*ValueBase
	// contains filtered or unexported fields
}

func NewStr

func NewStr(v string, args ...interface{}) ValueStr

func NewStrByRunes

func NewStrByRunes(v []rune) ValueStr

func (ValueStr) CompareTo

func (v ValueStr) CompareTo(other Value, c *Context) CompareResult

func (ValueStr) GetIndex

func (v ValueStr) GetIndex(index int, c *Context) Value

func (ValueStr) GetMember

func (v ValueStr) GetMember(name string, c *Context) Value

func (ValueStr) GoType

func (v ValueStr) GoType() reflect.Type

func (ValueStr) Hash added in v1.0.13

func (v ValueStr) Hash() int64

func (ValueStr) IsTrue

func (v ValueStr) IsTrue() bool

func (ValueStr) Len

func (v ValueStr) Len() int

func (ValueStr) Runes

func (v ValueStr) Runes() []rune

func (ValueStr) ToGoValue

func (v ValueStr) ToGoValue() interface{}

func (ValueStr) ToString

func (v ValueStr) ToString(*Context) string

func (ValueStr) Type

func (ValueStr) Type() ValueType

func (ValueStr) Value

func (v ValueStr) Value() string

type ValueType

type ValueType = *valueType

func NewType

func NewType(id int, name string) ValueType

func NewTypeWithCreator added in v1.0.13

func NewTypeWithCreator(id int, name string, creator func(*Context, []Value) Value) ValueType

type ValueUndefined

type ValueUndefined struct {
	*ValueBase
}

func Undefined

func Undefined() ValueUndefined

func (ValueUndefined) CompareTo

func (ValueUndefined) CompareTo(other Value, c *Context) CompareResult

func (ValueUndefined) GetIndex

func (ValueUndefined) GetIndex(int, *Context) Value

func (ValueUndefined) GetMember

func (v ValueUndefined) GetMember(name string, c *Context) Value

func (ValueUndefined) GoType

func (ValueUndefined) GoType() reflect.Type

func (ValueUndefined) IsTrue

func (ValueUndefined) IsTrue() bool

func (ValueUndefined) ToGoValue

func (ValueUndefined) ToGoValue() interface{}

func (ValueUndefined) ToString

func (ValueUndefined) ToString(*Context) string

func (ValueUndefined) Type

func (ValueUndefined) Type() ValueType

Jump to

Keyboard shortcuts

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