Documentation
¶
Overview ¶
Package builtins provides the built-in functions for the Charlang language.
Overview ¶
This file contains all built-in functions that are available in Charlang scripts. Built-in functions are pre-defined functions that provide core language functionality and access to Go's standard library and external packages.
Function Categories ¶
Built-in functions are organized into the following categories:
**Core Functions:**
- print, printf, println - Output functions
- len, type, typeof - Inspection functions
- int, float, string, bool, char - Type conversion functions
- append, copy, delete - Collection manipulation
**String Functions:**
- str, format, sprintf - String formatting
- split, join, replace, trim - String manipulation
- regex, matches, find - Regular expressions
**Collection Functions:**
- map, filter, reduce - Functional operations
- sort, reverse, shuffle - Collection ordering
- keys, values, items - Map operations
**I/O Functions:**
- open, close, read, write - File operations
- read_file, write_file - Convenience file functions
- http_get, http_post - HTTP requests
**System Functions:**
- time, sleep, timer - Time operations
- exec, shell - Process execution
- env, args - Environment access
**Data Processing:**
- json, yaml, xml, csv - Data format handling
- base64, hex, url_encode - Encoding functions
- hash, md5, sha256 - Cryptographic functions
**External Services:**
- database, query - Database operations
- mail, ftp, s3 - External service integrations
- excel, word, pdf - Document processing
Usage ¶
Built-in functions are automatically available in Charlang scripts:
print("Hello, World!")
result := len([1, 2, 3]) // result = 3
items := split("a,b,c", ",") // items = ["a", "b", "c"]
Extending Builtins ¶
To add a new built-in function:
- Add a constant to BuiltinType
- Add an entry to BuiltinsMap
- Add the function object to BuiltinObjects array
- Implement the function logic
Package charlang provides a scripting language interpreter with Go integration. Charlang is a dynamically-typed scripting language designed for embedding in Go applications.
Overview ¶
Charlang provides:
- A complete scripting language with familiar syntax
- Seamless Go value integration via type conversion functions
- A virtual machine (VM) for executing compiled bytecode
- Extensible built-in functions and modules
- Support for closures, generators, and object-oriented patterns
Core Components ¶
The main components of Charlang are:
- Compiler: Transforms source code into bytecode (compiler.go)
- VM: Executes compiled bytecode (vm.go)
- Objects: Represents all runtime values (objects.go)
- Builtins: Provides built-in functions (builtins.go)
- Parser: Parses source code into AST (parser/)
Basic Usage ¶
Simple script execution:
script := `print("Hello, World!")`
result, err := charlang.Execute(script, nil)
With variables:
script := `x + y`
vars := map[string]interface{}{"x": 10, "y": 20}
result, err := charlang.Execute(script, vars)
Type Conversion ¶
Charlang provides bidirectional type conversion between Go and Charlang:
// Go to Charlang obj, err := charlang.ToObject(goValue) // Charlang to Go goValue := charlang.ToInterface(obj)
Object Types ¶
Charlang supports multiple object types including:
- Primitive types: Int, Uint, Float, String, Bool, Char, Bytes
- Container types: Array, Map, SyncMap
- Function types: Function, CompiledFunction, BuiltinFunction
- Special types: Undefined, Error, RuntimeError
- External types: Time, Database, WebSocket, Excel, Image, etc.
Thread Safety ¶
The VM and most object types are not thread-safe by default. Use SyncMap for concurrent map access and Mutex for synchronization.
Extending Charlang ¶
You can extend Charlang with custom functions:
customFunc := &charlang.Function{
Name: "myFunc",
Value: func(args ...charlang.Object) (charlang.Object, error) {
return charlang.Int(42), nil
},
}
Package opcodes defines the bytecode instructions for the Charlang VM.
Opcode Overview ¶
Opcodes are single-byte instructions that the VM executes sequentially. Each opcode may have zero or more operands that provide additional data.
Instruction Format ¶
Instructions are encoded as: [opcode][operand1][operand2]... Operands are either 1 byte (0-255) or 2 bytes (0-65535, big-endian).
Opcode Categories ¶
- Constants: OpConstant, OpNull, OpTrue, OpFalse
- Variables: OpGetGlobal, OpSetGlobal, OpGetLocal, OpSetLocal, OpGetFree, OpSetFree
- Calls: OpCall, OpCallName, OpGetBuiltin, OpReturn
- Operations: OpBinaryOp, OpUnary, OpEqual, OpNotEqual
- Control Flow: OpJump, OpJumpFalsy, OpAndJump, OpOrJump
- Data Structures: OpMap, OpArray, OpSliceIndex, OpGetIndex, OpSetIndex
- Closures: OpClosure, OpGetLocalPtr, OpGetFreePtr
- Iteration: OpIterInit, OpIterNext, OpIterKey, OpIterValue
- Modules: OpLoadModule, OpStoreModule
- Exceptions: OpSetupTry, OpSetupCatch, OpSetupFinally, OpThrow, OpFinalizer
- Stack: OpPop, OpDefineLocal
Index ¶
- Constants
- Variables
- func AnysToOriginal(aryA []Object) []interface{}
- func ConvertFromObject(vA Object) interface{}
- func DownloadStringFromSSH(sshA string, filePathA string) string
- func FormatInstructions(b []byte, posOffset int) []string
- func FromStringObject(argA String) string
- func GetCfgString(fileNameA string) string
- func GetMagic(numberA int) string
- func GetSwitchFromObjects(argsA []Object, switchA string, defaultA string) string
- func IfSwitchExistsInObjects(argsA []Object, switchA string) bool
- func IsUndefInternal(o Object) bool
- func IterateInstructions(insts []byte, fn func(pos int, opcode Opcode, operands []int, offset int) bool)
- func MakeInstruction(buf []byte, op Opcode, args ...int) ([]byte, error)
- func NewChar(codeA string) (interface{}, error)
- func ObjectsToBytes(aryA []Object) []byte
- func ObjectsToI(aryA []Object) []interface{}
- func ObjectsToN(aryA []Object) []int
- func ObjectsToO(aryA []Object) []interface{}
- func ObjectsToS(aryA []Object) []string
- func OneResultCallAdapter(fn CallableFunc) func(args ...Object) Object
- func OneResultCallExAdapter(fn CallableExFunc) func(args ...Object) Object
- func QuickCompile(codeA string, compilerOptionsA ...*CompilerOptions) interface{}
- func QuickRun(codeA interface{}, globalsA map[string]interface{}, additionsA ...Object) interface{}
- func ReadOperands(numOperands []int, ins []byte, operands []int) ([]int, int)
- func RemoveCfgString(fileNameA string) string
- func RunAsFunc(codeA interface{}, argsA ...interface{}) interface{}
- func RunCharCode(codeA string, envA map[string]interface{}, paraMapA map[string]string, ...) (interface{}, error)
- func RunScriptOnHttp(codeA string, compilerOptionsA *CompilerOptions, res http.ResponseWriter, ...) (string, error)
- func SHA1(data []byte) []byte
- func SHA1PRNG(seed []byte, size int) ([]byte, error)
- func SetCfgString(fileNameA string, strA string) string
- func ToFloatQuick(o Object) float64
- func ToGoBool(o Object) (v bool, ok bool)
- func ToGoByteSlice(o Object) (v []byte, ok bool)
- func ToGoFloat64(o Object) (v float64, ok bool)
- func ToGoInt(o Object) (v int, ok bool)
- func ToGoInt64(o Object) (v int64, ok bool)
- func ToGoIntWithDefault(o Object, defaultA int) int
- func ToGoRune(o Object) (v rune, ok bool)
- func ToGoString(o Object) (v string, ok bool)
- func ToGoUint64(o Object) (v uint64, ok bool)
- func ToIntQuick(o Object) int
- func ToInterface(o Object) (ret interface{})
- type Any
- func (o *Any) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Any) Call(_ ...Object) (Object, error)
- func (o *Any) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Any) CallName(nameA string, c Call) (Object, error)
- func (*Any) CanCall() bool
- func (*Any) CanIterate() bool
- func (o *Any) Copy() Object
- func (o *Any) Equal(right Object) bool
- func (o *Any) GetMember(idxA string) Object
- func (o *Any) GetValue() Object
- func (o *Any) HasMemeber() bool
- func (o *Any) IndexGet(index Object) (Object, error)
- func (o *Any) IndexSet(index, value Object) error
- func (o *Any) IsFalsy() bool
- func (*Any) Iterate() Iterator
- func (o *Any) SetMember(idxA string, valueA Object) error
- func (o *Any) SetValue(valueA Object) error
- func (o *Any) String() string
- func (o *Any) TypeCode() int
- func (*Any) TypeName() string
- type Array
- func (o Array) BinaryOp(tok token.Token, right Object) (Object, error)
- func (Array) Call(...Object) (Object, error)
- func (o Array) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Array) CallName(nameA string, c Call) (Object, error)
- func (Array) CanCall() bool
- func (Array) CanIterate() bool
- func (o Array) Copy() Object
- func (o Array) Equal(right Object) bool
- func (o Array) GetMember(idxA string) Object
- func (o Array) GetValue() Object
- func (o Array) HasMemeber() bool
- func (o Array) IndexGet(index Object) (Object, error)
- func (o Array) IndexSet(index, value Object) error
- func (o Array) IsFalsy() bool
- func (o Array) Iterate() Iterator
- func (o Array) Len() int
- func (o Array) SetMember(idxA string, valueA Object) error
- func (o Array) String() string
- func (Array) TypeCode() int
- func (Array) TypeName() string
- type ArrayIterator
- type BigFloat
- func (o *BigFloat) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *BigFloat) Call(_ ...Object) (Object, error)
- func (o *BigFloat) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *BigFloat) CanCall() bool
- func (*BigFloat) CanIterate() bool
- func (o *BigFloat) Equal(right Object) bool
- func (o *BigFloat) GetMember(idxA string) Object
- func (o *BigFloat) GetValue() Object
- func (o *BigFloat) HasMemeber() bool
- func (o *BigFloat) IndexGet(index Object) (Object, error)
- func (o *BigFloat) IndexSet(index, value Object) error
- func (o *BigFloat) IsFalsy() bool
- func (*BigFloat) Iterate() Iterator
- func (o *BigFloat) SetMember(idxA string, valueA Object) error
- func (o *BigFloat) SetValue(valueA Object) error
- func (o *BigFloat) String() string
- func (*BigFloat) TypeCode() int
- func (*BigFloat) TypeName() string
- type BigInt
- func (o *BigInt) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *BigInt) Call(_ ...Object) (Object, error)
- func (o *BigInt) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *BigInt) CanCall() bool
- func (*BigInt) CanIterate() bool
- func (o *BigInt) Equal(right Object) bool
- func (o *BigInt) GetMember(idxA string) Object
- func (o *BigInt) GetValue() Object
- func (o *BigInt) HasMemeber() bool
- func (o *BigInt) IndexGet(index Object) (Object, error)
- func (o *BigInt) IndexSet(index, value Object) error
- func (o *BigInt) IsFalsy() bool
- func (*BigInt) Iterate() Iterator
- func (o *BigInt) SetMember(idxA string, valueA Object) error
- func (o *BigInt) SetValue(valueA Object) error
- func (o *BigInt) String() string
- func (*BigInt) TypeCode() int
- func (*BigInt) TypeName() string
- type Bool
- func (o Bool) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Bool) BoolValue() bool
- func (Bool) Call(_ ...Object) (Object, error)
- func (o Bool) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (Bool) CanCall() bool
- func (Bool) CanIterate() bool
- func (o Bool) Equal(right Object) bool
- func (o Bool) Format(s fmt.State, verb rune)
- func (o Bool) GetMember(idxA string) Object
- func (o Bool) GetValue() Object
- func (o Bool) HasMemeber() bool
- func (o Bool) IndexGet(index Object) (value Object, err error)
- func (Bool) IndexSet(index, value Object) error
- func (o Bool) IsFalsy() bool
- func (Bool) Iterate() Iterator
- func (o Bool) SetMember(idxA string, valueA Object) error
- func (o Bool) String() string
- func (Bool) TypeCode() int
- func (Bool) TypeName() string
- type BuiltinFunction
- func (*BuiltinFunction) BinaryOp(token.Token, Object) (Object, error)
- func (o *BuiltinFunction) Call(args ...Object) (Object, error)
- func (o *BuiltinFunction) CallEx(c Call) (Object, error)
- func (o *BuiltinFunction) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*BuiltinFunction) CanCall() bool
- func (o *BuiltinFunction) CanIterate() bool
- func (o *BuiltinFunction) Copy() Object
- func (o *BuiltinFunction) Equal(right Object) bool
- func (o *BuiltinFunction) GetMember(idxA string) Object
- func (o *BuiltinFunction) GetValue() Object
- func (o *BuiltinFunction) HasMemeber() bool
- func (o *BuiltinFunction) IndexGet(index Object) (Object, error)
- func (*BuiltinFunction) IndexSet(index, value Object) error
- func (o *BuiltinFunction) IsFalsy() bool
- func (o *BuiltinFunction) Iterate() Iterator
- func (o *BuiltinFunction) SetMember(idxA string, valueA Object) error
- func (o *BuiltinFunction) String() string
- func (*BuiltinFunction) TypeCode() int
- func (*BuiltinFunction) TypeName() string
- type BuiltinModule
- type BuiltinType
- type Byte
- func (o Byte) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Byte) Call(_ ...Object) (Object, error)
- func (o Byte) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Byte) CanCall() bool
- func (Byte) CanIterate() bool
- func (o Byte) Equal(right Object) bool
- func (o Byte) Format(s fmt.State, verb rune)
- func (o Byte) GetMember(idxA string) Object
- func (o Byte) GetValue() Object
- func (o Byte) HasMemeber() bool
- func (o Byte) IndexGet(index Object) (Object, error)
- func (Byte) IndexSet(index, value Object) error
- func (o Byte) IsFalsy() bool
- func (Byte) Iterate() Iterator
- func (o Byte) SetMember(idxA string, valueA Object) error
- func (o Byte) String() string
- func (Byte) TypeCode() int
- func (Byte) TypeName() string
- type Bytecode
- type Bytes
- func (o Bytes) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Bytes) Call(_ ...Object) (Object, error)
- func (o Bytes) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Bytes) CanCall() bool
- func (Bytes) CanIterate() bool
- func (o Bytes) Copy() Object
- func (o Bytes) Equal(right Object) bool
- func (o Bytes) Format(s fmt.State, verb rune)
- func (o Bytes) GetMember(idxA string) Object
- func (o Bytes) GetValue() Object
- func (o Bytes) HasMemeber() bool
- func (o Bytes) IndexGet(index Object) (Object, error)
- func (o Bytes) IndexSet(index, value Object) error
- func (o Bytes) IsFalsy() bool
- func (o Bytes) Iterate() Iterator
- func (o Bytes) Len() int
- func (o Bytes) SetMember(idxA string, valueA Object) error
- func (o Bytes) String() string
- func (Bytes) TypeCode() int
- func (Bytes) TypeName() string
- type BytesBuffer
- func (o *BytesBuffer) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*BytesBuffer) Call(_ ...Object) (Object, error)
- func (o *BytesBuffer) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*BytesBuffer) CanCall() bool
- func (*BytesBuffer) CanIterate() bool
- func (o *BytesBuffer) Copy() Object
- func (o *BytesBuffer) Equal(right Object) bool
- func (o *BytesBuffer) GetMember(idxA string) Object
- func (o *BytesBuffer) GetValue() Object
- func (o *BytesBuffer) HasMemeber() bool
- func (o *BytesBuffer) IndexGet(index Object) (value Object, err error)
- func (o *BytesBuffer) IndexSet(index, value Object) error
- func (o *BytesBuffer) IsFalsy() bool
- func (*BytesBuffer) Iterate() Iterator
- func (o *BytesBuffer) SetMember(idxA string, valueA Object) error
- func (o *BytesBuffer) String() string
- func (o *BytesBuffer) TypeCode() int
- func (o *BytesBuffer) TypeName() string
- type BytesIterator
- type Call
- type CallableExFunc
- type CallableFunc
- type Char
- func (o Char) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Char) Call(_ ...Object) (Object, error)
- func (o Char) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Char) CanCall() bool
- func (Char) CanIterate() bool
- func (o Char) Equal(right Object) bool
- func (o Char) Format(s fmt.State, verb rune)
- func (o Char) GetMember(idxA string) Object
- func (o Char) GetValue() Object
- func (o Char) HasMemeber() bool
- func (o Char) IndexGet(index Object) (Object, error)
- func (Char) IndexSet(index, value Object) error
- func (o Char) IsFalsy() bool
- func (Char) Iterate() Iterator
- func (o Char) SetMember(idxA string, valueA Object) error
- func (o Char) String() string
- func (Char) TypeCode() int
- func (Char) TypeName() string
- type CharCode
- func (o *CharCode) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *CharCode) Call(argsA ...Object) (Object, error)
- func (o *CharCode) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *CharCode) CanCall() bool
- func (*CharCode) CanIterate() bool
- func (o *CharCode) Equal(right Object) bool
- func (o *CharCode) GetMember(idxA string) Object
- func (o *CharCode) GetValue() Object
- func (o *CharCode) HasMemeber() bool
- func (o *CharCode) IndexGet(index Object) (Object, error)
- func (o *CharCode) IndexSet(index, value Object) error
- func (o *CharCode) IsFalsy() bool
- func (o *CharCode) Iterate() Iterator
- func (o *CharCode) SetMember(idxA string, valueA Object) error
- func (o *CharCode) String() string
- func (*CharCode) TypeCode() int
- func (*CharCode) TypeName() string
- type Chars
- func (o Chars) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Chars) Call(_ ...Object) (Object, error)
- func (o Chars) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Chars) CanCall() bool
- func (Chars) CanIterate() bool
- func (o Chars) Copy() Object
- func (o Chars) Equal(right Object) bool
- func (o Chars) Format(s fmt.State, verb rune)
- func (o Chars) GetMember(idxA string) Object
- func (o Chars) GetValue() Object
- func (o Chars) HasMemeber() bool
- func (o Chars) IndexGet(index Object) (Object, error)
- func (o Chars) IndexSet(index, value Object) error
- func (o Chars) IsFalsy() bool
- func (o Chars) Iterate() Iterator
- func (o Chars) Len() int
- func (o Chars) SetMember(idxA string, valueA Object) error
- func (o Chars) String() string
- func (Chars) TypeCode() int
- func (Chars) TypeName() string
- type CharsIterator
- type CompiledFunction
- func (*CompiledFunction) BinaryOp(token.Token, Object) (Object, error)
- func (*CompiledFunction) Call(...Object) (Object, error)
- func (o *CompiledFunction) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*CompiledFunction) CanCall() bool
- func (*CompiledFunction) CanIterate() bool
- func (o *CompiledFunction) Copy() Object
- func (o *CompiledFunction) Equal(right Object) bool
- func (o *CompiledFunction) Fprint(w io.Writer)
- func (o *CompiledFunction) GetMember(idxA string) Object
- func (o *CompiledFunction) GetValue() Object
- func (o *CompiledFunction) HasMemeber() bool
- func (o *CompiledFunction) IndexGet(index Object) (Object, error)
- func (*CompiledFunction) IndexSet(index, value Object) error
- func (o *CompiledFunction) IsFalsy() bool
- func (*CompiledFunction) Iterate() Iterator
- func (o *CompiledFunction) SetMember(idxA string, valueA Object) error
- func (o *CompiledFunction) SourcePos(ip int) parser.Pos
- func (o *CompiledFunction) String() string
- func (*CompiledFunction) TypeCode() int
- func (*CompiledFunction) TypeName() string
- type Compiler
- type CompilerError
- type CompilerOptions
- type Copier
- type Database
- func (o *Database) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Database) Call(_ ...Object) (Object, error)
- func (o *Database) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*Database) CanCall() bool
- func (*Database) CanIterate() bool
- func (o Database) Equal(right Object) bool
- func (o *Database) GetMember(idxA string) Object
- func (o *Database) GetValue() Object
- func (o *Database) HasMemeber() bool
- func (o *Database) IndexGet(index Object) (value Object, err error)
- func (o *Database) IndexSet(index, value Object) error
- func (o *Database) IsFalsy() bool
- func (*Database) Iterate() Iterator
- func (o *Database) SetMember(idxA string, valueA Object) error
- func (o *Database) String() string
- func (o *Database) TypeCode() int
- func (o *Database) TypeName() string
- type Delegate
- func (o *Delegate) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Delegate) Call(argsA ...Object) (Object, error)
- func (o *Delegate) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Delegate) CallName(nameA string, c Call) (Object, error)
- func (o *Delegate) CanCall() bool
- func (*Delegate) CanIterate() bool
- func (o *Delegate) Equal(right Object) bool
- func (o *Delegate) GetMember(idxA string) Object
- func (o *Delegate) GetValue() Object
- func (o *Delegate) HasMemeber() bool
- func (o *Delegate) IndexGet(index Object) (Object, error)
- func (o *Delegate) IndexSet(index, value Object) error
- func (o *Delegate) IsFalsy() bool
- func (*Delegate) Iterate() Iterator
- func (o *Delegate) SetMember(idxA string, valueA Object) error
- func (o *Delegate) SetValue(valueA Object) error
- func (o *Delegate) String() string
- func (*Delegate) TypeCode() int
- func (*Delegate) TypeName() string
- type Error
- func NewArgumentTypeError(pos, expectType, foundType string) *Error
- func NewCommonError(formatA string, argsA ...interface{}) *Error
- func NewCommonErrorWithPos(c Call, formatA string, argsA ...interface{}) *Error
- func NewError(nameA string, formatA string, argsA ...interface{}) *Error
- func NewFromError(errA error) *Error
- func NewIndexTypeError(expectType, foundType string) *Error
- func NewIndexValueTypeError(expectType, foundType string) *Error
- func NewOperandTypeError(token, leftType, rightType string) *Error
- func WrapError(errA error) *Error
- func (o *Error) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Error) Call(_ ...Object) (Object, error)
- func (o *Error) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*Error) CanCall() bool
- func (*Error) CanIterate() bool
- func (o *Error) Copy() Object
- func (o *Error) Equal(right Object) bool
- func (o *Error) Error() string
- func (o *Error) GetMember(idxA string) Object
- func (o *Error) GetValue() Object
- func (o *Error) HasMemeber() bool
- func (o *Error) IndexGet(index Object) (Object, error)
- func (o *Error) IndexSet(index, value Object) error
- func (o *Error) IsFalsy() bool
- func (*Error) Iterate() Iterator
- func (o *Error) NewError(messages ...string) *Error
- func (o *Error) SetMember(idxA string, valueA Object) error
- func (o *Error) String() string
- func (*Error) TypeCode() int
- func (*Error) TypeName() string
- func (o *Error) Unwrap() error
- type Eval
- type EvalMachine
- func (o *EvalMachine) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *EvalMachine) Call(_ ...Object) (Object, error)
- func (o *EvalMachine) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *EvalMachine) CallName(nameA string, c Call) (Object, error)
- func (o *EvalMachine) CanCall() bool
- func (*EvalMachine) CanIterate() bool
- func (o *EvalMachine) Equal(right Object) bool
- func (o *EvalMachine) GetMember(idxA string) Object
- func (o *EvalMachine) GetValue() Object
- func (o *EvalMachine) HasMemeber() bool
- func (o *EvalMachine) IndexGet(index Object) (Object, error)
- func (o *EvalMachine) IndexSet(index, value Object) error
- func (o *EvalMachine) IsFalsy() bool
- func (*EvalMachine) Iterate() Iterator
- func (o *EvalMachine) SetMember(idxA string, valueA Object) error
- func (o *EvalMachine) SetValue(valueA Object) error
- func (o *EvalMachine) String() string
- func (*EvalMachine) TypeCode() int
- func (*EvalMachine) TypeName() string
- type ExCallerObject
- type Excel
- func (o *Excel) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Excel) Call(argsA ...Object) (Object, error)
- func (o *Excel) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Excel) CanCall() bool
- func (*Excel) CanIterate() bool
- func (o *Excel) Equal(right Object) bool
- func (o *Excel) GetMember(idxA string) Object
- func (o *Excel) GetValue() Object
- func (o *Excel) HasMemeber() bool
- func (o *Excel) IndexGet(index Object) (Object, error)
- func (o *Excel) IndexSet(index, value Object) error
- func (o *Excel) IsFalsy() bool
- func (*Excel) Iterate() Iterator
- func (o *Excel) SetMember(idxA string, valueA Object) error
- func (o *Excel) SetValue(valueA Object) error
- func (o *Excel) String() string
- func (*Excel) TypeCode() int
- func (*Excel) TypeName() string
- type ExtImporter
- type File
- func (o *File) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *File) Call(_ ...Object) (Object, error)
- func (o *File) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *File) CallName(name string, c Call) (Object, error)
- func (o *File) CanCall() bool
- func (*File) CanIterate() bool
- func (o *File) Close() error
- func (o *File) Equal(right Object) bool
- func (o *File) GetMember(idxA string) Object
- func (o *File) GetValue() Object
- func (o *File) HasMemeber() bool
- func (o *File) IndexGet(index Object) (Object, error)
- func (o *File) IndexSet(index, value Object) error
- func (o *File) IsFalsy() bool
- func (o *File) Iterate() Iterator
- func (o *File) Read(p []byte) (n int, err error)
- func (o *File) SetMember(idxA string, valueA Object) error
- func (o *File) String() string
- func (*File) TypeCode() int
- func (*File) TypeName() string
- func (o *File) Write(p []byte) (n int, err error)
- type Float
- func (o Float) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Float) Call(_ ...Object) (Object, error)
- func (o Float) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Float) CanCall() bool
- func (Float) CanIterate() bool
- func (o Float) Equal(right Object) bool
- func (o Float) Format(s fmt.State, verb rune)
- func (o Float) GetMember(idxA string) Object
- func (o Float) GetValue() Object
- func (o Float) HasMemeber() bool
- func (o Float) IndexGet(index Object) (Object, error)
- func (Float) IndexSet(index, value Object) error
- func (o Float) IsFalsy() bool
- func (Float) Iterate() Iterator
- func (o Float) SetMember(idxA string, valueA Object) error
- func (o Float) String() string
- func (Float) TypeCode() int
- func (Float) TypeName() string
- type Function
- func (*Function) BinaryOp(token.Token, Object) (Object, error)
- func (o *Function) Call(args ...Object) (Object, error)
- func (o *Function) CallEx(call Call) (Object, error)
- func (o *Function) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*Function) CanCall() bool
- func (o *Function) CanIterate() bool
- func (o *Function) Copy() Object
- func (o *Function) Equal(right Object) bool
- func (o *Function) GetMember(idxA string) Object
- func (o *Function) GetValue() Object
- func (o *Function) HasMemeber() bool
- func (o *Function) IndexGet(index Object) (Object, error)
- func (*Function) IndexSet(index, value Object) error
- func (o *Function) IsFalsy() bool
- func (o *Function) Iterate() Iterator
- func (o *Function) SetMember(idxA string, valueA Object) error
- func (o *Function) String() string
- func (*Function) TypeCode() int
- func (*Function) TypeName() string
- type Gel
- func (o *Gel) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Gel) Call(_ ...Object) (Object, error)
- func (o *Gel) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Gel) CanCall() bool
- func (*Gel) CanIterate() bool
- func (o *Gel) Equal(right Object) bool
- func (o *Gel) GetMember(idxA string) Object
- func (o *Gel) GetValue() Object
- func (o *Gel) HasMemeber() bool
- func (o *Gel) IndexGet(index Object) (Object, error)
- func (o *Gel) IndexSet(index, value Object) error
- func (o *Gel) IsFalsy() bool
- func (o *Gel) Iterate() Iterator
- func (o *Gel) SetMember(idxA string, valueA Object) error
- func (o *Gel) String() string
- func (*Gel) TypeCode() int
- func (*Gel) TypeName() string
- type GlobalContext
- type HttpHandler
- func (o *HttpHandler) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *HttpHandler) Call(_ ...Object) (Object, error)
- func (o *HttpHandler) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *HttpHandler) CanCall() bool
- func (*HttpHandler) CanIterate() bool
- func (o *HttpHandler) Equal(right Object) bool
- func (o *HttpHandler) GetMember(idxA string) Object
- func (o *HttpHandler) GetValue() Object
- func (o *HttpHandler) HasMemeber() bool
- func (o *HttpHandler) IndexGet(index Object) (Object, error)
- func (o *HttpHandler) IndexSet(index, value Object) error
- func (o *HttpHandler) IsFalsy() bool
- func (o *HttpHandler) Iterate() Iterator
- func (o *HttpHandler) SetMember(idxA string, valueA Object) error
- func (o *HttpHandler) String() string
- func (*HttpHandler) TypeCode() int
- func (*HttpHandler) TypeName() string
- type HttpReq
- func (o *HttpReq) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *HttpReq) Call(_ ...Object) (Object, error)
- func (o *HttpReq) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *HttpReq) CanCall() bool
- func (*HttpReq) CanIterate() bool
- func (o *HttpReq) Equal(right Object) bool
- func (o *HttpReq) GetMember(idxA string) Object
- func (o *HttpReq) GetValue() Object
- func (o *HttpReq) HasMemeber() bool
- func (o *HttpReq) IndexGet(index Object) (Object, error)
- func (o *HttpReq) IndexSet(index, value Object) error
- func (o *HttpReq) IsFalsy() bool
- func (o *HttpReq) Iterate() Iterator
- func (o *HttpReq) SetMember(idxA string, valueA Object) error
- func (o *HttpReq) String() string
- func (*HttpReq) TypeCode() int
- func (*HttpReq) TypeName() string
- type HttpResp
- func (o *HttpResp) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *HttpResp) Call(_ ...Object) (Object, error)
- func (o *HttpResp) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *HttpResp) CanCall() bool
- func (*HttpResp) CanIterate() bool
- func (o *HttpResp) Equal(right Object) bool
- func (o *HttpResp) GetMember(idxA string) Object
- func (o *HttpResp) GetValue() Object
- func (o *HttpResp) HasMemeber() bool
- func (o *HttpResp) IndexGet(index Object) (Object, error)
- func (o *HttpResp) IndexSet(index, value Object) error
- func (o *HttpResp) IsFalsy() bool
- func (o *HttpResp) Iterate() Iterator
- func (o *HttpResp) SetMember(idxA string, valueA Object) error
- func (o *HttpResp) String() string
- func (*HttpResp) TypeCode() int
- func (*HttpResp) TypeName() string
- func (o *HttpResp) Write(p []byte) (n int, err error)
- type Image
- func (o *Image) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Image) Call(_ ...Object) (Object, error)
- func (o *Image) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Image) CallName(nameA string, c Call) (Object, error)
- func (o *Image) CanCall() bool
- func (*Image) CanIterate() bool
- func (o *Image) Equal(right Object) bool
- func (o *Image) GetMember(idxA string) Object
- func (o *Image) GetValue() Object
- func (o *Image) HasMemeber() bool
- func (o *Image) IndexGet(index Object) (Object, error)
- func (o *Image) IndexSet(index, value Object) error
- func (o *Image) IsFalsy() bool
- func (*Image) Iterate() Iterator
- func (o *Image) SetMember(idxA string, valueA Object) error
- func (o *Image) SetValue(valueA Object) error
- func (o *Image) String() string
- func (*Image) TypeCode() int
- func (*Image) TypeName() string
- type Importable
- type IndexDeleter
- type Int
- func (o Int) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Int) Call(_ ...Object) (Object, error)
- func (o Int) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Int) CanCall() bool
- func (Int) CanIterate() bool
- func (o Int) Equal(right Object) bool
- func (o Int) Format(s fmt.State, verb rune)
- func (o Int) GetMember(idxA string) Object
- func (o Int) GetValue() Object
- func (o Int) HasMemeber() bool
- func (o Int) IndexGet(index Object) (Object, error)
- func (Int) IndexSet(index, value Object) error
- func (o Int) IsFalsy() bool
- func (o Int) Iterate() Iterator
- func (o Int) SetMember(idxA string, valueA Object) error
- func (o Int) String() string
- func (Int) TypeCode() int
- func (Int) TypeName() string
- type IntIterator
- type Invoker
- type Iterator
- type JsVm
- func (o *JsVm) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *JsVm) Call(_ ...Object) (Object, error)
- func (o *JsVm) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *JsVm) CallName(nameA string, c Call) (Object, error)
- func (o *JsVm) CanCall() bool
- func (*JsVm) CanIterate() bool
- func (o *JsVm) Equal(right Object) bool
- func (o *JsVm) GetMember(idxA string) Object
- func (o *JsVm) GetValue() Object
- func (o *JsVm) HasMemeber() bool
- func (o *JsVm) IndexGet(index Object) (Object, error)
- func (o *JsVm) IndexSet(index, value Object) error
- func (o *JsVm) IsFalsy() bool
- func (*JsVm) Iterate() Iterator
- func (o *JsVm) SetMember(idxA string, valueA Object) error
- func (o *JsVm) SetValue(valueA Object) error
- func (o *JsVm) String() string
- func (*JsVm) TypeCode() int
- func (*JsVm) TypeName() string
- type LengthGetter
- type Location
- func (o *Location) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Location) Equal(right Object) bool
- func (o *Location) GetMember(idxA string) Object
- func (o *Location) GetValue() Object
- func (o *Location) HasMemeber() bool
- func (o *Location) IsFalsy() bool
- func (o *Location) SetMember(idxA string, valueA Object) error
- func (o *Location) String() string
- func (*Location) TypeCode() int
- func (*Location) TypeName() string
- type Map
- func (o Map) BinaryOp(tok token.Token, right Object) (Object, error)
- func (Map) Call(...Object) (Object, error)
- func (o Map) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Map) CallName(nameA string, c Call) (Object, error)
- func (Map) CanCall() bool
- func (Map) CanIterate() bool
- func (o Map) Copy() Object
- func (o Map) Equal(right Object) bool
- func (o Map) GetMember(idxA string) Object
- func (o Map) GetValue() Object
- func (o Map) HasMemeber() bool
- func (o Map) IndexDelete(key Object) error
- func (o Map) IndexGet(index Object) (Object, error)
- func (o Map) IndexSet(index, value Object) error
- func (o Map) IsFalsy() bool
- func (o Map) Iterate() Iterator
- func (o Map) Len() int
- func (o Map) SetMember(idxA string, valueA Object) error
- func (o Map) String() string
- func (Map) TypeCode() int
- func (Map) TypeName() string
- type MapArray
- func (o *MapArray) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *MapArray) Call(_ ...Object) (Object, error)
- func (o *MapArray) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *MapArray) CallName(nameA string, c Call) (Object, error)
- func (o *MapArray) CanCall() bool
- func (*MapArray) CanIterate() bool
- func (o *MapArray) Equal(right Object) bool
- func (o *MapArray) GetMember(idxA string) Object
- func (o *MapArray) GetValue() Object
- func (o *MapArray) HasMemeber() bool
- func (o *MapArray) IndexGet(index Object) (Object, error)
- func (o *MapArray) IndexSet(index, value Object) error
- func (o *MapArray) IsFalsy() bool
- func (o *MapArray) Iterate() Iterator
- func (o *MapArray) Len() int
- func (o *MapArray) SetMember(idxA string, valueA Object) error
- func (o *MapArray) SetValue(valueA Object) error
- func (o *MapArray) String() string
- func (*MapArray) TypeCode() int
- func (*MapArray) TypeName() string
- type MapArrayIterator
- type MapIterator
- type ModuleMap
- func (m *ModuleMap) Add(name string, module Importable) *ModuleMap
- func (m *ModuleMap) AddBuiltinModule(name string, attrs map[string]Object) *ModuleMap
- func (m *ModuleMap) AddSourceModule(name string, src []byte) *ModuleMap
- func (m *ModuleMap) Copy() *ModuleMap
- func (m *ModuleMap) Fork(moduleName string) *ModuleMap
- func (m *ModuleMap) Get(name string) Importable
- func (m *ModuleMap) Remove(name string)
- func (m *ModuleMap) SetExtImporter(im ExtImporter) *ModuleMap
- type MutableString
- func (o *MutableString) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *MutableString) Call(_ ...Object) (Object, error)
- func (o *MutableString) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *MutableString) CallName(nameA string, c Call) (Object, error)
- func (o *MutableString) CanCall() bool
- func (*MutableString) CanIterate() bool
- func (o *MutableString) Copy() Object
- func (o *MutableString) Equal(right Object) bool
- func (o *MutableString) Format(s fmt.State, verb rune)
- func (o *MutableString) GetMember(idxA string) Object
- func (o *MutableString) GetValue() Object
- func (o *MutableString) HasMemeber() bool
- func (o *MutableString) IndexGet(index Object) (Object, error)
- func (o *MutableString) IndexSet(index, value Object) error
- func (o *MutableString) IsFalsy() bool
- func (o *MutableString) Iterate() Iterator
- func (o *MutableString) Len() int
- func (o *MutableString) MarshalJSON() ([]byte, error)
- func (o *MutableString) SetMember(idxA string, valueA Object) error
- func (o *MutableString) SetValue(valueA Object) error
- func (o *MutableString) String() string
- func (*MutableString) TypeCode() int
- func (*MutableString) TypeName() string
- type MutableStringIterator
- type Mutex
- func (o *Mutex) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Mutex) Call(_ ...Object) (Object, error)
- func (o *Mutex) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Mutex) CanCall() bool
- func (*Mutex) CanIterate() bool
- func (o *Mutex) Equal(right Object) bool
- func (o *Mutex) GetMember(idxA string) Object
- func (o *Mutex) GetValue() Object
- func (o *Mutex) HasMemeber() bool
- func (o *Mutex) IndexGet(index Object) (Object, error)
- func (o *Mutex) IndexSet(index, value Object) error
- func (o *Mutex) IsFalsy() bool
- func (o *Mutex) Iterate() Iterator
- func (o *Mutex) SetMember(idxA string, valueA Object) error
- func (o *Mutex) String() string
- func (*Mutex) TypeCode() int
- func (*Mutex) TypeName() string
- type Mux
- func (o *Mux) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Mux) Call(_ ...Object) (Object, error)
- func (o *Mux) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Mux) CanCall() bool
- func (*Mux) CanIterate() bool
- func (o *Mux) Equal(right Object) bool
- func (o *Mux) GetMember(idxA string) Object
- func (o *Mux) GetValue() Object
- func (o *Mux) HasMemeber() bool
- func (o *Mux) IndexGet(index Object) (Object, error)
- func (o *Mux) IndexSet(index, value Object) error
- func (o *Mux) IsFalsy() bool
- func (o *Mux) Iterate() Iterator
- func (o *Mux) SetMember(idxA string, valueA Object) error
- func (o *Mux) String() string
- func (*Mux) TypeCode() int
- func (*Mux) TypeName() string
- type NameCallerObject
- type Object
- func BuiltinDbCloseFunc(c Call) (Object, error)
- func BuiltinDealStrFunc(c Call) (Object, error)
- func BuiltinDelegateFunc(c Call) (Object, error)
- func BuiltinFuzzyFindFunc(c Call) (Object, error)
- func CallObjectMethodFunc(o Object, idxA string, argsA ...Object) (Object, error)
- func ConvertToObject(vA interface{}) Object
- func GenStatusResult(args ...Object) (Object, error)
- func GetObjectMethodFunc(o Object, idxA string) (Object, error)
- func NewBigFloat(c Call) (Object, error)
- func NewBigInt(c Call) (Object, error)
- func NewBytesBuffer(c Call) (Object, error)
- func NewDelegate(c Call) (Object, error)
- func NewEvalMachine(c Call) (Object, error)
- func NewExcel(c Call) (Object, error)
- func NewExternalDelegate(funcA func(...interface{}) interface{}) Object
- func NewFile(c Call) (Object, error)
- func NewGel(argsA ...Object) (Object, error)
- func NewHttpHandler(c Call) (Object, error)
- func NewHttpReq(c Call) (Object, error)
- func NewImage(c Call) (Object, error)
- func NewJsVm(c Call) (Object, error)
- func NewMapArray(c Call) (Object, error)
- func NewOrderedMap(argsA ...Object) (Object, error)
- func NewQueue(c Call) (Object, error)
- func NewReader(c Call) (Object, error)
- func NewStack(c Call) (Object, error)
- func NewWebSocket(c Call) (Object, error)
- func NewWriter(c Call) (Object, error)
- func ToObject(v interface{}) (ret Object, err error)
- func ToObjectAlt(v interface{}) (ret Object, err error)
- type ObjectImpl
- func (ObjectImpl) BinaryOp(_ token.Token, _ Object) (Object, error)
- func (ObjectImpl) Call(_ ...Object) (Object, error)
- func (o ObjectImpl) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (ObjectImpl) CanCall() bool
- func (ObjectImpl) CanIterate() bool
- func (ObjectImpl) Equal(Object) bool
- func (o ObjectImpl) GetMember(idxA string) Object
- func (o ObjectImpl) GetValue() Object
- func (o ObjectImpl) HasMemeber() bool
- func (o ObjectImpl) IndexGet(index Object) (value Object, err error)
- func (o ObjectImpl) IndexSet(index, value Object) error
- func (ObjectImpl) IsFalsy() bool
- func (ObjectImpl) Iterate() Iterator
- func (o ObjectImpl) SetMember(idxA string, valueA Object) error
- func (o ObjectImpl) String() string
- func (ObjectImpl) TypeCode() int
- func (ObjectImpl) TypeName() string
- type ObjectPtr
- func (o *ObjectPtr) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *ObjectPtr) Call(args ...Object) (Object, error)
- func (o *ObjectPtr) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *ObjectPtr) CanCall() bool
- func (o *ObjectPtr) Copy() Object
- func (o *ObjectPtr) Equal(x Object) bool
- func (o *ObjectPtr) GetMember(idxA string) Object
- func (o *ObjectPtr) GetValue() Object
- func (o *ObjectPtr) HasMemeber() bool
- func (o *ObjectPtr) IsFalsy() bool
- func (o *ObjectPtr) SetMember(idxA string, valueA Object) error
- func (o *ObjectPtr) String() string
- func (o *ObjectPtr) TypeCode() int
- func (o *ObjectPtr) TypeName() string
- type ObjectRef
- func (o *ObjectRef) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *ObjectRef) Call(args ...Object) (Object, error)
- func (o *ObjectRef) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *ObjectRef) CanCall() bool
- func (o *ObjectRef) Copy() Object
- func (o *ObjectRef) Equal(x Object) bool
- func (o *ObjectRef) GetMember(idxA string) Object
- func (o *ObjectRef) GetValue() Object
- func (o *ObjectRef) HasMemeber() bool
- func (o *ObjectRef) IsFalsy() bool
- func (o *ObjectRef) SetMember(idxA string, valueA Object) error
- func (o *ObjectRef) String() string
- func (o *ObjectRef) TypeCode() int
- func (o *ObjectRef) TypeName() string
- type Opcode
- type OptimizerError
- type OrderedMap
- func (o *OrderedMap) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*OrderedMap) Call(...Object) (Object, error)
- func (o *OrderedMap) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *OrderedMap) CallName(nameA string, c Call) (Object, error)
- func (*OrderedMap) CanCall() bool
- func (*OrderedMap) CanIterate() bool
- func (o *OrderedMap) Copy() Object
- func (o *OrderedMap) Equal(right Object) bool
- func (o *OrderedMap) GetMember(idxA string) Object
- func (o *OrderedMap) GetValue() Object
- func (o *OrderedMap) HasMemeber() bool
- func (o *OrderedMap) IndexDelete(key Object) error
- func (o *OrderedMap) IndexGet(index Object) (Object, error)
- func (o *OrderedMap) IndexSet(index, value Object) error
- func (o *OrderedMap) IsFalsy() bool
- func (o *OrderedMap) Iterate() Iterator
- func (o *OrderedMap) Len() int
- func (o *OrderedMap) SetMember(idxA string, valueA Object) error
- func (o *OrderedMap) String() string
- func (*OrderedMap) TypeCode() int
- func (*OrderedMap) TypeName() string
- type OrderedMapIterator
- type Queue
- func (o *Queue) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Queue) Call(...Object) (Object, error)
- func (o *Queue) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*Queue) CanCall() bool
- func (*Queue) CanIterate() bool
- func (o *Queue) GetMember(idxA string) Object
- func (o *Queue) GetValue() Object
- func (o *Queue) HasMemeber() bool
- func (o *Queue) IndexGet(index Object) (Object, error)
- func (o *Queue) IndexSet(index, value Object) error
- func (o *Queue) IsFalsy() bool
- func (o *Queue) Iterate() Iterator
- func (o *Queue) Len() int
- func (o *Queue) SetMember(idxA string, valueA Object) error
- func (o *Queue) String() string
- func (*Queue) TypeCode() int
- func (*Queue) TypeName() string
- type QueueIterator
- type RSAEncryption
- type Reader
- func (o *Reader) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Reader) Call(_ ...Object) (Object, error)
- func (o *Reader) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Reader) CallName(nameA string, c Call) (Object, error)
- func (o *Reader) CanCall() bool
- func (*Reader) CanIterate() bool
- func (o *Reader) Close() error
- func (o *Reader) Equal(right Object) bool
- func (o *Reader) GetMember(idxA string) Object
- func (o *Reader) GetValue() Object
- func (o *Reader) HasMemeber() bool
- func (o *Reader) IndexGet(index Object) (Object, error)
- func (o *Reader) IndexSet(index, value Object) error
- func (o *Reader) IsFalsy() bool
- func (o *Reader) Iterate() Iterator
- func (o *Reader) Read(p []byte) (n int, err error)
- func (o *Reader) SetMember(idxA string, valueA Object) error
- func (o *Reader) SetSize(sizeA int)
- func (o *Reader) Size() int
- func (o *Reader) String() string
- func (*Reader) TypeCode() int
- func (*Reader) TypeName() string
- type RuntimeError
- func (o *RuntimeError) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*RuntimeError) Call(_ ...Object) (Object, error)
- func (o *RuntimeError) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*RuntimeError) CanCall() bool
- func (*RuntimeError) CanIterate() bool
- func (o *RuntimeError) Copy() Object
- func (o *RuntimeError) Equal(right Object) bool
- func (o *RuntimeError) Error() string
- func (o *RuntimeError) Format(s fmt.State, verb rune)
- func (o *RuntimeError) GetMember(idxA string) Object
- func (o *RuntimeError) GetValue() Object
- func (o *RuntimeError) HasMemeber() bool
- func (o *RuntimeError) IndexGet(index Object) (Object, error)
- func (o *RuntimeError) IndexSet(index, value Object) error
- func (o *RuntimeError) IsFalsy() bool
- func (*RuntimeError) Iterate() Iterator
- func (o *RuntimeError) NewError(messages ...string) *RuntimeError
- func (o *RuntimeError) SetMember(idxA string, valueA Object) error
- func (o *RuntimeError) StackTrace() StackTrace
- func (o *RuntimeError) String() string
- func (*RuntimeError) TypeCode() int
- func (*RuntimeError) TypeName() string
- func (o *RuntimeError) Unwrap() error
- type Seq
- func (o *Seq) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Seq) Call(_ ...Object) (Object, error)
- func (o *Seq) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Seq) CanCall() bool
- func (*Seq) CanIterate() bool
- func (o *Seq) Equal(right Object) bool
- func (o *Seq) GetCurrentValue() Object
- func (o *Seq) GetMember(idxA string) Object
- func (o *Seq) GetValue() Object
- func (o *Seq) HasMemeber() bool
- func (o *Seq) IndexGet(index Object) (Object, error)
- func (o *Seq) IndexSet(index, value Object) error
- func (o *Seq) IsFalsy() bool
- func (o *Seq) Iterate() Iterator
- func (o *Seq) SetMember(idxA string, valueA Object) error
- func (o *Seq) SetValue(valueA Object) error
- func (o *Seq) String() string
- func (*Seq) TypeCode() int
- func (*Seq) TypeName() string
- type SimpleOptimizer
- type SourceModule
- type Stack
- func (o *Stack) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Stack) Call(...Object) (Object, error)
- func (o *Stack) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*Stack) CanCall() bool
- func (*Stack) CanIterate() bool
- func (o *Stack) Equal(right Object) bool
- func (o *Stack) GetMember(idxA string) Object
- func (o *Stack) GetValue() Object
- func (o *Stack) HasMemeber() bool
- func (o *Stack) IndexGet(index Object) (Object, error)
- func (o *Stack) IndexSet(index, value Object) error
- func (o *Stack) IsFalsy() bool
- func (o *Stack) Iterate() Iterator
- func (o *Stack) Len() int
- func (o *Stack) Queue(right Object) bool
- func (o *Stack) SetMember(idxA string, valueA Object) error
- func (o *Stack) String() string
- func (*Stack) TypeCode() int
- func (*Stack) TypeName() string
- type StackIterator
- type StackTrace
- type StatusResult
- func (o *StatusResult) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*StatusResult) Call(_ ...Object) (Object, error)
- func (o *StatusResult) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *StatusResult) Equal(right Object) bool
- func (o *StatusResult) GetMember(idxA string) Object
- func (o *StatusResult) GetValue() Object
- func (o *StatusResult) HasMemeber() bool
- func (o *StatusResult) IndexGet(index Object) (Object, error)
- func (o *StatusResult) IndexSet(key, value Object) error
- func (o *StatusResult) SetMember(idxA string, valueA Object) error
- func (o *StatusResult) String() string
- func (o *StatusResult) TypeCode() int
- func (o *StatusResult) TypeName() string
- type String
- func (o String) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o String) Call(_ ...Object) (Object, error)
- func (o String) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o String) CallName(nameA string, c Call) (Object, error)
- func (o String) CanCall() bool
- func (String) CanIterate() bool
- func (o String) Copy() Object
- func (o String) Equal(right Object) bool
- func (o String) Format(s fmt.State, verb rune)
- func (o String) GetMember(idxA string) Object
- func (o String) GetValue() Object
- func (o String) HasMemeber() bool
- func (o String) IndexGet(index Object) (Object, error)
- func (o String) IndexSet(index, value Object) error
- func (o String) IsFalsy() bool
- func (o String) Iterate() Iterator
- func (o String) Len() int
- func (o String) MarshalJSON() ([]byte, error)
- func (o String) SetMember(idxA string, valueA Object) error
- func (o String) String() string
- func (String) TypeCode() int
- func (String) TypeName() string
- type StringBuilder
- func (o *StringBuilder) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*StringBuilder) Call(_ ...Object) (Object, error)
- func (o *StringBuilder) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *StringBuilder) CallName(nameA string, c Call) (Object, error)
- func (*StringBuilder) CanCall() bool
- func (*StringBuilder) CanIterate() bool
- func (o *StringBuilder) Copy() Object
- func (o *StringBuilder) Equal(right Object) bool
- func (o *StringBuilder) GetMember(idxA string) Object
- func (o *StringBuilder) GetValue() Object
- func (o *StringBuilder) HasMemeber() bool
- func (o *StringBuilder) IndexGet(index Object) (value Object, err error)
- func (o *StringBuilder) IndexSet(index, value Object) error
- func (o *StringBuilder) IsFalsy() bool
- func (*StringBuilder) Iterate() Iterator
- func (o *StringBuilder) SetMember(idxA string, valueA Object) error
- func (o *StringBuilder) String() string
- func (o *StringBuilder) TypeCode() int
- func (o *StringBuilder) TypeName() string
- type StringIterator
- type Symbol
- type SymbolScope
- type SymbolTable
- func (st *SymbolTable) DefineGlobal(name string) (*Symbol, error)
- func (st *SymbolTable) DefineLocal(name string) (*Symbol, bool)
- func (st *SymbolTable) DisableBuiltin(names ...string) *SymbolTable
- func (st *SymbolTable) DisabledBuiltins() []string
- func (st *SymbolTable) EnableParams(v bool) *SymbolTable
- func (st *SymbolTable) Fork(block bool) *SymbolTable
- func (st *SymbolTable) FreeSymbols() []*Symbol
- func (st *SymbolTable) InBlock() bool
- func (st *SymbolTable) MaxSymbols() int
- func (st *SymbolTable) NextIndex() int
- func (st *SymbolTable) NumParams() int
- func (st *SymbolTable) Parent(skipBlock bool) *SymbolTable
- func (st *SymbolTable) Resolve(name string) (symbol *Symbol, ok bool)
- func (st *SymbolTable) SetParams(params ...string) error
- func (st *SymbolTable) ShadowedBuiltins() []string
- func (st *SymbolTable) Symbols() []*Symbol
- type SyncIterator
- type SyncMap
- func (o *SyncMap) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*SyncMap) Call(...Object) (Object, error)
- func (o *SyncMap) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (*SyncMap) CanCall() bool
- func (o *SyncMap) CanIterate() bool
- func (o *SyncMap) Copy() Object
- func (o *SyncMap) Equal(right Object) bool
- func (o *SyncMap) Get(index string) (value Object, exists bool)
- func (o *SyncMap) GetMember(idxA string) Object
- func (o *SyncMap) GetValue() Object
- func (o *SyncMap) HasMemeber() bool
- func (o *SyncMap) IndexDelete(key Object) error
- func (o *SyncMap) IndexGet(index Object) (Object, error)
- func (o *SyncMap) IndexSet(index, value Object) error
- func (o *SyncMap) IsFalsy() bool
- func (o *SyncMap) Iterate() Iterator
- func (o *SyncMap) Len() int
- func (o *SyncMap) Lock()
- func (o *SyncMap) RLock()
- func (o *SyncMap) RUnlock()
- func (o *SyncMap) SetMember(idxA string, valueA Object) error
- func (o *SyncMap) String() string
- func (*SyncMap) TypeCode() int
- func (*SyncMap) TypeName() string
- func (o *SyncMap) Unlock()
- type Time
- func (o *Time) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*Time) Call(args ...Object) (Object, error)
- func (o *Time) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Time) CallName(name string, c Call) (Object, error)
- func (*Time) CanCall() bool
- func (*Time) CanIterate() bool
- func (o *Time) Copy() Object
- func (o *Time) Equal(right Object) bool
- func (o *Time) GetMember(idxA string) Object
- func (o *Time) GetValue() Object
- func (o *Time) HasMemeber() bool
- func (o *Time) IndexGet(index Object) (Object, error)
- func (o *Time) IndexSet(index, value Object) error
- func (o *Time) IsFalsy() bool
- func (*Time) Iterate() Iterator
- func (o *Time) MarshalBinary() ([]byte, error)
- func (o *Time) MarshalJSON() ([]byte, error)
- func (o *Time) SetMember(idxA string, valueA Object) error
- func (o *Time) String() string
- func (*Time) TypeCode() int
- func (*Time) TypeName() string
- func (o *Time) UnmarshalBinary(data []byte) error
- func (o *Time) UnmarshalJSON(data []byte) error
- type Uint
- func (o Uint) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o Uint) Call(_ ...Object) (Object, error)
- func (o Uint) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o Uint) CanCall() bool
- func (Uint) CanIterate() bool
- func (o Uint) Equal(right Object) bool
- func (o Uint) Format(s fmt.State, verb rune)
- func (o Uint) GetMember(idxA string) Object
- func (o Uint) GetValue() Object
- func (o Uint) HasMemeber() bool
- func (o Uint) IndexGet(index Object) (Object, error)
- func (Uint) IndexSet(index, value Object) error
- func (o Uint) IsFalsy() bool
- func (o Uint) Iterate() Iterator
- func (o Uint) SetMember(idxA string, valueA Object) error
- func (o Uint) String() string
- func (Uint) TypeCode() int
- func (Uint) TypeName() string
- type UintIterator
- type UndefinedType
- func (o *UndefinedType) BinaryOp(tok token.Token, right Object) (Object, error)
- func (*UndefinedType) Call(_ ...Object) (Object, error)
- func (o *UndefinedType) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *UndefinedType) Equal(right Object) bool
- func (o *UndefinedType) GetMember(idxA string) Object
- func (o *UndefinedType) GetValue() Object
- func (o *UndefinedType) HasMemeber() bool
- func (*UndefinedType) IndexGet(key Object) (Object, error)
- func (*UndefinedType) IndexSet(key, value Object) error
- func (o *UndefinedType) SetMember(idxA string, valueA Object) error
- func (o *UndefinedType) String() string
- func (o *UndefinedType) TypeCode() int
- func (o *UndefinedType) TypeName() string
- type VM
- func (vm *VM) Abort()
- func (vm *VM) Aborted() bool
- func (vm *VM) Clear() *VM
- func (vm *VM) GetBytecode() *Bytecode
- func (vm *VM) GetBytecodeInfo() string
- func (vm *VM) GetCompilerOptions() *CompilerOptions
- func (vm *VM) GetCurFunc() Object
- func (vm *VM) GetCurInstr() Object
- func (vm *VM) GetGlobals() Object
- func (vm *VM) GetLocals(locals []Object) []Object
- func (vm *VM) GetLocalsQuick() []Object
- func (vm *VM) GetSrcPos() parser.Pos
- func (vm *VM) Run(globals Object, args ...Object) (Object, error)
- func (vm *VM) RunCompiledFunction(f *CompiledFunction, globals Object, args ...Object) (Object, error)
- func (vm *VM) SetBytecode(bc *Bytecode) *VM
- func (vm *VM) SetRecover(v bool) *VM
- type ValueSetter
- type WebSocket
- func (o *WebSocket) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *WebSocket) Call(_ ...Object) (Object, error)
- func (o *WebSocket) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *WebSocket) CallName(nameA string, c Call) (Object, error)
- func (o *WebSocket) CanCall() bool
- func (*WebSocket) CanIterate() bool
- func (o *WebSocket) Close() error
- func (o *WebSocket) Equal(right Object) bool
- func (o *WebSocket) GetMember(idxA string) Object
- func (o *WebSocket) GetValue() Object
- func (o *WebSocket) HasMemeber() bool
- func (o *WebSocket) IndexGet(index Object) (Object, error)
- func (o *WebSocket) IndexSet(index, value Object) error
- func (o *WebSocket) IsFalsy() bool
- func (o *WebSocket) Iterate() Iterator
- func (o *WebSocket) SetMember(idxA string, valueA Object) error
- func (o *WebSocket) String() string
- func (*WebSocket) TypeCode() int
- func (*WebSocket) TypeName() string
- type Writer
- func (o *Writer) BinaryOp(tok token.Token, right Object) (Object, error)
- func (o *Writer) Call(_ ...Object) (Object, error)
- func (o *Writer) CallMethod(nameA string, argsA ...Object) (Object, error)
- func (o *Writer) CallName(nameA string, c Call) (Object, error)
- func (o *Writer) CanCall() bool
- func (*Writer) CanIterate() bool
- func (o *Writer) Close() error
- func (o *Writer) Equal(right Object) bool
- func (o *Writer) GetMember(idxA string) Object
- func (o *Writer) GetValue() Object
- func (o *Writer) HasMemeber() bool
- func (o *Writer) IndexGet(index Object) (Object, error)
- func (o *Writer) IndexSet(index, value Object) error
- func (o *Writer) IsFalsy() bool
- func (o *Writer) Iterate() Iterator
- func (o *Writer) SetMember(idxA string, valueA Object) error
- func (o *Writer) String() string
- func (*Writer) TypeCode() int
- func (*Writer) TypeName() string
- func (o *Writer) Write(p []byte) (n int, err error)
Constants ¶
const ( // True represents a true value. True = Bool(true) // False represents a false value. False = Bool(false) )
const ( // AttrModuleName is a special attribute injected into modules to identify // the modules by name. AttrModuleName = "__module_name__" )
Variables ¶
var ( // DefaultCompilerOptions holds default Compiler options. DefaultCompilerOptions = CompilerOptions{ OptimizerMaxCycle: 100, OptimizeConst: true, OptimizeExpr: true, } // TraceCompilerOptions holds Compiler options to print trace output // to stdout for Parser, Optimizer, Compiler. TraceCompilerOptions = CompilerOptions{ Trace: os.Stdout, TraceParser: true, TraceCompiler: true, TraceOptimizer: true, OptimizerMaxCycle: 1<<8 - 1, OptimizeConst: true, OptimizeExpr: true, } )
var ( // ErrSymbolLimit represents a symbol limit error which is returned by // Compiler when number of local symbols exceeds the symbo limit for // a function that is 256. ErrSymbolLimit = &Error{ Name: "SymbolLimitError", Message: "number of local symbols exceeds the limit", } // ErrStackOverflow represents a stack overflow error. ErrStackOverflow = &Error{Name: "StackOverflowError"} // ErrVMAborted represents a VM aborted error. ErrVMAborted = &Error{Name: "VMAbortedError"} // ErrWrongNumArguments represents a wrong number of arguments error. ErrWrongNumArguments = &Error{Name: "WrongNumberOfArgumentsError"} // ErrInvalidOperator represents an error for invalid operator usage. ErrInvalidOperator = &Error{Name: "InvalidOperatorError"} // ErrIndexOutOfBounds represents an out of bounds index error. ErrIndexOutOfBounds = &Error{Name: "IndexOutOfBoundsError"} // ErrInvalidIndex represents an invalid index error. ErrInvalidIndex = &Error{Name: "InvalidIndexError"} // ErrNotIterable is an error where an Object is not iterable. ErrNotIterable = &Error{Name: "NotIterableError"} // ErrNotIndexable is an error where an Object is not indexable. ErrNotIndexable = &Error{Name: "NotIndexableError"} // ErrNotIndexAssignable is an error where an Object is not index assignable. ErrNotIndexAssignable = &Error{Name: "NotIndexAssignableError"} // ErrNotCallable is an error where Object is not callable. ErrNotCallable = &Error{Name: "NotCallableError"} // ErrNotImplemented is an error where an Object has not implemented a required method. ErrNotImplemented = &Error{Name: "NotImplementedError"} // ErrZeroDivision is an error where divisor is zero. ErrZeroDivision = &Error{Name: "ZeroDivisionError"} // ErrType represents a type error. ErrType = &Error{Name: "TypeError"} )
var BigFloatZero = big.NewFloat(0)
var BigIntZero = big.NewInt(0)
var BuiltinCharCodeFunc = builtinCharCodeFunc
var BuiltinObjects = [...]Object{}/* 586 elements not displayed */
BuiltinObjects contains the implementation objects for all built-in functions. Each BuiltinType constant is used as an index into this array. The array is indexed by BuiltinType value and contains BuiltinFunction objects.
Example:
fn := BuiltinObjects[BuiltinPrint] // Returns the print function object result, err := fn.Call(arg1, arg2)
var BuiltinsMap = map[string]BuiltinType{}/* 650 elements not displayed */
BuiltinsMap maps built-in function names to their BuiltinType identifiers. This allows the compiler and VM to resolve function names to their implementations. The map is exported for use by REPL and other tooling.
Example:
builtinType := BuiltinsMap["print"] // Returns BuiltinPrint builtinType := BuiltinsMap["len"] // Returns BuiltinLen
var CodeTextG = ""
var DebugModeG = false
var ErrCommon = &Error{Name: "error"}
var OpcodeNames = [...]string{ OpNoOp: "NOOP", OpConstant: "CONSTANT", OpCall: "CALL", OpGetGlobal: "GETGLOBAL", OpSetGlobal: "SETGLOBAL", OpGetLocal: "GETLOCAL", OpSetLocal: "SETLOCAL", OpGetBuiltin: "GETBUILTIN", OpBinaryOp: "BINARYOP", OpUnary: "UNARY", OpEqual: "EQUAL", OpNotEqual: "NOTEQUAL", OpJump: "JUMP", OpJumpFalsy: "JUMPFALSY", OpAndJump: "ANDJUMP", OpOrJump: "ORJUMP", OpMap: "MAP", OpArray: "ARRAY", OpSliceIndex: "SLICEINDEX", OpGetIndex: "GETINDEX", OpSetIndex: "SETINDEX", OpNull: "NULL", OpPop: "POP", OpGetFree: "GETFREE", OpSetFree: "SETFREE", OpGetLocalPtr: "GETLOCALPTR", OpGetFreePtr: "GETFREEPTR", OpClosure: "CLOSURE", OpIterInit: "ITERINIT", OpIterNext: "ITERNEXT", OpIterKey: "ITERKEY", OpIterValue: "ITERVALUE", OpLoadModule: "LOADMODULE", OpStoreModule: "STOREMODULE", OpReturn: "RETURN", OpSetupTry: "SETUPTRY", OpSetupCatch: "SETUPCATCH", OpSetupFinally: "SETUPFINALLY", OpThrow: "THROW", OpFinalizer: "FINALIZER", OpDefineLocal: "DEFINELOCAL", OpTrue: "TRUE", OpFalse: "FALSE", OpCallName: "CALLNAME", }
OpcodeNames maps each opcode to its human-readable string representation. Used for debugging and disassembly output.
var OpcodeOperands = [...][]int{ OpNoOp: {}, OpConstant: {2}, OpCall: {1, 1}, OpGetGlobal: {2}, OpSetGlobal: {2}, OpGetLocal: {1}, OpSetLocal: {1}, OpGetBuiltin: {2}, OpBinaryOp: {1}, OpUnary: {1}, OpEqual: {}, OpNotEqual: {}, OpJump: {2}, OpJumpFalsy: {2}, OpAndJump: {2}, OpOrJump: {2}, OpMap: {2}, OpArray: {2}, OpSliceIndex: {}, OpGetIndex: {1}, OpSetIndex: {}, OpNull: {}, OpPop: {}, OpGetFree: {1}, OpSetFree: {1}, OpGetLocalPtr: {1}, OpGetFreePtr: {1}, OpClosure: {2, 1}, OpIterInit: {}, OpIterNext: {}, OpIterKey: {}, OpIterValue: {}, OpLoadModule: {2, 2}, OpStoreModule: {2}, OpReturn: {1}, OpSetupTry: {2, 2}, OpSetupCatch: {}, OpSetupFinally: {}, OpThrow: {1}, OpFinalizer: {1}, OpDefineLocal: {1}, OpTrue: {}, OpFalse: {}, OpCallName: {1, 1}, }
OpcodeOperands defines the operand specification for each opcode. Each entry is a slice of operand widths in bytes:
- {} means no operands
- {1} means one 1-byte operand (0-255)
- {2} means one 2-byte operand (0-65535, big-endian)
- {1, 1} means two 1-byte operands
- {2, 1} means one 2-byte and one 1-byte operand
var (
PrintWriter io.Writer = os.Stdout
)
PrintWriter is the default writer for printf and println builtins. It defaults to os.Stdout but can be redirected for testing or logging.
var RandomGeneratorG *tk.RandomX = nil
var RegiCountG int = 30
var ServerModeG = false
var StatusResultFail = StatusResult{Status: "fail", Value: ""}
var StatusResultInvalid = StatusResult{Status: "", Value: ""}
var StatusResultSuccess = StatusResult{Status: "success", Value: ""}
var VerboseG = false
var VersionG = "2.1.3"
global vars
Functions ¶
func AnysToOriginal ¶
func AnysToOriginal(aryA []Object) []interface{}
func ConvertFromObject ¶
func ConvertFromObject(vA Object) interface{}
func DownloadStringFromSSH ¶
func FormatInstructions ¶
FormatInstructions returns string representation of bytecode instructions.
func FromStringObject ¶
FromStringObject creates a String object from string. Parameters:
- argA: The string to wrap (required)
Returns:
- A new String object
Examples:
FromStringObject("hello") // Returns: String("hello")
FromStringObject("42") // Returns: String("42")
func GetCfgString ¶
func GetSwitchFromObjects ¶
GetSwitchFromObjects returns switch value from objects, or default when absent.
func IfSwitchExistsInObjects ¶
IfSwitchExistsInObjects reports whether the switch exists in object args.
func IsUndefInternal ¶
func IterateInstructions ¶
func IterateInstructions(insts []byte, fn func(pos int, opcode Opcode, operands []int, offset int) bool)
IterateInstructions iterate instructions and call given function for each instruction. Note: Do not use operands slice in callback, it is reused for less allocation.
func MakeInstruction ¶
MakeInstruction returns a bytecode for an Opcode and the operands.
Provide "buf" slice which is a returning value to reduce allocation or nil to create new byte slice. This is implemented to reduce compilation allocation that resulted in -15% allocation, +2% speed in compiler. It takes ~8ns/op with zero allocation.
Returning error is required to identify bugs faster when VM and Opcodes are under heavy development.
Warning: Unknown Opcode causes panic!
func ObjectsToBytes ¶
func ObjectsToI ¶
func ObjectsToI(aryA []Object) []interface{}
func ObjectsToN ¶
func ObjectsToO ¶
func ObjectsToO(aryA []Object) []interface{}
func ObjectsToS ¶
func OneResultCallAdapter ¶
func OneResultCallAdapter(fn CallableFunc) func(args ...Object) Object
char add start OneResultCallAdapter wraps CallableFunc and returns only one Object result.
func OneResultCallExAdapter ¶
func OneResultCallExAdapter(fn CallableExFunc) func(args ...Object) Object
OneResultCallExAdapter wraps CallableExFunc and returns only one Object result.
func QuickCompile ¶
func QuickCompile(codeA string, compilerOptionsA ...*CompilerOptions) interface{}
func ReadOperands ¶
ReadOperands reads operands from bytecode instructions. It parses the operand bytes according to the specified widths and returns the operand values and the total bytes consumed.
Parameters:
- numOperands: slice of operand widths (1 or 2 bytes each)
- ins: bytecode instruction slice starting after the opcode
- operands: pre-allocated slice to fill (reused to reduce allocations)
Returns:
- operands: slice of parsed operand values
- int: total number of bytes consumed
Example:
// For OpConstant with operands {2}:
operands, offset := ReadOperands([]int{2}, ins[1:], make([]int, 0, 1))
// operands[0] contains the constant index
func RemoveCfgString ¶
func RunCharCode ¶
func RunScriptOnHttp ¶
func SetCfgString ¶
func ToFloatQuick ¶
func ToGoByteSlice ¶
ToGoByteSlice will try to convert an Object to Go byte slice.
func ToGoFloat64 ¶
ToGoFloat64 will try to convert a numeric, bool or string Object to Go float64 value.
func ToGoIntWithDefault ¶
ToGoIntWithDefault converts an Object to Go int value with a default fallback. It returns the default value if the conversion fails. Supported types: Bool, Byte, Char, Int, Uint, Float, String, MutableString.
func ToGoString ¶
ToGoString will try to convert an Object to Go string value.
func ToGoUint64 ¶
ToGoUint64 will try to convert a numeric, bool or string Object to Go uint64 value.
func ToIntQuick ¶
func ToInterface ¶
func ToInterface(o Object) (ret interface{})
ToInterface tries to convert an Object o to an interface{} value.
Types ¶
type Any ¶
type Any struct {
ObjectImpl
Value interface{}
OriginalType string
OriginalCode int
Members map[string]Object `json:"-"`
}
Any represents container object and implements the Object interfaces. Any is used to hold some data which is not an Object in Charlang, such as structured data from Golang function call Any wraps any Go value as a Charlang Object for interoperability. It stores the original value, type name, and type code for type preservation.
Type code: 999.
Key characteristics:
- Wraps arbitrary Go values (interface{}) as Charlang objects
- Preserves original type information via OriginalType and OriginalCode
- Provides transparent access to wrapped value via "value" method
- Supports member attachment via Members map
- Used for FFI (Foreign Function Interface) and Go value bridging
func (*Any) HasMemeber ¶
type Array ¶
type Array []Object
Array represents array of objects and implements Object interface.
func (Array) HasMemeber ¶
type ArrayIterator ¶
type ArrayIterator struct {
V Array
// contains filtered or unexported fields
}
ArrayIterator represents an iterator for the array.
func (*ArrayIterator) Key ¶
func (it *ArrayIterator) Key() Object
Key implements Iterator interface.
func (*ArrayIterator) Next ¶
func (it *ArrayIterator) Next() bool
Next implements Iterator interface.
func (*ArrayIterator) Value ¶
func (it *ArrayIterator) Value() Object
Value implements Iterator interface.
type BigFloat ¶
BigFloat represents large signed float values and implements Object interface. BigFloat wraps big.Float for arbitrary-precision floating-point arithmetic. It supports floating-point numbers with configurable precision.
Type code: 203.
Key characteristics:
- Wraps Go's math/big.Float for arbitrary-precision floats
- Supports configurable precision and rounding modes
- Supports comparison with other BigFloat values
- String() returns decimal representation
- Supports member attachment via Members map
func (*BigFloat) CallMethod ¶
func (*BigFloat) CanIterate ¶
func (*BigFloat) HasMemeber ¶
type BigInt ¶
BigInt represents large signed integer values and implements Object interface. BigInt wraps big.Int for arbitrary-precision integer arithmetic. It supports integers of unlimited size, beyond Int's 64-bit limit.
Type code: 201.
Key characteristics:
- Wraps Go's math/big.Int for arbitrary-precision integers
- Supports all arithmetic operations without overflow
- Supports comparison with other BigInt values
- String() returns decimal representation
- Supports member attachment via Members map
func (*BigInt) CallMethod ¶
func (*BigInt) CanIterate ¶
func (*BigInt) HasMemeber ¶
type Bool ¶
type Bool bool
Bool represents boolean values and implements Object interface.
func (Bool) HasMemeber ¶
type BuiltinFunction ¶
type BuiltinFunction struct {
ObjectImpl
Name string
Value func(args ...Object) (Object, error)
ValueEx func(Call) (Object, error)
Members map[string]Object `json:"-"`
Methods map[string]*Function
Remark string
}
BuiltinFunction represents a builtin function object and implements Object interface. BuiltinFunction represents a built-in function provided by the Charlang runtime. Examples include print, len, type, new, and other language primitives.
Type code: 183.
Key characteristics:
- Implements ExCallerObject interface for extended call context
- Value: simple function signature with variadic Object args
- ValueEx: extended signature with full Call context access
- Supports dynamic method generation for namespace functions
- Methods cache stores dynamically created function objects
- Remark field stores additional documentation/description
- Supports member attachment via Members map
Usage:
builtin := &BuiltinFunction{
Name: "print",
Value: func(args ...Object) (Object, error) {
fmt.Println(args[0].String())
return Undefined, nil
},
}
func (*BuiltinFunction) Call ¶
func (o *BuiltinFunction) Call(args ...Object) (Object, error)
Call implements Object interface.
func (*BuiltinFunction) CallMethod ¶
func (o *BuiltinFunction) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*BuiltinFunction) CanCall ¶
func (*BuiltinFunction) CanCall() bool
CanCall implements Object interface.
func (*BuiltinFunction) CanIterate ¶
func (o *BuiltinFunction) CanIterate() bool
func (*BuiltinFunction) Copy ¶
func (o *BuiltinFunction) Copy() Object
Copy implements Copier interface.
func (*BuiltinFunction) Equal ¶
func (o *BuiltinFunction) Equal(right Object) bool
Equal implements Object interface.
func (*BuiltinFunction) GetMember ¶
func (o *BuiltinFunction) GetMember(idxA string) Object
func (*BuiltinFunction) GetValue ¶
func (o *BuiltinFunction) GetValue() Object
func (*BuiltinFunction) HasMemeber ¶
func (o *BuiltinFunction) HasMemeber() bool
func (*BuiltinFunction) IndexSet ¶
func (*BuiltinFunction) IndexSet(index, value Object) error
func (*BuiltinFunction) IsFalsy ¶
func (o *BuiltinFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*BuiltinFunction) Iterate ¶
func (o *BuiltinFunction) Iterate() Iterator
Iterate implements Iterable interface.
func (*BuiltinFunction) SetMember ¶
func (o *BuiltinFunction) SetMember(idxA string, valueA Object) error
func (*BuiltinFunction) String ¶
func (o *BuiltinFunction) String() string
String implements Object interface.
func (*BuiltinFunction) TypeCode ¶
func (*BuiltinFunction) TypeCode() int
func (*BuiltinFunction) TypeName ¶
func (*BuiltinFunction) TypeName() string
TypeName implements Object interface.
type BuiltinModule ¶
BuiltinModule is an importable module that's written in Go.
func (*BuiltinModule) Import ¶
func (m *BuiltinModule) Import(moduleName string) (interface{}, error)
Import returns an immutable map for the module.
type BuiltinType ¶
type BuiltinType int
BuiltinType represents a unique identifier for each built-in function. These constants are used as indices into BuiltinObjects array and keys in BuiltinsMap.
const ( BuiltinAppend BuiltinType = iota BuiltinReset BuiltinStatusToStr BuiltinStatusToMap BuiltinDocxToStrs BuiltinDocxReplacePattern BuiltinDocxGetPlaceholders BuiltinDeepClone BuiltinGetCfgStr BuiltinSetCfgStr BuiltinRemoveCfgStr BuiltinShowTable BuiltinGuiServerCommand BuiltinGetMapItem BuiltinSetMapItem BuiltinSendMail BuiltinGetTextSimilarity BuiltinFuzzyFind BuiltinStrRemoveBomHead BuiltinLeSshInfo BuiltinStack BuiltinQueue BuiltinMapArray BuiltinPlotClearConsole BuiltinPlotDataToStr BuiltinPlotDataToImage BuiltinPlotLoadFont BuiltinResizeImage BuiltinImageToAscii BuiltinLoadImageFromFile BuiltinSaveImageToFile BuiltinGetImageInfo BuiltinStrToRgba BuiltinEncodeImage BuiltinEncodeBytesInImage BuiltinDecodeBytesFromImage BuiltinDrawImageOnImage BuiltinDrawTextWrappedOnImage BuiltinAddWatermarkToImage BuiltinSetImageOpacity BuiltinGenQr BuiltinScanQr BuiltinSaveImageToBytes BuiltinClose BuiltinRegSplit BuiltinReadCsv BuiltinExcelNew BuiltinExcelOpen BuiltinExcelOpenFromBytes BuiltinExcelOpenFile BuiltinExcelSaveAs BuiltinExcelWriteTo BuiltinExcelWriteToBytes BuiltinExcelClose BuiltinExcelNewSheet BuiltinExcelRemoveSheet BuiltinExcelReadAll BuiltinExcelGetSheetCount BuiltinExcelGetSheetList BuiltinExcelGetSheetName BuiltinExcelReadSheet BuiltinExcelReadCell BuiltinExcelReadCellImages BuiltinExcelWriteSheet BuiltinExcelWriteCell BuiltinExcelGetColumnIndexByName BuiltinExcelGetColumnNameByIndex BuiltinWriteCsv BuiltinRemovePath BuiltinRemoveDir BuiltinGetInput BuiltinGetInputf BuiltinGetInputPasswordf BuiltinGetChar BuiltinGetMultiLineInput BuiltinSetStdin BuiltinSetStdout BuiltinSetStderr BuiltinGetPipe BuiltinRegCount BuiltinStrRepeat BuiltinRegMatch BuiltinRegContains BuiltinRegContainsIn BuiltinLePrint BuiltinLeFindLines BuiltinLeFind BuiltinLeFindAll BuiltinLeReplace BuiltinLeLoadFromSsh BuiltinLeSaveToSsh BuiltinLeRemoveLine BuiltinLeRemoveLines BuiltinLeInsertLine BuiltinLeAppendLine BuiltinLeGetLine BuiltinLeSetLine BuiltinLeSetLines BuiltinLeConvertToUtf8 BuiltinLeSort BuiltinLeViewAll BuiltinLeViewLine BuiltinLeViewLines BuiltinLeLoadFromUrl BuiltinLeLoadFromClip BuiltinLeSaveToClip BuiltinLeAppendFromFile BuiltinLeAppendToFile BuiltinLeLoadFromFile BuiltinLeSaveToFile BuiltinLeLoadFromStr BuiltinLeSaveToStr BuiltinLeGetList BuiltinLeAppendFromStr BuiltinLeClear BuiltinLeInfo BuiltinS3GetObjectBytes BuiltinS3GetObjectText BuiltinS3PutObject BuiltinS3GetObjectToFile BuiltinS3GetObjectReader BuiltinS3GetObjectUrl BuiltinS3GetObjectTags BuiltinS3GetObjectStat BuiltinS3StatObject BuiltinS3CopyObject BuiltinS3MoveObject BuiltinS3RemoveObject BuiltinS3ListObjects BuiltinAwsSign BuiltinNow BuiltinTimeToTick BuiltinFormatTime BuiltinTimeAddSecs BuiltinTimeAddDate BuiltinTimeBefore BuiltinIsCronExprValid BuiltinRunTicker BuiltinIsCronExprDue BuiltinSplitCronExpr BuiltinResetTasker BuiltinRunTasker BuiltinStopTasker BuiltinAddSimpleTask BuiltinAddShellTask BuiltinGetNowTimeStamp BuiltinBase64Encode BuiltinBase64Decode BuiltinBase64EncodeByRawUrl BuiltinBase64DecodeByRawUrl BuiltinXmlGetNodeStr BuiltinStrXmlEncode BuiltinFromXml BuiltinFormatXml BuiltinMd5 BuiltinPostRequest BuiltinPrepareMultiPartFieldFromBytes BuiltinPrepareMultiPartFileFromBytes BuiltinHttpRedirect BuiltinReader BuiltinWriter BuiltinFile BuiltinBytesBuffer BuiltinImage BuiltinLoadImageFromBytes BuiltinLoadImageFromUrl BuiltinThumbImage BuiltinBytesStartsWith BuiltinBytesEndsWith BuiltinBytesContains BuiltinBytesIndex BuiltinIsEncrypted BuiltinEncryptData BuiltinDecryptData BuiltinEncryptStream BuiltinDecryptStream BuiltinSimpleEncode BuiltinSimpleDecode BuiltinToPinYin BuiltinKanjiToKana BuiltinKanaToRomaji BuiltinKanjiToRomaji BuiltinIsHttps BuiltinCopyFile BuiltinRenameFile BuiltinStrJoin BuiltinStrCount BuiltinStrSub BuiltinStrPad BuiltinStrRuneLen BuiltinStrIn BuiltinStrGetLastComponent BuiltinEnsureMakeDirs BuiltinExtractFileDir BuiltinExtractFileName BuiltinCheckToken BuiltinGetOtpCode BuiltinCheckOtpCode BuiltinEncryptText BuiltinDecryptText BuiltinEncryptTextByTXTE BuiltinDecryptTextByTXTE BuiltinEncryptDataByTXDEE BuiltinDecryptDataByTXDEE BuiltinEncryptTextByTXDEE BuiltinDecryptTextByTXDEE BuiltinAesEncrypt BuiltinAesDecrypt BuiltinGetSha256WithKeyYY BuiltinRsaEncryptStrYY BuiltinHtmlEncode BuiltinHtmlDecode BuiltinServeFile BuiltinGetFileInfo BuiltinGetFileAbs BuiltinGetFileRel BuiltinGetFileExt BuiltinGetMimeType BuiltinStartSocksServer BuiltinStartSocksClient BuiltinStartTransparentProxy BuiltinStartTransparentProxyEx BuiltinRenderMarkdown BuiltinReplaceHtmlByMap BuiltinProcessHtmlTemplate BuiltinIsDir BuiltinStrStartsWith BuiltinStrEndsWith BuiltinStrSplit BuiltinStrSplitN BuiltinGenToken BuiltinGenJwtToken BuiltinParseJwtToken BuiltinStrContains BuiltinStrContainsAny BuiltinStrContainsIn BuiltinStrIndex BuiltinGetNowStr BuiltinGetNowStrCompact BuiltinLock BuiltinUnlock BuiltinTryLock BuiltinRLock BuiltinRUnlock BuiltinTryRLock BuiltinToKMG BuiltinIntToStr BuiltinFloatToStr BuiltinStrToUtf8 BuiltinStrUtf8ToGb BuiltinBytesGbToUtf8Str BuiltinIsUtf8 BuiltinSimpleStrToMap BuiltinSimpleStrToMapReverse BuiltinReverseMap BuiltinGetFileList BuiltinMathAbs BuiltinMathSqrt BuiltinMathPow BuiltinMathExp BuiltinMathLog BuiltinMathLog10 BuiltinMathMin BuiltinMathMax BuiltinMathCeil BuiltinMathFloor BuiltinMathRound BuiltinMathPi BuiltinMathE BuiltinMathSin BuiltinMathCos BuiltinMathTan BuiltinMathAtan2 BuiltinFlexEval BuiltinCalDistanceOfLatLon BuiltinCalDistanceOfLonLat BuiltinAdjustFloat BuiltinBigInt BuiltinBigFloat BuiltinToOrderedMap BuiltinUnhex BuiltinHexToStr BuiltinBitNot BuiltinToUpper BuiltinToLower BuiltinSscanf BuiltinStrQuote BuiltinStrUnquote BuiltinStrToInt BuiltinStrToTime BuiltinDealStr BuiltinToInt BuiltinToBool BuiltinToBoolWithDefault BuiltinToFloat BuiltinToHex BuiltinCompareBytes BuiltinCompareText BuiltinLoadBytes BuiltinLoadBytesFromFile BuiltinLoadBytesFromFileLimit BuiltinSaveBytes BuiltinOpenFile BuiltinCloseFile BuiltinCompressData BuiltinCompressStr BuiltinUncompressData BuiltinUncompressStr BuiltinUrlEncode BuiltinUrlEncode1 BuiltinUrlDecode BuiltinOrderedMap BuiltinExcel BuiltinArrayContains BuiltinSortArray // BuiltinSortByFunc BuiltinShuffle BuiltinLimitStr BuiltinStrFindDiffPos BuiltinStrDiff BuiltinStrFindAllSub BuiltinRemoveItem BuiltinRemoveItems BuiltinAppendList BuiltinGetRandomInt BuiltinGetRandomFloat BuiltinGetRandomStr BuiltinFormatSQLValue BuiltinDbClose BuiltinDbQuery BuiltinDbQueryOrdered BuiltinDbQueryRecs BuiltinDbQueryMap BuiltinDbQueryMapArray BuiltinDbQueryCount BuiltinDbQueryFloat BuiltinDbQueryString BuiltinDbExec BuiltinRemoveFile BuiltinFileExists BuiltinGenJSONResp BuiltinUrlExists BuiltinParseUrl BuiltinParseQuery BuiltinErrStrf BuiltinErrf BuiltinErrToEmpty BuiltinCharCode BuiltinEvalMachine BuiltinJsVm // BuiltinQjsVm BuiltinGel BuiltinDelegate BuiltinGetReqBody BuiltinGetReqHeader BuiltinGetReqHeaders BuiltinWriteRespHeader BuiltinSetRespHeader BuiltinParseReqForm BuiltinParseReqFormEx BuiltinWriteResp BuiltinMux BuiltinMutex BuiltinHttpHandler BuiltinHttpReq BuiltinWebSocket BuiltinFatalf BuiltinSeq BuiltinIsNil BuiltinIsNilOrEmpty BuiltinIsNilOrErr BuiltinGetValue BuiltinSetValue BuiltinGetMember BuiltinSetMember BuiltinCallMethod BuiltinDumpVar BuiltinDebugInfo BuiltinMake BuiltinDatabase BuiltinStatusResult BuiltinUnref BuiltinSetValueByRef BuiltinGetWeb BuiltinDownloadFile BuiltinGetWebBytes BuiltinGetWebBytesWithHeaders BuiltinGetWebRespBody BuiltinRegFindFirstGroups BuiltinReadAllStr BuiltinReadAllBytes BuiltinReadBytes BuiltinWriteStr BuiltinWriteBytes BuiltinWriteBytesAt BuiltinIoCopy BuiltinStrSplitLines BuiltinNew BuiltinStringBuilder BuiltinStrReplace BuiltinGetErrStrX BuiltinFtpList BuiltinFtpCreateDir BuiltinFtpSize BuiltinFtpUpload BuiltinFtpUploadFromReader BuiltinFtpDownloadBytes BuiltinFtpDownloadFile BuiltinFtpGetReader BuiltinFtpRemoveFile BuiltinSshUpload BuiltinSshUploadBytes BuiltinSshDownload BuiltinSshDownloadBytes BuiltinSshList BuiltinSshIfFileExists BuiltinSshGetFileInfo BuiltinSshRun BuiltinSshRename BuiltinSshJoinPath BuiltinSshRemoveFile BuiltinSshRemoveDir BuiltinSshEnsureMakeDirs BuiltinArchiveFilesToZip BuiltinGetFileListInArchive BuiltinGetFileListInArchiveBytes BuiltinGetFileListInZip BuiltinLoadBytesInArchive BuiltinLoadBytesInArchiveBytes BuiltinExtractFileInArchive BuiltinExtractArchive BuiltinIsFileNameUtf8InZipBytes BuiltinZipPath BuiltinZipPaths BuiltinAddPathsToZipFile BuiltinUnzipToPath BuiltinGetOSName BuiltinGetOSArch BuiltinGetOSArgs BuiltinGetAppDir BuiltinGetAppPath BuiltinGetCurDir BuiltinGetHomeDir BuiltinGetTempDir BuiltinCreateTempDir BuiltinCreateTempFile BuiltinChangeDir BuiltinLookPath BuiltinGetClipText BuiltinSetClipText BuiltinRegQuote BuiltinRegReplace BuiltinAny BuiltinTrim BuiltinTrimErr BuiltinStrTrim BuiltinStrTrimStart BuiltinStrTrimEnd BuiltinStrTrimLeft BuiltinStrTrimRight BuiltinRegFindFirst BuiltinRegFindAll BuiltinRegFindAllIndex BuiltinRegFindAllGroups BuiltinCheckErrX BuiltinCheckEmpty BuiltinLoadText BuiltinLoadLines BuiltinSaveText BuiltinAppendText BuiltinJoinPath BuiltinJoinUrlPath BuiltinGetSysInfo BuiltinGetEnv BuiltinSetEnv BuiltinTypeOfAny BuiltinToStr BuiltinCallNamedFunc BuiltinCallInternalFunc BuiltinGetProcessVar BuiltinSetProcessVar BuiltinDeleteProcessVar BuiltinGetNamedValue BuiltinNewEx BuiltinCallMethodEx BuiltinToTime // BuiltinNewAny BuiltinTime BuiltinSleep BuiltinExit BuiltinSystemCmd BuiltinSystemCmdDetached BuiltinSystemStart BuiltinIsErrX BuiltinIsErrStr BuiltinToJSON BuiltinFromJSON BuiltinFormatJson BuiltinCompactJson BuiltinGetJsonNodeStr BuiltinGetJsonNodeStrs BuiltinStrsToJson BuiltinEncodeSimpleMap BuiltinDecodeSimpleMap BuiltinPlo BuiltinPlt BuiltinPlErr BuiltinGetParam BuiltinGetParams BuiltinGetSwitch BuiltinGetSwitches BuiltinGetIntSwitch BuiltinIfSwitchExists BuiltinTypeCode BuiltinTypeName BuiltinPl BuiltinPr BuiltinPrf BuiltinFprf BuiltinPlNow BuiltinPln BuiltinPlv BuiltinSpr BuiltinSpt BuiltinSpln BuiltinTestByText BuiltinTestByStartsWith BuiltinTestByEndsWith BuiltinTestByContains BuiltinTestByRegContains // BuiltinTestByFunc // BuiltinTestByLineRules BuiltinTestByReg BuiltinGetSeq BuiltinMagic BuiltinGetUuid BuiltinPass BuiltinDelete BuiltinGetArrayItem BuiltinCopy BuiltinCopyBytes BuiltinRepeat BuiltinContains BuiltinLen BuiltinSort BuiltinSortReverse BuiltinError BuiltinBool BuiltinInt BuiltinUint BuiltinFloat BuiltinChar BuiltinByte BuiltinString BuiltinMutableString BuiltinBytes BuiltinBytesWithSize BuiltinBytesWithCap BuiltinChars BuiltinPrintf BuiltinPrintln BuiltinSprintf BuiltinGlobals BuiltinIsError BuiltinIsInt BuiltinIsUint BuiltinIsFloat BuiltinIsChar BuiltinIsByte BuiltinIsBool BuiltinIsString BuiltinIsBytes BuiltinIsChars BuiltinIsMap BuiltinIsSyncMap BuiltinIsArray BuiltinIsUndefined BuiltinIsFunction BuiltinIsCallable BuiltinIsIterable BuiltinWrongNumArgumentsError BuiltinInvalidOperatorError BuiltinIndexOutOfBoundsError BuiltinNotIterableError BuiltinNotIndexableError BuiltinNotIndexAssignableError BuiltinNotCallableError BuiltinNotImplementedError BuiltinZeroDivisionError BuiltinTypeError BuiltinMakeArray BuiltinCap )
Builtin constants define all available built-in functions. Each constant corresponds to a built-in function implementation in BuiltinObjects.
type Byte ¶
type Byte byte
func ToByteObject ¶
func (Byte) HasMemeber ¶
type Bytecode ¶
type Bytecode struct {
FileSet *parser.SourceFileSet
Main *CompiledFunction
Constants []Object
NumModules int
CompilerOptionsM *CompilerOptions
}
Bytecode holds the compiled functions and constants.
func Compile ¶
func Compile(script []byte, opts *CompilerOptions) (*Bytecode, error)
Compile compiles given script to Bytecode.
type Bytes ¶
type Bytes []byte
Bytes represents byte slice and implements Object interface.
func (Bytes) HasMemeber ¶
type BytesBuffer ¶
type BytesBuffer struct {
ObjectImpl
Value *bytes.Buffer
Members map[string]Object `json:"-"`
}
BytesBuffer wraps Go's bytes.Buffer for efficient byte manipulation. It provides a mutable buffer for reading and writing byte data.
Type code: 308.
Key characteristics:
- Wraps Go's bytes.Buffer for efficient byte operations
- Supports Write, Read, Reset, and Bytes operations via methods
- Grows dynamically without reallocation (amortized O(1) append)
- String() returns the buffer content as a string
- Supports member attachment via Members map
func (*BytesBuffer) CallMethod ¶
func (o *BytesBuffer) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*BytesBuffer) CanCall ¶
func (*BytesBuffer) CanCall() bool
func (*BytesBuffer) CanIterate ¶
func (*BytesBuffer) CanIterate() bool
func (*BytesBuffer) Copy ¶
func (o *BytesBuffer) Copy() Object
func (*BytesBuffer) Equal ¶
func (o *BytesBuffer) Equal(right Object) bool
func (*BytesBuffer) GetMember ¶
func (o *BytesBuffer) GetMember(idxA string) Object
func (*BytesBuffer) GetValue ¶
func (o *BytesBuffer) GetValue() Object
func (*BytesBuffer) HasMemeber ¶
func (o *BytesBuffer) HasMemeber() bool
func (*BytesBuffer) IndexGet ¶
func (o *BytesBuffer) IndexGet(index Object) (value Object, err error)
func (*BytesBuffer) IndexSet ¶
func (o *BytesBuffer) IndexSet(index, value Object) error
func (*BytesBuffer) IsFalsy ¶
func (o *BytesBuffer) IsFalsy() bool
func (*BytesBuffer) Iterate ¶
func (*BytesBuffer) Iterate() Iterator
func (*BytesBuffer) String ¶
func (o *BytesBuffer) String() string
func (*BytesBuffer) TypeCode ¶
func (o *BytesBuffer) TypeCode() int
func (*BytesBuffer) TypeName ¶
func (o *BytesBuffer) TypeName() string
type BytesIterator ¶
type BytesIterator struct {
V Bytes
// contains filtered or unexported fields
}
BytesIterator represents an iterator for the bytes.
func (*BytesIterator) Key ¶
func (it *BytesIterator) Key() Object
Key implements Iterator interface.
func (*BytesIterator) Next ¶
func (it *BytesIterator) Next() bool
Next implements Iterator interface.
func (*BytesIterator) Value ¶
func (it *BytesIterator) Value() Object
Value implements Iterator interface.
type Call ¶
Call is a struct to pass arguments to CallEx and CallName methods. It provides VM for various purposes.
Call struct intentionally does not provide access to normal and variadic arguments directly. Using Len() and Get() methods is preferred. It is safe to create Call with a nil VM as long as VM is not required by the callee. Call represents a function call context passed to functions implementing ExCallerObject. It provides access to the VM, 'this' context, arguments, and variadic arguments.
Key characteristics:
- Passed to functions via ValueEx() method for extended call semantics
- Supports method calls with 'This' binding for object-oriented patterns
- Separates regular arguments (Args) from variadic arguments (Vargs)
- Provides helper methods for argument access, validation, and manipulation
func (*Call) CheckLen ¶
CheckLen checks the number of arguments and variadic arguments. If the number of arguments is not equal to n, it returns an error.
func (*Call) Get ¶
Get returns the nth argument. If n is greater than the number of arguments, it returns the nth variadic argument. If n is greater than the number of arguments and variadic arguments, it panics!
type CallableExFunc ¶
CallableExFunc is a function signature for a callable function that accepts a Call struct.
type CallableFunc ¶
CallableFunc is a function signature for a callable function.
func CallExAdapter ¶
func CallExAdapter(fn CallableExFunc) CallableFunc
CallExAdapter converts a CallableExFunc into a CallableFunc.
type Char ¶
type Char rune
Char represents a rune and implements Object interface.
func (Char) HasMemeber ¶
type CharCode ¶
type CharCode struct {
ObjectImpl
Source string
Value *Bytecode
CompilerOptions *CompilerOptions
LastError string
Members map[string]Object `json:"-"`
}
CharCode object is used for represent thent io.Reader type value CharCode represents compiled Charlang bytecode ready for execution. It stores source code, compiled bytecode, compiler options, and error state.
Type code: 191.
Key characteristics:
- Holds compiled Bytecode for VM execution
- Source stores the original source code string
- CompilerOptions control compilation behavior
- LastError stores the most recent compilation error
- Supports member attachment via Members map
func NewCharCode ¶
func NewCharCode(srcA string, optsA ...*CompilerOptions) *CharCode
func (*CharCode) CallMethod ¶
func (*CharCode) CanIterate ¶
func (*CharCode) HasMemeber ¶
type Chars ¶
type Chars []rune
Chars represents byte slice and implements Object interface.
func (Chars) HasMemeber ¶
type CharsIterator ¶
type CharsIterator struct {
V Chars
// contains filtered or unexported fields
}
CharsIterator represents an iterator for the chars.
func (*CharsIterator) Key ¶
func (it *CharsIterator) Key() Object
Key implements Iterator interface.
func (*CharsIterator) Next ¶
func (it *CharsIterator) Next() bool
Next implements Iterator interface.
func (*CharsIterator) Value ¶
func (it *CharsIterator) Value() Object
Value implements Iterator interface.
type CompiledFunction ¶
type CompiledFunction struct {
// number of parameters
NumParams int
// number of local variabls including parameters NumLocals>=NumParams
NumLocals int
Instructions []byte
Variadic bool
Free []*ObjectPtr
// SourceMap holds the index of instruction and token's position.
SourceMap map[int]int
Members map[string]Object `json:"-"`
}
CompiledFunction holds the constants and instructions to pass VM. CompiledFunction represents a compiled Charlang function for VM execution. It contains bytecode instructions, parameter info, free variables, and source mapping.
Type code: 185.
Key characteristics:
- Produced by the Charlang compiler from source code
- NumParams: count of declared parameters
- NumLocals: count of local variables (including parameters)
- Instructions: bytecode for the VM to execute
- Variadic: true if the function accepts variadic arguments
- Free: captured variables for closure support
- SourceMap: instruction index to source position mapping for debugging
- Cannot be called directly; use an Invoker to execute
func (*CompiledFunction) Call ¶
func (*CompiledFunction) Call(...Object) (Object, error)
Call implements Object interface. CompiledFunction is not directly callable. You should use Invoker to call it with a Virtual Machine. Because of this, it always returns an error.
func (*CompiledFunction) CallMethod ¶
func (o *CompiledFunction) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*CompiledFunction) CanCall ¶
func (*CompiledFunction) CanCall() bool
CanCall implements Object interface.
func (*CompiledFunction) CanIterate ¶
func (*CompiledFunction) CanIterate() bool
CanIterate implements Object interface.
func (*CompiledFunction) Copy ¶
func (o *CompiledFunction) Copy() Object
Copy implements the Copier interface.
func (*CompiledFunction) Equal ¶
func (o *CompiledFunction) Equal(right Object) bool
Equal implements Object interface.
func (*CompiledFunction) Fprint ¶
func (o *CompiledFunction) Fprint(w io.Writer)
Fprint writes constants and instructions to given Writer in a human readable form.
func (*CompiledFunction) GetMember ¶
func (o *CompiledFunction) GetMember(idxA string) Object
func (*CompiledFunction) GetValue ¶
func (o *CompiledFunction) GetValue() Object
func (*CompiledFunction) HasMemeber ¶
func (o *CompiledFunction) HasMemeber() bool
func (*CompiledFunction) IndexGet ¶
func (o *CompiledFunction) IndexGet(index Object) (Object, error)
IndexGet represents string values and implements Object interface.
func (*CompiledFunction) IndexSet ¶
func (*CompiledFunction) IndexSet(index, value Object) error
IndexSet implements Object interface.
func (*CompiledFunction) IsFalsy ¶
func (o *CompiledFunction) IsFalsy() bool
IsFalsy implements Object interface.
func (*CompiledFunction) Iterate ¶
func (*CompiledFunction) Iterate() Iterator
Iterate implements Object interface.
func (*CompiledFunction) SetMember ¶
func (o *CompiledFunction) SetMember(idxA string, valueA Object) error
func (*CompiledFunction) SourcePos ¶
func (o *CompiledFunction) SourcePos(ip int) parser.Pos
SourcePos returns the source position of the instruction at ip.
func (*CompiledFunction) String ¶
func (o *CompiledFunction) String() string
func (*CompiledFunction) TypeCode ¶
func (*CompiledFunction) TypeCode() int
func (*CompiledFunction) TypeName ¶
func (*CompiledFunction) TypeName() string
TypeName implements Object interface
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler compiles the AST into a bytecode.
func NewCompiler ¶
func NewCompiler(file *parser.SourceFile, opts CompilerOptions) *Compiler
NewCompiler creates a new Compiler object.
func (*Compiler) SetGlobalSymbolsIndex ¶
func (c *Compiler) SetGlobalSymbolsIndex()
SetGlobalSymbolsIndex sets index of a global symbol. This is only required when a global symbol is defined in SymbolTable and provided to compiler. Otherwise, caller needs to append the constant to Constants, set the symbol index and provide it to the Compiler. This should be called before Compiler.Compile call.
type CompilerError ¶
type CompilerError struct {
FileSet *parser.SourceFileSet
Node parser.Node
Err error
}
CompilerError represents a compiler error.
func (*CompilerError) Error ¶
func (e *CompilerError) Error() string
func (*CompilerError) Unwrap ¶
func (e *CompilerError) Unwrap() error
type CompilerOptions ¶
type CompilerOptions struct {
ModuleMap *ModuleMap
ModulePath string
Constants []Object
SymbolTable *SymbolTable
Trace io.Writer
TraceParser bool
TraceCompiler bool
TraceOptimizer bool
OptimizerMaxCycle int
OptimizeConst bool
OptimizeExpr bool
// contains filtered or unexported fields
}
CompilerOptions represents customizable options for Compile().
var MainCompilerOptions *CompilerOptions = nil
type Copier ¶
type Copier interface {
Copy() Object
}
Copier wraps the Copy method to create a deep copy of the object.
type Database ¶
type Database struct {
ObjectImpl
Value *sql.DB
DBType string
DBConnectString string
Members map[string]Object `json:"-"`
Methods map[string]*Function `json:"-"`
}
Database wraps sql.DB for database operations. It provides connectivity to SQL databases (MySQL, PostgreSQL, SQLite, etc.).
Type code: 309.
Key characteristics:
- Wraps Go's sql.DB for database connectivity
- Supports multiple database types via DBType field
- DBConnectString stores the connection string
- Provides methods for query, exec, and transaction operations
- Methods cache stores dynamically generated function objects
- Supports member attachment via Members map
func (*Database) CallMethod ¶
func (*Database) CanIterate ¶
func (*Database) HasMemeber ¶
type Delegate ¶
type Delegate struct {
// ObjectImpl
Code *CharCode
Value tk.QuickVarDelegate
Members map[string]Object `json:"-"`
}
Delegate represents an function caller and implements Object interface. Delegate wraps a callback delegate for deferred execution. It combines a CharCode with a delegate function for event handling patterns.
Type code: 601.
Key characteristics:
- Combines CharCode with tk.QuickVarDelegate for callbacks
- Used for deferred execution patterns (event handlers, async callbacks)
- Code field stores the associated compiled code
- Value field stores the actual delegate function
- Supports member attachment via Members map
func (*Delegate) CallMethod ¶
func (*Delegate) CanIterate ¶
func (*Delegate) HasMemeber ¶
type Error ¶
Error represents Error Object and implements error and Object interfaces. Error represents a Charlang error object with name, message, and optional cause. It provides structured error handling with member support for additional context.
Type code: 155.
Key characteristics:
- Implements Go's error interface for seamless integration
- Supports error chaining via Cause field (Unwrap method)
- Supports member attachment via Members map
- Name field identifies the error type (e.g., "TypeError", "ValueError")
- Message field contains the human-readable error description
func NewArgumentTypeError ¶
NewArgumentTypeError creates a new Error from ErrType.
func NewCommonError ¶
func NewCommonErrorWithPos ¶
func NewFromError ¶
func NewIndexTypeError ¶
NewIndexTypeError creates a new Error from ErrType.
func NewIndexValueTypeError ¶
NewIndexValueTypeError creates a new Error from ErrType.
func NewOperandTypeError ¶
NewOperandTypeError creates a new Error from ErrType.
func (*Error) CallMethod ¶
func (*Error) HasMemeber ¶
type Eval ¶
type Eval struct {
Locals []Object
Globals Object
Opts CompilerOptions
VM *VM
ModulesCache []Object
}
Eval compiles and runs scripts within same scope. If executed script's return statement has no value to return or return is omitted, it returns last value on stack. Warning: Eval is not safe to use concurrently.
func NewEval ¶
func NewEval(opts CompilerOptions, globals Object, args ...Object) *Eval
NewEval returns new Eval object.
func NewEvalQuick ¶
func NewEvalQuick(globalsA map[string]interface{}, optsA *CompilerOptions, localsA ...Object) *Eval
type EvalMachine ¶
EvalMachine represents an Charlang Virtual Machine could run script once or more EvalMachine wraps Eval for expression evaluation with variable context. It provides a calculator-like evaluation engine with variable storage.
Type code: 888.
Key characteristics:
- Wraps Eval for mathematical and logical expression evaluation
- Supports variable assignment and retrieval
- Provides functions for parsing and evaluating expressions
- Can be used for dynamic formula evaluation
- Supports member attachment via Members map
func (*EvalMachine) CallMethod ¶
func (o *EvalMachine) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*EvalMachine) CanCall ¶
func (o *EvalMachine) CanCall() bool
func (*EvalMachine) CanIterate ¶
func (*EvalMachine) CanIterate() bool
func (*EvalMachine) Equal ¶
func (o *EvalMachine) Equal(right Object) bool
func (*EvalMachine) GetMember ¶
func (o *EvalMachine) GetMember(idxA string) Object
func (*EvalMachine) GetValue ¶
func (o *EvalMachine) GetValue() Object
func (*EvalMachine) HasMemeber ¶
func (o *EvalMachine) HasMemeber() bool
func (*EvalMachine) IndexSet ¶
func (o *EvalMachine) IndexSet(index, value Object) error
func (*EvalMachine) IsFalsy ¶
func (o *EvalMachine) IsFalsy() bool
func (*EvalMachine) Iterate ¶
func (*EvalMachine) Iterate() Iterator
func (*EvalMachine) SetValue ¶
func (o *EvalMachine) SetValue(valueA Object) error
func (*EvalMachine) String ¶
func (o *EvalMachine) String() string
func (*EvalMachine) TypeCode ¶
func (*EvalMachine) TypeCode() int
func (*EvalMachine) TypeName ¶
func (*EvalMachine) TypeName() string
type ExCallerObject ¶
ExCallerObject is an interface for objects that can be called with CallEx method. It is an extended version of the Call method that can be used to call an object with a Call struct. Objects implementing this interface is called with CallEx method instead of Call method. Note that CanCall() should return true for objects implementing this interface.
type Excel ¶
Excel represents an Excel(or compatible) file and implements Object interface. Excel wraps excelize.File for Excel spreadsheet operations. It provides reading, writing, and manipulation of .xlsx files.
Type code: 1003.
Key characteristics:
- Wraps excelize.File for Excel file operations
- Supports reading, writing, and modifying .xlsx files
- Provides methods for cell access, formulas, charts, and styling
- Can create new workbooks or open existing ones
- Supports member attachment via Members map
func (*Excel) CallMethod ¶
func (*Excel) CanIterate ¶
func (*Excel) HasMemeber ¶
type ExtImporter ¶
type ExtImporter interface {
Importable
// Get returns Extimporter instance which will import a module.
Get(moduleName string) ExtImporter
// Name returns the full name of the module e.g. absoule path of a file.
// Import names are generally relative, this overwrites module name and used
// as unique key for compiler module cache.
Name() string
// Fork returns an ExtImporter instance which will be used to import the
// modules. Fork will get the result of Name() if it is not empty, otherwise
// module name will be same with the Get call.
Fork(moduleName string) ExtImporter
}
ExtImporter wraps methods for a module which will be imported dynamically like a file.
type File ¶
type File struct {
ObjectImpl
Value *os.File
Members map[string]Object `json:"-"`
}
File object is used for represent os.File type value File wraps os.File for file system operations. It provides read, write, seek, and close operations on files.
Type code: 401.
Key characteristics:
- Wraps Go's os.File for file I/O operations
- Supports reading, writing, seeking, and closing
- Can be used as Reader (via Read method) or Writer (via Write method)
- Supports member attachment via Members map
func (*File) CanIterate ¶
func (*File) HasMemeber ¶
type Float ¶
type Float float64
Float represents float values and implements Object interface.
func (Float) HasMemeber ¶
type Function ¶
type Function struct {
ObjectImpl
Name string
Value func(args ...Object) (Object, error)
ValueEx func(Call) (Object, error)
Members map[string]Object `json:"-"`
}
Function represents a function object and implements Object interface. Function represents a user-defined or dynamically created function object. It encapsulates a Go function that receives Object arguments and returns an Object.
Type code: 181.
Key characteristics:
- Implements ExCallerObject interface, supporting extended call context
- Two call modes: Value (simple args) and ValueEx (full Call access)
- ValueEx takes precedence if both Value and ValueEx are set
- Supports member attachment via Members map
- Name field identifies the function for debugging/error messages
Usage:
fn := &Function{
Name: "myFunc",
Value: func(args ...Object) (Object, error) {
return &Int{Value: 42}, nil
},
}
func (*Function) CallMethod ¶
func (*Function) CanIterate ¶
func (*Function) HasMemeber ¶
type Gel ¶
type Gel struct {
ObjectImpl
// Source string
Value *CharCode
Members map[string]Object `json:"-"`
}
Gel object is like modules based on CharCode object Gel wraps CharCode for compiled code execution with VM. It provides a convenient interface for running compiled scripts.
Type code: 193.
Key characteristics:
- Wraps CharCode for script execution
- Provides Run methods for executing compiled code
- Can be created from source code string
- Supports member attachment via Members map
func (*Gel) CanIterate ¶
func (*Gel) HasMemeber ¶
type GlobalContext ¶
type GlobalContext struct {
SyncMap tk.SyncMap
SyncQueue tk.SyncQueue
SyncStack tk.SyncStack
SyncSeq tk.Seq
Vars map[string]interface{}
Regs []interface{}
VerboseLevel int
}
var GlobalsG *GlobalContext
type HttpHandler ¶
type HttpHandler struct {
// ObjectImpl
Value func(http.ResponseWriter, *http.Request)
Members map[string]Object `json:"-"`
}
HttpHandler object is used to represent the http response HttpHandler wraps an HTTP handler function for use with Mux routing. It encapsulates a function that handles HTTP requests.
Type code: 325.
Key characteristics:
- Wraps http.HandlerFunc for HTTP request handling
- Used with Mux.Handle() for route registration
- Function signature: func(http.ResponseWriter, *http.Request)
- Supports member attachment via Members map
func (*HttpHandler) CallMethod ¶
func (o *HttpHandler) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*HttpHandler) CanCall ¶
func (o *HttpHandler) CanCall() bool
func (*HttpHandler) CanIterate ¶
func (*HttpHandler) CanIterate() bool
func (*HttpHandler) Equal ¶
func (o *HttpHandler) Equal(right Object) bool
func (*HttpHandler) GetMember ¶
func (o *HttpHandler) GetMember(idxA string) Object
func (*HttpHandler) GetValue ¶
func (o *HttpHandler) GetValue() Object
func (*HttpHandler) HasMemeber ¶
func (o *HttpHandler) HasMemeber() bool
func (*HttpHandler) IndexSet ¶
func (o *HttpHandler) IndexSet(index, value Object) error
func (*HttpHandler) IsFalsy ¶
func (o *HttpHandler) IsFalsy() bool
func (*HttpHandler) Iterate ¶
func (o *HttpHandler) Iterate() Iterator
func (*HttpHandler) String ¶
func (o *HttpHandler) String() string
func (*HttpHandler) TypeCode ¶
func (*HttpHandler) TypeCode() int
func (*HttpHandler) TypeName ¶
func (*HttpHandler) TypeName() string
TypeName implements Object interface.
type HttpReq ¶
type HttpReq struct {
ObjectImpl
Value *http.Request
Members map[string]Object `json:"-"`
}
HttpReq object is used to represent the http request HttpReq wraps http.Request for HTTP request handling. It provides access to request method, URL, headers, body, and parameters.
Type code: 321.
Key characteristics:
- Wraps Go's http.Request for HTTP request data access
- Provides methods for accessing query params, form data, headers
- Supports body reading via io.Reader interface
- Used in HTTP handler functions with HttpResp
- Supports member attachment via Members map
func (*HttpReq) CallMethod ¶
func (*HttpReq) CanIterate ¶
func (*HttpReq) HasMemeber ¶
type HttpResp ¶
type HttpResp struct {
ObjectImpl
Value http.ResponseWriter
Members map[string]Object `json:"-"`
}
HttpResp object is used to represent the http response HttpResp wraps http.ResponseWriter for HTTP response handling. It provides methods for writing response data, headers, and status codes.
Type code: 323.
Key characteristics:
- Wraps Go's http.ResponseWriter for HTTP response writing
- Implements io.Writer interface for direct writing
- Provides methods for setting headers, status codes, and cookies
- Used in HTTP handler functions with HttpReq
- Supports member attachment via Members map
func (*HttpResp) CallMethod ¶
func (*HttpResp) CanIterate ¶
func (*HttpResp) HasMemeber ¶
type Image ¶
Image represents an image and implements Object interface. Image wraps image.Image for image processing operations. It provides access to pixel data, dimensions, and format information.
Type code: 501.
Key characteristics:
- Wraps Go's image.Image for image data handling
- Supports various image formats (PNG, JPEG, GIF, etc.)
- Provides methods for accessing pixel data and dimensions
- Can be created from file, bytes, or decoded data
- Supports member attachment via Members map
func (*Image) CallMethod ¶
func (*Image) CanIterate ¶
func (*Image) HasMemeber ¶
type Importable ¶
type Importable interface {
// Import should return either an Object or module source code ([]byte).
Import(moduleName string) (interface{}, error)
}
Importable interface represents importable module instance.
type IndexDeleter ¶
IndexDeleter wraps the IndexDelete method to delete an index of an object.
type Int ¶
type Int int64
Int represents signed integer values and implements Object interface.
func ToIntObject ¶
func (Int) HasMemeber ¶
type IntIterator ¶
type IntIterator struct {
V Int
// contains filtered or unexported fields
}
IntIterator represents an iterator for the Int.
func (*IntIterator) Value ¶
func (it *IntIterator) Value() Object
Value implements Iterator interface.
type Invoker ¶
type Invoker struct {
// contains filtered or unexported fields
}
Invoker invokes a given callee object (either a CompiledFunction or any other callable object) with the given arguments.
Invoker creates a new VM instance if the callee is a CompiledFunction, otherwise it runs the callee directly. Every Invoker call checks if the VM is aborted. If it is, it returns ErrVMAborted.
Invoker is not safe for concurrent use by multiple goroutines.
Acquire and Release methods are used to acquire and release a VM from the pool. So it is possible to reuse a VM instance for multiple Invoke calls. This is useful when you want to execute multiple functions in a single VM. For example, you can use Acquire and Release to execute multiple functions in a single VM instance. Note that you should call Release after Acquire, if you want to reuse the VM. If you don't want to use the pool, you can just call Invoke method. It is unsafe to hold a reference to the VM after Release is called. Using VM pool is about three times faster than creating a new VM for each Invoke call.
func NewInvoker ¶
NewInvoker creates a new Invoker object.
type Iterator ¶
type Iterator interface {
// Next returns true if there are more elements to iterate.
Next() bool
// Key returns the key or index value of the current element.
Key() Object
// Value returns the value of the current element.
Value() Object
}
Iterator wraps the methods required to iterate Objects in VM.
type JsVm ¶
JsVm represents an JavaScript Virtual Machine could run script once or more JsVm wraps goja.Runtime for JavaScript execution within Charlang. It provides a JavaScript VM for running JS code alongside Charlang.
Type code: 711.
Key characteristics:
- Wraps goja.Runtime for JavaScript execution
- Supports running JavaScript code from Charlang
- Can exchange data between Charlang and JavaScript contexts
- Provides methods for setting/getting JS variables and calling functions
- Supports member attachment via Members map
func (*JsVm) CanIterate ¶
func (*JsVm) HasMemeber ¶
type LengthGetter ¶
type LengthGetter interface {
Len() int
}
LengthGetter wraps the Len method to get the number of elements of an object.
type Location ¶
type Location struct {
ObjectImpl
Value *time.Location
Members map[string]Object `json:"-"`
}
Location represents a timezone location for time operations. It wraps Go's time.Location and is used with Time objects for timezone conversions.
Type code: 313.
Key characteristics:
- Wraps Go's time.Location for timezone handling
- Loaded by IANA timezone identifiers (e.g., "UTC", "America/New_York")
- Used with Time objects for timezone-aware operations
- Supports member attachment via Members map
func ToLocation ¶
ToLocation will try to convert given Object to *Location value.
func (*Location) CallMethod ¶
func (*Location) HasMemeber ¶
type Map ¶
Map represents map of objects and implements Object interface.
func NewBaseEnv ¶
func (Map) HasMemeber ¶
func (Map) IndexDelete ¶
IndexDelete tries to delete the string value of key from the map. IndexDelete implements IndexDeleter interface.
type MapArray ¶
type MapArray struct {
Value *tk.SimpleFlexObject
}
MapArray represents an SimpleFlexObject which is an array with some items have keys MapArray wraps tk.SimpleFlexObject for hybrid map-array storage. It combines the features of both map and array for flexible data access.
Type code: 136.
Key characteristics:
- Wraps tk.SimpleFlexObject for hybrid map/array operations
- Supports both indexed (array-like) and keyed (map-like) access
- Provides flexible data structure for dynamic content
- Useful for JSON-like data with mixed access patterns
func (*MapArray) CallMethod ¶
func (*MapArray) CanIterate ¶
func (*MapArray) HasMemeber ¶
type MapArrayIterator ¶
type MapArrayIterator struct {
V *MapArray
// contains filtered or unexported fields
}
MapArrayIterator represents an iterator for the array.
func (*MapArrayIterator) Key ¶
func (it *MapArrayIterator) Key() Object
Key implements Iterator interface.
func (*MapArrayIterator) Next ¶
func (it *MapArrayIterator) Next() bool
Next implements Iterator interface.
func (*MapArrayIterator) Value ¶
func (it *MapArrayIterator) Value() Object
Value implements Iterator interface.
type MapIterator ¶
type MapIterator struct {
V Map
// contains filtered or unexported fields
}
MapIterator represents an iterator for the map.
func (*MapIterator) Value ¶
func (it *MapIterator) Value() Object
Value implements Iterator interface.
type ModuleMap ¶
type ModuleMap struct {
// contains filtered or unexported fields
}
ModuleMap represents a set of named modules. Use NewModuleMap to create a new module map.
func (*ModuleMap) Add ¶
func (m *ModuleMap) Add(name string, module Importable) *ModuleMap
Add adds an importable module.
func (*ModuleMap) AddBuiltinModule ¶
AddBuiltinModule adds a builtin module.
func (*ModuleMap) AddSourceModule ¶
AddSourceModule adds a source module.
func (*ModuleMap) Fork ¶
Fork creates a new ModuleMap instance if ModuleMap has an ExtImporter to make ExtImporter preseve state.
func (*ModuleMap) Get ¶
func (m *ModuleMap) Get(name string) Importable
Get returns an import module identified by name. It returns nil if the name is not found.
func (*ModuleMap) SetExtImporter ¶
func (m *ModuleMap) SetExtImporter(im ExtImporter) *ModuleMap
SetExtImporter sets an ExtImporter to ModuleMap, which will be used to import modules dynamically.
type MutableString ¶
type MutableString struct {
ObjectImpl
Value string
Members map[string]Object `json:"-"`
}
MutableString represents string values and implements Object interface, compare to String, it supports setValue method. MutableString represents a mutable string that can be modified in place. Unlike String (immutable), MutableString allows character-level modification.
Type code: 106.
Key characteristics:
- Mutable counterpart to the immutable String type
- Supports index-based read and write of characters
- Implements LengthGetter and ValueSetter interfaces
- String() returns the current string value
- Supports member attachment via Members map
func ToMutableStringObject ¶
func ToMutableStringObject(argA interface{}) *MutableString
func (*MutableString) Call ¶
func (o *MutableString) Call(_ ...Object) (Object, error)
Call implements Object interface.
func (*MutableString) CallMethod ¶
func (o *MutableString) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*MutableString) CallName ¶
func (o *MutableString) CallName(nameA string, c Call) (Object, error)
func (*MutableString) CanCall ¶
func (o *MutableString) CanCall() bool
CanCall implements Object interface.
func (*MutableString) CanIterate ¶
func (*MutableString) CanIterate() bool
CanIterate implements Object interface.
func (*MutableString) Copy ¶
func (o *MutableString) Copy() Object
func (*MutableString) Equal ¶
func (o *MutableString) Equal(right Object) bool
Equal implements Object interface.
func (*MutableString) Format ¶
func (o *MutableString) Format(s fmt.State, verb rune)
Format implements fmt.Formatter interface.
func (*MutableString) GetMember ¶
func (o *MutableString) GetMember(idxA string) Object
func (*MutableString) GetValue ¶
func (o *MutableString) GetValue() Object
func (*MutableString) HasMemeber ¶
func (o *MutableString) HasMemeber() bool
func (*MutableString) IndexGet ¶
func (o *MutableString) IndexGet(index Object) (Object, error)
IndexGet represents string values and implements Object interface.
func (*MutableString) IndexSet ¶
func (o *MutableString) IndexSet(index, value Object) error
IndexSet implements Object interface.
func (*MutableString) IsFalsy ¶
func (o *MutableString) IsFalsy() bool
IsFalsy implements Object interface.
func (*MutableString) Iterate ¶
func (o *MutableString) Iterate() Iterator
Iterate implements Object interface.
func (*MutableString) Len ¶
func (o *MutableString) Len() int
Len implements LengthGetter interface.
func (*MutableString) MarshalJSON ¶
func (o *MutableString) MarshalJSON() ([]byte, error)
func (*MutableString) SetMember ¶
func (o *MutableString) SetMember(idxA string, valueA Object) error
func (*MutableString) SetValue ¶
func (o *MutableString) SetValue(valueA Object) error
func (*MutableString) String ¶
func (o *MutableString) String() string
func (*MutableString) TypeCode ¶
func (*MutableString) TypeCode() int
func (*MutableString) TypeName ¶
func (*MutableString) TypeName() string
TypeName implements Object interface.
type MutableStringIterator ¶
type MutableStringIterator struct {
V *MutableString
// contains filtered or unexported fields
}
MutableStringIterator represents an iterator for the string.
func (*MutableStringIterator) Key ¶
func (it *MutableStringIterator) Key() Object
Key implements Iterator interface.
func (*MutableStringIterator) Next ¶
func (it *MutableStringIterator) Next() bool
Next implements Iterator interface.
func (*MutableStringIterator) Value ¶
func (it *MutableStringIterator) Value() Object
Value implements Iterator interface.
type Mutex ¶
type Mutex struct {
ObjectImpl
Value *(sync.RWMutex)
Members map[string]Object `json:"-"`
}
Mutex object is used for thread-safe actions note that the members set/get operations are not thread-safe Mutex wraps sync.RWMutex for thread-safe mutual exclusion. It provides Lock, Unlock, RLock, RUnlock operations for concurrency control.
Type code: 317.
Key characteristics:
- Wraps Go's sync.RWMutex for reader-writer locking
- Supports exclusive (Lock/Unlock) and shared (RLock/RUnlock) access
- Essential for protecting shared resources in concurrent code
- Supports member attachment via Members map
func (*Mutex) CallMethod ¶
func (*Mutex) CanIterate ¶
func (*Mutex) HasMemeber ¶
type Mux ¶
type Mux struct {
ObjectImpl
Value *http.ServeMux
Members map[string]Object `json:"-"`
}
Mux object is used for http handlers Mux wraps http.ServeMux for HTTP request routing. It provides pattern-based routing for HTTP server handlers.
Type code: 319.
Key characteristics:
- Wraps Go's http.ServeMux for HTTP routing
- Supports Handle and HandleFunc methods for route registration
- Used with HttpHandler and HttpServer for HTTP services
- Supports member attachment via Members map
func (*Mux) CanIterate ¶
func (*Mux) HasMemeber ¶
type NameCallerObject ¶
NameCallerObject is an interface for objects that can be called with CallName method to call a method of an object. Objects implementing this interface can reduce allocations by not creating a callable object for each method call.
type Object ¶
type Object interface {
// TypeName should return the name of the type.
TypeName() string
// TypeCode should return the code of the type.
TypeCode() int
// String should return a string of the type's value.
String() string
// BinaryOp handles +,-,*,/,%,<<,>>,<=,>=,<,> operators.
// Returned error stops VM execution if not handled with an error handler
// and VM.Run returns the same error as wrapped.
BinaryOp(tok token.Token, right Object) (Object, error)
// IsFalsy returns true if value is falsy otherwise false.
IsFalsy() bool
// Equal checks equality of objects.
Equal(right Object) bool
// Call is called from VM if CanCall() returns true. Check the number of
// arguments provided and their types in the method. Returned error stops VM
// execution if not handled with an error handler and VM.Run returns the
// same error as wrapped.
Call(args ...Object) (Object, error)
// CanCall returns true if type can be called with Call() method.
// VM returns an error if one tries to call a noncallable object.
CanCall() bool
// Iterate should return an Iterator for the type.
Iterate() Iterator
// CanIterate should return whether the Object can be Iterated.
CanIterate() bool
// IndexGet should take an index Object and return a result Object or an
// error for indexable objects. Indexable is an object that can take an
// index and return an object. Returned error stops VM execution if not
// handled with an error handler and VM.Run returns the same error as
// wrapped. If Object is not indexable, ErrNotIndexable should be returned
// as error.
IndexGet(index Object) (value Object, err error)
// IndexSet should take an index Object and a value Object for index
// assignable objects. Index assignable is an object that can take an index
// and a value on the left-hand side of the assignment statement. If Object
// is not index assignable, ErrNotIndexAssignable should be returned as
// error. Returned error stops VM execution if not handled with an error
// handler and VM.Run returns the same error as wrapped.
IndexSet(index, value Object) error
GetValue() Object
HasMemeber() bool
GetMember(string) Object
SetMember(string, Object) error
CallMethod(string, ...Object) (Object, error)
}
Object represents an object in the VM.
var ( // Undefined represents undefined value. Undefined Object = &UndefinedType{} )
func BuiltinDbCloseFunc ¶
BuiltinDbCloseFunc closes a database connection. It should be called after completing database operations to release resources. Failing to close database connections may lead to resource leaks.
Parameters:
- db: The database connection object (*Database)
Returns:
nil on success, or an error if the close operation fails.
Examples:
db := dbConnect("sqlite3", "test.db")
// ... perform database operations ...
dbClose(db)
func BuiltinDealStrFunc ¶
BuiltinDealStrFunc decodes/decrypts tagged string formats.
func BuiltinDelegateFunc ¶
BuiltinDelegateFunc creates a Delegate object.
func BuiltinFuzzyFindFunc ¶
BuiltinFuzzyFindFunc performs fuzzy search on string or string list.
func CallObjectMethodFunc ¶
func ConvertToObject ¶
func ConvertToObject(vA interface{}) Object
func GenStatusResult ¶
func NewBigFloat ¶
func NewBytesBuffer ¶
func NewDelegate ¶
func NewEvalMachine ¶
func NewExternalDelegate ¶
func NewExternalDelegate(funcA func(...interface{}) interface{}) Object
func NewHttpHandler ¶
func NewHttpReq ¶
func NewMapArray ¶
func NewOrderedMap ¶
func NewWebSocket ¶
func ToObjectAlt ¶
ToObjectAlt is analogous to ToObject but it will always convert signed integers to Int and unsigned integers to Uint. It is an alternative to ToObject. Note that, this function is subject to change in the future.
type ObjectImpl ¶
type ObjectImpl struct {
}
ObjectImpl is the basic Object implementation and it does not nothing, and helps to implement Object interface by embedding and overriding methods in custom implementations. String and TypeName must be implemented otherwise calling these methods causes panic. ObjectImpl provides a basic Object implementation that does nothing. It can be embedded in custom types to partially implement the Object interface. Types embedding ObjectImpl must override TypeName() and String() methods, otherwise calling these methods will panic with ErrNotImplemented.
Type code: N/A (base implementation, not instantiable as standalone type).
Key characteristics:
- Provides default implementations for all Object interface methods
- TypeCode(), TypeName(), String() panic with ErrNotImplemented
- HasMemeber() returns false, IsFalsy() returns true
- CanCall() returns false, CanIterate() returns false
- Equal() returns false, IndexGet/Set return appropriate errors
- BinaryOp() returns ErrInvalidOperator
func (ObjectImpl) Call ¶
func (ObjectImpl) Call(_ ...Object) (Object, error)
Call implements Object interface.
func (ObjectImpl) CallMethod ¶
func (o ObjectImpl) CallMethod(nameA string, argsA ...Object) (Object, error)
func (ObjectImpl) CanIterate ¶
func (ObjectImpl) CanIterate() bool
CanIterate implements Object interface.
func (ObjectImpl) GetMember ¶
func (o ObjectImpl) GetMember(idxA string) Object
func (ObjectImpl) GetValue ¶
func (o ObjectImpl) GetValue() Object
func (ObjectImpl) HasMemeber ¶
func (o ObjectImpl) HasMemeber() bool
func (ObjectImpl) IndexGet ¶
func (o ObjectImpl) IndexGet(index Object) (value Object, err error)
IndexGet implements Object interface.
func (ObjectImpl) IndexSet ¶
func (o ObjectImpl) IndexSet(index, value Object) error
IndexSet implements Object interface.
func (ObjectImpl) Iterate ¶
func (ObjectImpl) Iterate() Iterator
Iterate implements Object interface.
func (ObjectImpl) TypeCode ¶
func (ObjectImpl) TypeCode() int
func (ObjectImpl) TypeName ¶
func (ObjectImpl) TypeName() string
TypeName implements Object interface.
type ObjectPtr ¶
type ObjectPtr struct {
ObjectImpl
Value *Object
Members map[string]Object `json:"-"`
}
ObjectPtr represents a pointer to an Object, enabling pass-by-reference semantics. It allows modification of shared objects across different contexts.
Type code: 151.
Key characteristics:
- Internal use only; for common purpose, use ObjectRef instead
- Holds a pointer to an Object (*Object), not the Object itself
- Enables pass-by-reference semantics in Charlang
- "value" method dereferences and returns the pointed-to object
- Supports member attachment via Members map
func (*ObjectPtr) CallMethod ¶
func (*ObjectPtr) HasMemeber ¶
type ObjectRef ¶
type ObjectRef struct {
ObjectImpl
Value *Object
Members map[string]Object `json:"-"`
}
ObjectRef represents a reference variable. always refer to an Object(i.e. *Object) ObjectRef represents a reference variable that points to another Object. It wraps a pointer to an Object (*Object) allowing indirect access and modification.
Type code: 152.
Key characteristics:
- Wraps a pointer to Object (*Object) for reference semantics
- Delegates operations (BinaryOp, CanCall, Call) to the referenced object
- Copier interface returns self (references are not deep-copied)
- "value" method dereferences and returns the pointed-to object
- Supports member attachment via Members map
func (*ObjectRef) CallMethod ¶
func (*ObjectRef) HasMemeber ¶
type Opcode ¶
type Opcode = byte
Opcode represents a single byte operation code for the VM.
const ( // OpNoOp is a no-operation instruction. OpNoOp Opcode = iota // OpConstant pushes a constant from the constant pool onto the stack. // Operands: [2] - constant index (0-65535) OpConstant // OpCall calls a function with the specified number of arguments. // Operands: [1, 1] - argument count, flags OpCall // OpGetGlobal retrieves a global variable by name and pushes it onto the stack. // Operands: [2] - constant index (variable name) OpGetGlobal // OpSetGlobal sets a global variable by name to the value on top of stack. // Operands: [2] - constant index (variable name) OpSetGlobal // OpGetLocal retrieves a local variable by index and pushes it onto the stack. // Operands: [1] - local variable index OpGetLocal // OpSetLocal sets a local variable by index to the value on top of stack. // Operands: [1] - local variable index OpSetLocal // OpGetBuiltin retrieves a built-in function by index and pushes it onto the stack. // Operands: [2] - builtin function index OpGetBuiltin // OpBinaryOp performs a binary operation on the top two stack values. // Operands: [1] - operator token OpBinaryOp // OpUnary performs a unary operation on the top stack value. // Operands: [1] - operator token OpUnary // OpEqual checks equality of the top two stack values and pushes the result. OpEqual // OpNotEqual checks inequality of the top two stack values and pushes the result. OpNotEqual // OpJump unconditionally jumps to the specified instruction position. // Operands: [2] - instruction position OpJump // OpJumpFalsy jumps to the specified position if the top of stack is falsy. // Operands: [2] - instruction position OpJumpFalsy // OpAndJump implements short-circuit AND: jumps if top of stack is falsy. // Operands: [2] - instruction position OpAndJump // OpOrJump implements short-circuit OR: jumps if top of stack is truthy. // Operands: [2] - instruction position OpOrJump // OpMap creates a new map with the specified number of key-value pairs. // Operands: [2] - number of pairs OpMap // OpArray creates a new array with the specified number of elements. // Operands: [2] - number of elements OpArray // OpSliceIndex performs a slice operation [start:end] on the top value. OpSliceIndex // OpGetIndex retrieves a value by index from the collection on the stack. // Operands: [1] - number of selectors (for chained access) OpGetIndex // OpSetIndex sets a value by index in the collection on the stack. OpSetIndex // OpNull pushes Undefined onto the stack. OpNull // OpPop removes and discards the top value from the stack. OpPop // OpGetFree retrieves a free variable (from enclosing scope) by index. // Operands: [1] - free variable index OpGetFree // OpSetFree sets a free variable by index to the value on top of stack. // Operands: [1] - free variable index OpSetFree // OpGetLocalPtr gets a pointer to a local variable for reference semantics. // Operands: [1] - local variable index OpGetLocalPtr // OpGetFreePtr gets a pointer to a free variable for reference semantics. // Operands: [1] - free variable index OpGetFreePtr // OpClosure creates a closure from a compiled function with captured variables. // Operands: [2, 1] - constant index (function), number of free variables OpClosure // OpIterInit initializes an iterator for the collection on top of stack. OpIterInit // OpIterNext advances the iterator and pushes the next value (or null if done). OpIterNext // OpIterKey pushes the current key from the iterator onto the stack. OpIterKey // OpIterValue pushes the current value from the iterator onto the stack. OpIterValue // OpLoadModule loads a module by name and pushes it onto the stack. // Operands: [2, 2] - constant index (module name), module index OpLoadModule // OpStoreModule stores the top of stack as a module with the given name. // Operands: [2] - constant index (module name) OpStoreModule // OpSetupTry sets up a try block for exception handling. // Operands: [2, 2] - catch position, finally position OpSetupTry // OpSetupCatch sets up a catch block to handle exceptions. OpSetupCatch // OpSetupFinally sets up a finally block for cleanup code. OpSetupFinally // OpThrow throws an exception (re-throws if operand is 0). // Operands: [1] - 0 for re-throw, 1 for throw expression OpThrow // OpFinalizer handles cleanup after exception handling. // Operands: [1] - error handler index OpFinalizer // OpReturn returns from the current function with the top of stack. // Operands: [1] - number of return values (0 or 1) OpReturn // OpDefineLocal defines a new local variable at the specified index. // Operands: [1] - local variable index OpDefineLocal // OpTrue pushes the boolean value true onto the stack. OpTrue // OpFalse pushes the boolean value false onto the stack. OpFalse // OpCallName calls a method by name on the object on top of stack. // Operands: [1, 1] - argument count, flags OpCallName )
List of opcodes. Each opcode is a single byte value. See OpcodeOperands for the operand specification of each opcode.
type OptimizerError ¶
type OptimizerError struct {
FilePos parser.SourceFilePos
Node parser.Node
Err error
}
OptimizerError represents an optimizer error.
func (*OptimizerError) Error ¶
func (e *OptimizerError) Error() string
func (*OptimizerError) Unwrap ¶
func (e *OptimizerError) Unwrap() error
type OrderedMap ¶
type OrderedMap struct {
ObjectImpl
Value *tk.OrderedMap
}
OrderedMap represents map of objects but has order(in the order of push-in) and implements Object interface. OrderedMap wraps tk.OrderedMap for ordered key-value storage. Unlike Map, OrderedMap preserves insertion order during iteration.
Type code: 195.
Key characteristics:
- Wraps tk.OrderedMap for order-preserving map operations
- Maintains insertion order during iteration
- Implements IndexDeleter, Copier, and LengthGetter interfaces
- Keys are strings; values are Objects
func (*OrderedMap) Call ¶
func (*OrderedMap) Call(...Object) (Object, error)
Call implements Object interface.
func (*OrderedMap) CallMethod ¶
func (o *OrderedMap) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*OrderedMap) CanIterate ¶
func (*OrderedMap) CanIterate() bool
CanIterate implements Object interface.
func (*OrderedMap) Equal ¶
func (o *OrderedMap) Equal(right Object) bool
Equal implements Object interface.
func (*OrderedMap) GetMember ¶
func (o *OrderedMap) GetMember(idxA string) Object
func (*OrderedMap) GetValue ¶
func (o *OrderedMap) GetValue() Object
func (*OrderedMap) HasMemeber ¶
func (o *OrderedMap) HasMemeber() bool
func (*OrderedMap) IndexDelete ¶
func (o *OrderedMap) IndexDelete(key Object) error
IndexDelete tries to delete the string value of key from the map. IndexDelete implements IndexDeleter interface.
func (*OrderedMap) IndexGet ¶
func (o *OrderedMap) IndexGet(index Object) (Object, error)
IndexGet implements Object interface.
func (*OrderedMap) IndexSet ¶
func (o *OrderedMap) IndexSet(index, value Object) error
IndexSet implements Object interface.
func (*OrderedMap) IsFalsy ¶
func (o *OrderedMap) IsFalsy() bool
IsFalsy implements Object interface.
func (*OrderedMap) Iterate ¶
func (o *OrderedMap) Iterate() Iterator
Iterate implements Iterable interface.
func (*OrderedMap) String ¶
func (o *OrderedMap) String() string
String implements Object interface.
func (*OrderedMap) TypeCode ¶
func (*OrderedMap) TypeCode() int
func (*OrderedMap) TypeName ¶
func (*OrderedMap) TypeName() string
TypeName implements Object interface.
type OrderedMapIterator ¶
type OrderedMapIterator struct {
V *OrderedMap
// contains filtered or unexported fields
}
OrderedMapIterator represents an iterator for the map.
func (*OrderedMapIterator) Key ¶
func (it *OrderedMapIterator) Key() Object
Key implements Iterator interface.
func (*OrderedMapIterator) Next ¶
func (it *OrderedMapIterator) Next() bool
Next implements Iterator interface.
func (*OrderedMapIterator) Value ¶
func (it *OrderedMapIterator) Value() Object
Value implements Iterator interface.
type Queue ¶
type Queue struct {
ObjectImpl
Value *tk.AnyQueue
Members map[string]Object `json:"-"`
}
Queue represents a generic FIFO queue object and implements Object interface. Queue wraps tk.AnyQueue for FIFO (First-In-First-Out) data structure. It provides enqueue, dequeue, and peek operations for queue-based algorithms.
Type code: 323.
Key characteristics:
- Wraps tk.AnyQueue for FIFO operations
- Implements LengthGetter interface for size queries
- Supports Enqueue, Dequeue, Peek, and Clear operations
- Generic container for Object values
- Supports member attachment via Members map
func (*Queue) CallMethod ¶
func (*Queue) HasMemeber ¶
type QueueIterator ¶
type QueueIterator struct {
V *Queue
// contains filtered or unexported fields
}
QueueIterator represents an iterator for the Queue.
func (*QueueIterator) Key ¶
func (it *QueueIterator) Key() Object
Key implements Iterator interface.
func (*QueueIterator) Next ¶
func (it *QueueIterator) Next() bool
Next implements Iterator interface.
func (*QueueIterator) Value ¶
func (it *QueueIterator) Value() Object
Value implements Iterator interface.
type RSAEncryption ¶
type RSAEncryption struct {
// contains filtered or unexported fields
}
type Reader ¶
type Reader struct {
ObjectImpl
Value io.Reader
SizeM int // may be not set
CloseDele tk.QuickVarDelegate
Members map[string]Object `json:"-"`
}
Reader object is used for represent io.Reader type value Reader wraps io.Reader for reading data from various sources. It implements io.ReadCloser interface for stream-based reading.
Type code: 331.
Key characteristics:
- Wraps any io.Reader (files, network connections, buffers, etc.)
- Implements io.ReadCloser interface
- SizeM field optionally stores expected content size
- CloseDele provides optional close callback delegate
- Supports member attachment via Members map
func (*Reader) CallMethod ¶
func (*Reader) CanIterate ¶
func (*Reader) HasMemeber ¶
type RuntimeError ¶
type RuntimeError struct {
Err *Error
Trace []parser.Pos
Members map[string]Object `json:"-"`
// contains filtered or unexported fields
}
RuntimeError represents a runtime error that wraps Error and includes trace information. RuntimeError represents a Charlang runtime error with stack trace information. It wraps an Error with source position tracking for debugging.
Type code: 157.
Key characteristics:
- Wraps an Error with source file set and position trace
- Provides stack trace for debugging via Trace field
- fileSet enables resolution of positions to file:line:column
- Supports member attachment via Members map
- TypeName() returns "error" (same as Error for type checking)
func (*RuntimeError) Call ¶
func (*RuntimeError) Call(_ ...Object) (Object, error)
Call implements Object interface.
func (*RuntimeError) CallMethod ¶
func (o *RuntimeError) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*RuntimeError) CanCall ¶
func (*RuntimeError) CanCall() bool
CanCall implements Object interface.
func (*RuntimeError) CanIterate ¶
func (*RuntimeError) CanIterate() bool
CanIterate implements Object interface.
func (*RuntimeError) Equal ¶
func (o *RuntimeError) Equal(right Object) bool
Equal implements Object interface.
func (*RuntimeError) Error ¶
func (o *RuntimeError) Error() string
Error implements error interface.
func (*RuntimeError) Format ¶
func (o *RuntimeError) Format(s fmt.State, verb rune)
Format implements fmt.Formater interface.
func (*RuntimeError) GetMember ¶
func (o *RuntimeError) GetMember(idxA string) Object
func (*RuntimeError) GetValue ¶
func (o *RuntimeError) GetValue() Object
func (*RuntimeError) HasMemeber ¶
func (o *RuntimeError) HasMemeber() bool
func (*RuntimeError) IndexGet ¶
func (o *RuntimeError) IndexGet(index Object) (Object, error)
IndexGet implements Object interface.
func (*RuntimeError) IndexSet ¶
func (o *RuntimeError) IndexSet(index, value Object) error
IndexSet implements Object interface.
func (*RuntimeError) IsFalsy ¶
func (o *RuntimeError) IsFalsy() bool
IsFalsy implements Object interface.
func (*RuntimeError) Iterate ¶
func (*RuntimeError) Iterate() Iterator
Iterate implements Object interface.
func (*RuntimeError) NewError ¶
func (o *RuntimeError) NewError(messages ...string) *RuntimeError
NewError creates a new Error and sets original Error as its cause which can be unwrapped.
func (*RuntimeError) StackTrace ¶
func (o *RuntimeError) StackTrace() StackTrace
StackTrace returns stack trace if set otherwise returns nil.
func (*RuntimeError) String ¶
func (o *RuntimeError) String() string
String implements Object interface.
func (*RuntimeError) TypeCode ¶
func (*RuntimeError) TypeCode() int
func (*RuntimeError) TypeName ¶
func (*RuntimeError) TypeName() string
TypeName implements Object interface.
func (*RuntimeError) Unwrap ¶
func (o *RuntimeError) Unwrap() error
type Seq ¶
type Seq struct {
ObjectImpl
Value *(tk.Seq)
Members map[string]Object `json:"-"`
}
Seq object is used for generate unique sequence number(integer) Seq wraps tk.Seq for sequence/generator operations. It provides lazy evaluation of infinite or finite sequences.
Type code: 315.
Key characteristics:
- Wraps tk.Seq for sequence generation and manipulation
- Supports lazy evaluation of sequence elements
- Provides methods for filtering, mapping, and reducing
- Implements ValueSetter interface
- Supports member attachment via Members map
func (*Seq) CanIterate ¶
func (*Seq) GetCurrentValue ¶
func (*Seq) HasMemeber ¶
type SimpleOptimizer ¶
type SimpleOptimizer struct {
// contains filtered or unexported fields
}
SimpleOptimizer optimizes given parsed file by evaluating constants and expressions. It is not safe to call methods concurrently.
func NewOptimizer ¶
func NewOptimizer( file *parser.File, base *SymbolTable, opts CompilerOptions, ) *SimpleOptimizer
NewOptimizer creates an Optimizer object.
func (*SimpleOptimizer) Optimize ¶
func (so *SimpleOptimizer) Optimize() error
Optimize optimizes ast tree by simple constant folding and evaluating simple expressions.
func (*SimpleOptimizer) Total ¶
func (so *SimpleOptimizer) Total() int
Total returns total number of evaluated constants and expressions.
type SourceModule ¶
type SourceModule struct {
Src []byte
}
SourceModule is an importable module that's written in Charlang.
func (*SourceModule) Import ¶
func (m *SourceModule) Import(_ string) (interface{}, error)
Import returns a module source code.
type Stack ¶
type Stack struct {
ObjectImpl
Value *tk.SimpleStack
Members map[string]Object `json:"-"`
}
Stack represents a generic stack object and implements Object interface. Stack wraps tk.SimpleStack for LIFO (Last-In-First-Out) data structure. It provides push, pop, and peek operations for stack-based algorithms.
Type code: 321.
Key characteristics:
- Wraps tk.SimpleStack for LIFO operations
- Implements LengthGetter interface for size queries
- Supports Push, Pop, Peek, and Clear operations
- Generic container for Object values
- Supports member attachment via Members map
func (*Stack) CallMethod ¶
func (*Stack) HasMemeber ¶
type StackIterator ¶
type StackIterator struct {
V *Stack
// contains filtered or unexported fields
}
StackIterator represents an iterator for the Stack.
func (*StackIterator) Key ¶
func (it *StackIterator) Key() Object
Key implements Iterator interface.
func (*StackIterator) Next ¶
func (it *StackIterator) Next() bool
Next implements Iterator interface.
func (*StackIterator) Value ¶
func (it *StackIterator) Value() Object
Value implements Iterator interface.
type StackTrace ¶
type StackTrace []parser.SourceFilePos
StackTrace is the stack of source file positions.
type StatusResult ¶
type StatusResult struct {
ObjectImpl
Status string
Value string
Objects interface{}
Members map[string]Object `json:"-"`
Methods map[string]*Function `json:"-"`
}
StatusResult represents an operation result with status and value. It provides a standardized result format for operations that may succeed or fail.
Type code: 303.
Key characteristics:
- Standardized result format: Status ("success", "fail", ""), Value, Objects
- Status indicates operation outcome
- Value stores the result message or primary return value
- Objects stores additional structured data (optional)
- Pre-defined constants: StatusResultSuccess, StatusResultFail, StatusResultInvalid
- Methods cache stores dynamically generated function objects
- Supports member attachment via Members map
func (*StatusResult) CallMethod ¶
func (o *StatusResult) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*StatusResult) Equal ¶
func (o *StatusResult) Equal(right Object) bool
func (*StatusResult) GetMember ¶
func (o *StatusResult) GetMember(idxA string) Object
func (*StatusResult) GetValue ¶
func (o *StatusResult) GetValue() Object
func (*StatusResult) HasMemeber ¶
func (o *StatusResult) HasMemeber() bool
func (*StatusResult) IndexSet ¶
func (o *StatusResult) IndexSet(key, value Object) error
func (*StatusResult) String ¶
func (o *StatusResult) String() string
func (*StatusResult) TypeCode ¶
func (o *StatusResult) TypeCode() int
func (*StatusResult) TypeName ¶
func (o *StatusResult) TypeName() string
type String ¶
type String string
String represents string values and implements Object interface.
func ToStringObject ¶
func ToStringObject(argA interface{}) String
ToStringObject converts any Object to string representation. Parameters:
- argA: The Object to convert (any type)
Returns:
- A String object containing string representation of object
Examples:
ToStringObject(42) // Returns: String("42")
ToStringObject("hello") // Returns: String("hello")
ToStringObject([1, 2, 3]) // Returns: String("1, 2, 3")
func (String) CallMethod ¶
func (String) HasMemeber ¶
func (String) MarshalJSON ¶
type StringBuilder ¶
type StringBuilder struct {
ObjectImpl
Value *strings.Builder
Members map[string]Object `json:"-"`
}
StringBuilder wraps Go's strings.Builder for efficient string concatenation. It provides a mutable buffer for building strings without allocations.
Type code: 307.
Key characteristics:
- Wraps Go's strings.Builder for efficient string building
- Supports WriteString, Write, and Reset operations via methods
- Grows dynamically without reallocation (amortized O(1) append)
- String() returns the accumulated string content
- Supports member attachment via Members map
func (*StringBuilder) CallMethod ¶
func (o *StringBuilder) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*StringBuilder) CallName ¶
func (o *StringBuilder) CallName(nameA string, c Call) (Object, error)
func (*StringBuilder) CanCall ¶
func (*StringBuilder) CanCall() bool
func (*StringBuilder) CanIterate ¶
func (*StringBuilder) CanIterate() bool
func (*StringBuilder) Copy ¶
func (o *StringBuilder) Copy() Object
func (*StringBuilder) Equal ¶
func (o *StringBuilder) Equal(right Object) bool
func (*StringBuilder) GetMember ¶
func (o *StringBuilder) GetMember(idxA string) Object
func (*StringBuilder) GetValue ¶
func (o *StringBuilder) GetValue() Object
func (*StringBuilder) HasMemeber ¶
func (o *StringBuilder) HasMemeber() bool
func (*StringBuilder) IndexGet ¶
func (o *StringBuilder) IndexGet(index Object) (value Object, err error)
func (*StringBuilder) IndexSet ¶
func (o *StringBuilder) IndexSet(index, value Object) error
func (*StringBuilder) IsFalsy ¶
func (o *StringBuilder) IsFalsy() bool
func (*StringBuilder) Iterate ¶
func (*StringBuilder) Iterate() Iterator
func (*StringBuilder) SetMember ¶
func (o *StringBuilder) SetMember(idxA string, valueA Object) error
func (*StringBuilder) String ¶
func (o *StringBuilder) String() string
func (*StringBuilder) TypeCode ¶
func (o *StringBuilder) TypeCode() int
func (*StringBuilder) TypeName ¶
func (o *StringBuilder) TypeName() string
type StringIterator ¶
type StringIterator struct {
V String
// contains filtered or unexported fields
}
StringIterator represents an iterator for the string.
func (*StringIterator) Key ¶
func (it *StringIterator) Key() Object
Key implements Iterator interface.
func (*StringIterator) Next ¶
func (it *StringIterator) Next() bool
Next implements Iterator interface.
func (*StringIterator) Value ¶
func (it *StringIterator) Value() Object
Value implements Iterator interface.
type Symbol ¶
type Symbol struct {
Name string
Index int
Scope SymbolScope
Assigned bool
Constant bool
Original *Symbol
}
Symbol represents a symbol in the symbol table.
type SymbolScope ¶
type SymbolScope string
SymbolScope represents a symbol scope.
const ( ScopeGlobal SymbolScope = "GLOBAL" ScopeLocal SymbolScope = "LOCAL" ScopeBuiltin SymbolScope = "BUILTIN" ScopeFree SymbolScope = "FREE" )
List of symbol scopes
type SymbolTable ¶
type SymbolTable struct {
// contains filtered or unexported fields
}
SymbolTable represents a symbol table.
func NewSymbolTable ¶
func NewSymbolTable() *SymbolTable
NewSymbolTable creates new symbol table object.
func (*SymbolTable) DefineGlobal ¶
func (st *SymbolTable) DefineGlobal(name string) (*Symbol, error)
DefineGlobal adds a new symbol with ScopeGlobal in the current scope.
func (*SymbolTable) DefineLocal ¶
func (st *SymbolTable) DefineLocal(name string) (*Symbol, bool)
DefineLocal adds a new symbol with ScopeLocal in the current scope.
func (*SymbolTable) DisableBuiltin ¶
func (st *SymbolTable) DisableBuiltin(names ...string) *SymbolTable
DisableBuiltin disables given builtin name(s). Compiler returns `Compile Error: unresolved reference "builtin name"` if a disabled builtin is used.
func (*SymbolTable) DisabledBuiltins ¶
func (st *SymbolTable) DisabledBuiltins() []string
DisabledBuiltins returns disabled builtin names.
func (*SymbolTable) EnableParams ¶
func (st *SymbolTable) EnableParams(v bool) *SymbolTable
EnableParams enables or disables definition of parameters.
func (*SymbolTable) Fork ¶
func (st *SymbolTable) Fork(block bool) *SymbolTable
Fork creates a new symbol table for a new scope.
func (*SymbolTable) FreeSymbols ¶
func (st *SymbolTable) FreeSymbols() []*Symbol
FreeSymbols returns registered free symbols for the scope.
func (*SymbolTable) InBlock ¶
func (st *SymbolTable) InBlock() bool
InBlock returns true if symbol table belongs to a block.
func (*SymbolTable) MaxSymbols ¶
func (st *SymbolTable) MaxSymbols() int
MaxSymbols returns the total number of symbols defined in the scope.
func (*SymbolTable) NextIndex ¶
func (st *SymbolTable) NextIndex() int
NextIndex returns the next symbol index.
func (*SymbolTable) NumParams ¶
func (st *SymbolTable) NumParams() int
NumParams returns number of parameters for the scope.
func (*SymbolTable) Parent ¶
func (st *SymbolTable) Parent(skipBlock bool) *SymbolTable
Parent returns the outer scope of the current symbol table.
func (*SymbolTable) Resolve ¶
func (st *SymbolTable) Resolve(name string) (symbol *Symbol, ok bool)
Resolve resolves a symbol with a given name.
func (*SymbolTable) SetParams ¶
func (st *SymbolTable) SetParams(params ...string) error
SetParams sets parameters defined in the scope. This can be called only once.
func (*SymbolTable) ShadowedBuiltins ¶
func (st *SymbolTable) ShadowedBuiltins() []string
ShadowedBuiltins returns all shadowed builtin names including parent symbol tables'. Returing slice may contain duplicate names.
func (*SymbolTable) Symbols ¶
func (st *SymbolTable) Symbols() []*Symbol
Symbols returns registered symbols for the scope.
type SyncIterator ¶
type SyncIterator struct {
Iterator
// contains filtered or unexported fields
}
SyncIterator represents an iterator for the SyncMap.
func (*SyncIterator) Value ¶
func (it *SyncIterator) Value() Object
Value implements Iterator interface.
type SyncMap ¶
type SyncMap struct {
Value Map
Members map[string]Object `json:"-"`
// contains filtered or unexported fields
}
SyncMap represents a thread-safe map with read-write locking. It wraps a Map with sync.RWMutex for concurrent access safety.
Type code: 153.
Key characteristics:
- Thread-safe map implementation using sync.RWMutex
- Provides RLock/RLock/Unlock methods for explicit locking
- Implements IndexDeleter and LengthGetter interfaces
- All operations are protected by the internal mutex
- Supports member attachment via Members map
func (*SyncMap) CallMethod ¶
func (*SyncMap) CanIterate ¶
CanIterate implements Object interface.
func (*SyncMap) HasMemeber ¶
func (*SyncMap) IndexDelete ¶
IndexDelete tries to delete the string value of key from the map.
func (*SyncMap) Len ¶
Len returns the number of items in the map. Len implements LengthGetter interface.
type Time ¶
Time represents time values and implements Object interface. Time represents a time value wrapping Go's time.Time. It supports arithmetic operations with duration (int) and comparison with other times.
Type code: 311.
Key characteristics:
- Wraps Go's time.Time for full-featured datetime operations
- Supports binary operations: addition/subtraction with duration (Int)
- Supports comparison operations with other Time objects
- Provides formatting, parsing, and timezone conversion methods
- Can be created from Unix timestamp (Int) or RFC3339 string (String)
- Implements NameCallerObject interface for efficient method dispatch
func (*Time) HasMemeber ¶
func (*Time) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler interface.
func (*Time) MarshalJSON ¶
MarshalJSON implements json.JSONMarshaler interface.
func (*Time) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler interface.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements json.JSONUnmarshaler interface.
type Uint ¶
type Uint uint64
Uint represents unsigned integer values and implements Object interface.
func (Uint) HasMemeber ¶
type UintIterator ¶
type UintIterator struct {
V Uint
// contains filtered or unexported fields
}
UintIterator represents an iterator for the Int.
func (*UintIterator) Value ¶
func (it *UintIterator) Value() Object
Value implements Iterator interface.
type UndefinedType ¶
type UndefinedType struct {
ObjectImpl
}
UndefinedType represents the type of global Undefined Object. One should use the UndefinedType in type switches only. UndefinedType represents the type of the global Undefined singleton. It should only be used in type switches; use the Undefined variable for values.
Type code: 0.
Key characteristics:
- Singleton pattern: only one instance exists (global Undefined variable)
- Represents absence of value, similar to JavaScript's undefined
- IsFalsy() returns true (undefined is falsy in boolean context)
- GetMember() returns Undefined for any member access (safe navigation)
- Cannot be called, indexed, or iterated
- Equal() returns true only when compared with Undefined itself
func (*UndefinedType) Call ¶
func (*UndefinedType) Call(_ ...Object) (Object, error)
Call implements Object interface.
func (*UndefinedType) CallMethod ¶
func (o *UndefinedType) CallMethod(nameA string, argsA ...Object) (Object, error)
func (*UndefinedType) Equal ¶
func (o *UndefinedType) Equal(right Object) bool
Equal implements Object interface.
func (*UndefinedType) GetMember ¶
func (o *UndefinedType) GetMember(idxA string) Object
func (*UndefinedType) GetValue ¶
func (o *UndefinedType) GetValue() Object
func (*UndefinedType) HasMemeber ¶
func (o *UndefinedType) HasMemeber() bool
func (*UndefinedType) IndexGet ¶
func (*UndefinedType) IndexGet(key Object) (Object, error)
IndexGet implements Object interface.
func (*UndefinedType) IndexSet ¶
func (*UndefinedType) IndexSet(key, value Object) error
IndexSet implements Object interface.
func (*UndefinedType) SetMember ¶
func (o *UndefinedType) SetMember(idxA string, valueA Object) error
func (*UndefinedType) String ¶
func (o *UndefinedType) String() string
String implements Object interface.
func (*UndefinedType) TypeCode ¶
func (o *UndefinedType) TypeCode() int
func (*UndefinedType) TypeName ¶
func (o *UndefinedType) TypeName() string
TypeName implements Object interface.
type VM ¶
type VM struct {
LeBuf []string
LeSshInfo map[string]string
// contains filtered or unexported fields
}
VM executes the instructions in Bytecode. It is a stack-based virtual machine with frame-based function calls.
Key fields:
- abort: Atomic flag to signal execution abort
- sp: Stack pointer - points to next free slot in value stack
- ip: Instruction pointer - current instruction offset in curInsts
- curInsts: Current instruction slice being executed
- constants: Constant pool from bytecode (literals, functions)
- stack: Value stack for operands and intermediate results
- frames: Call frame stack for function calls
- curFrame: Current active frame
- bytecode: The bytecode being executed
- globals: Global variables accessible to all functions
- pool: VM pool for instance reuse
func (*VM) Abort ¶
func (vm *VM) Abort()
Abort aborts the VM execution. It is safe to call this method from another goroutine.
func (*VM) Aborted ¶
Aborted reports whether VM is aborted. It is safe to call this method from another goroutine.
func (*VM) GetBytecode ¶
func (*VM) GetBytecodeInfo ¶
func (*VM) GetCompilerOptions ¶
func (vm *VM) GetCompilerOptions() *CompilerOptions
func (*VM) GetCurFunc ¶
func (*VM) GetCurInstr ¶
func (*VM) GetLocals ¶
GetLocals returns variables from stack up to the NumLocals of given Bytecode. This must be called after Run() before Clear().
func (*VM) GetLocalsQuick ¶
func (*VM) RunCompiledFunction ¶
func (vm *VM) RunCompiledFunction( f *CompiledFunction, globals Object, args ...Object, ) (Object, error)
RunCompiledFunction runs given CompiledFunction as if it is Main function. Bytecode must be set before calling this method, because Fileset and Constants are copied.
func (*VM) SetBytecode ¶
SetBytecode enables to set a new Bytecode.
func (*VM) SetRecover ¶
SetRecover recovers panic when Run panics and returns panic as an error. If error handler is present `try-catch-finally`, VM continues to run from catch/finally.
type ValueSetter ¶
type WebSocket ¶
type WebSocket struct {
ObjectImpl
Value *websocket.Conn
}
WebSocket object is used to represent the WebSocket connection WebSocket wraps websocket.Conn for WebSocket communication. It provides real-time bidirectional communication over TCP.
Type code: 701.
Key characteristics:
- Wraps gorilla/websocket.Conn for WebSocket protocol
- Supports both client (dial) and server (upgrade) modes
- Provides methods for sending/receiving text and binary messages
- Enables real-time bidirectional communication
func (*WebSocket) CallMethod ¶
func (*WebSocket) CanIterate ¶
func (*WebSocket) HasMemeber ¶
type Writer ¶
type Writer struct {
ObjectImpl
Value io.Writer
Members map[string]Object `json:"-"`
}
Writer object is used for represent io.Writer type value Writer wraps io.Writer for writing data to various destinations. It implements io.WriteCloser interface for stream-based writing.
Type code: 333.
Key characteristics:
- Wraps any io.Writer (files, network connections, buffers, etc.)
- Implements io.WriteCloser interface
- Provides unified interface for writing to different targets
- Supports member attachment via Members map
func (*Writer) CallMethod ¶
func (*Writer) CanIterate ¶
func (*Writer) HasMemeber ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
char
module
|
|
|
dll
module
|
|
|
docs
|
|
|
benchmark
command
Go 斐波那契性能测试
|
Go 斐波那契性能测试 |
|
internal
|
|
|
Package parser implements a parser for Charlang source code.
|
Package parser implements a parser for Charlang source code. |
|
ex
Package ex provides ex module implementing some extra functions.
|
Package ex provides ex module implementing some extra functions. |
|
strings
Package strings provides strings module implementing simple functions to manipulate UTF-8 encoded strings for Charlang script language.
|
Package strings provides strings module implementing simple functions to manipulate UTF-8 encoded strings for Charlang script language. |
|
test1
module
|
|
|
Package token defines lexical tokens for the Charlang language.
|
Package token defines lexical tokens for the Charlang language. |




