Documentation ¶
Index ¶
- Constants
- func CallAddrOp(kind Kind, op AddrOperator, data ...interface{})
- func CallBuiltinOp(kind Kind, op Operator, data ...interface{}) interface{}
- func GlobalInterface() exec.Interface
- func ToValues(args []interface{}) []reflect.Value
- type AddrOperator
- type AddrOperatorInfo
- type Builder
- func (p *Builder) AddrOp(kind Kind, op AddrOperator) *Builder
- func (p *Builder) AddrVar(v *Var) *Builder
- func (p *Builder) Append(typ reflect.Type, arity int) *Builder
- func (ctx *Builder) BuiltinOp(kind Kind, op Operator) *Builder
- func (p *Builder) CallClosure(arity int) *Builder
- func (p *Builder) CallFunc(fun *FuncInfo) *Builder
- func (p *Builder) CallFuncv(fun *FuncInfo, arity int) *Builder
- func (p *Builder) CallGoClosure(arity int) *Builder
- func (p *Builder) CallGoFunc(fun GoFuncAddr) *Builder
- func (p *Builder) CallGoFuncv(fun GoFuncvAddr, arity int) *Builder
- func (p *Builder) CaseNE(l *Label, arity int) *Builder
- func (p *Builder) Closure(fun *FuncInfo) *Builder
- func (p *Builder) Default() *Builder
- func (p *Builder) DefineFunc(fun *FuncInfo) *Builder
- func (p *Builder) DefineVar(vars ...*Var) *Builder
- func (p *Builder) DefineVars(vars ...exec.Var) *Builder
- func (p *Builder) EndComprehension(c *Comprehension) *Builder
- func (p *Builder) EndForPhrase(f *ForPhrase) *Builder
- func (p *Builder) EndFunc(fun *FuncInfo) *Builder
- func (p *Builder) FilterForPhrase(f *ForPhrase) *Builder
- func (p *Builder) ForPhrase(f *ForPhrase, key, val *Var, hasExecCtx ...bool) *Builder
- func (p *Builder) GoBuiltin(typ reflect.Type, op GoBuiltin) *Builder
- func (p *Builder) GoClosure(fun *FuncInfo) *Builder
- func (p *Builder) InCurrentCtx(v *Var) bool
- func (p *Builder) Index(idx int) *Builder
- func (p *Builder) Interface() exec.Builder
- func (p *Builder) Jmp(l *Label) *Builder
- func (p *Builder) JmpIf(zeroOrOne uint32, l *Label) *Builder
- func (p *Builder) Label(l *Label) *Builder
- func (p *Builder) ListComprehension(c *Comprehension) *Builder
- func (p *Builder) Load(idx int32) *Builder
- func (p *Builder) LoadVar(v *Var) *Builder
- func (p *Builder) Make(typ reflect.Type, arity int) *Builder
- func (p *Builder) MakeArray(typ reflect.Type, arity int) *Builder
- func (p *Builder) MakeMap(typ reflect.Type, arity int) *Builder
- func (p *Builder) MapComprehension(c *Comprehension) *Builder
- func (p *Builder) MapIndex() *Builder
- func (p *Builder) Pop(n int) *Builder
- func (p *Builder) Push(val interface{}) *Builder
- func (p *Builder) Reserve() Reserved
- func (p *Builder) ReservedAsPush(r Reserved, val interface{})
- func (p *Builder) Resolve() *Code
- func (p *Builder) Return(n int32) *Builder
- func (p *Builder) SetIndex(idx int) *Builder
- func (p *Builder) SetMapIndex() *Builder
- func (p *Builder) Slice(i, j int) *Builder
- func (p *Builder) Slice3(i, j, k int) *Builder
- func (p *Builder) Store(idx int32) *Builder
- func (p *Builder) StoreVar(v *Var) *Builder
- func (p *Builder) TypeCast(from, to reflect.Type) *Builder
- func (p *Builder) Zero(typ reflect.Type) *Builder
- type Closure
- type Code
- type Comprehension
- type ConstKind
- type Context
- type ForPhrase
- type FuncInfo
- func (p *FuncInfo) Args(in ...reflect.Type) *FuncInfo
- func (p *FuncInfo) IsUnnamedOut() bool
- func (p *FuncInfo) IsVariadic() bool
- func (p *FuncInfo) Name() string
- func (p *FuncInfo) NumOut() int
- func (p *FuncInfo) Out(i int) *Var
- func (p *FuncInfo) Return(out ...*Var) *FuncInfo
- func (p *FuncInfo) Type() reflect.Type
- func (p *FuncInfo) Vargs(in ...reflect.Type) *FuncInfo
- type GoBuiltin
- type GoConstInfo
- type GoFuncAddr
- type GoFuncInfo
- type GoFuncvAddr
- type GoFuncvInfo
- type GoPackage
- func (p *GoPackage) Const(name string, kind ConstKind, val interface{}) GoConstInfo
- func (p *GoPackage) Find(name string) (addr uint32, kind SymbolKind, ok bool)
- func (p *GoPackage) FindConst(name string) (ci *GoConstInfo, ok bool)
- func (p *GoPackage) FindFunc(name string) (addr GoFuncAddr, ok bool)
- func (p *GoPackage) FindFuncv(name string) (addr GoFuncvAddr, ok bool)
- func (p *GoPackage) FindType(name string) (typ reflect.Type, ok bool)
- func (p *GoPackage) FindVar(name string) (addr GoVarAddr, ok bool)
- func (p *GoPackage) Func(name string, fn interface{}, exec func(i int, p *Context)) GoFuncInfo
- func (p *GoPackage) Funcv(name string, fn interface{}, exec func(i int, p *Context)) GoFuncvInfo
- func (p *GoPackage) PkgPath() string
- func (p *GoPackage) RegisterConsts(consts ...GoConstInfo)
- func (p *GoPackage) RegisterFuncs(funs ...GoFuncInfo) (base GoFuncAddr)
- func (p *GoPackage) RegisterFuncvs(funs ...GoFuncvInfo) (base GoFuncvAddr)
- func (p *GoPackage) RegisterTypes(typinfos ...GoTypeInfo)
- func (p *GoPackage) RegisterVars(vars ...GoVarInfo) (base GoVarAddr)
- func (p *GoPackage) Rtype(typ reflect.Type) GoTypeInfo
- func (p *GoPackage) Type(name string, typ reflect.Type) GoTypeInfo
- func (p *GoPackage) Var(name string, addr interface{}) GoVarInfo
- type GoTypeInfo
- type GoVarAddr
- type GoVarInfo
- type Instr
- type InstrInfo
- type Kind
- type Label
- type Operator
- type OperatorInfo
- type Package
- type Reserved
- type Stack
- func (p *Stack) Get(idx int) interface{}
- func (p *Stack) GetArgs(arity int) []interface{}
- func (p *Stack) Init()
- func (p *Stack) Len() int
- func (p *Stack) Pop() interface{}
- func (p *Stack) PopN(n int)
- func (p *Stack) Push(v interface{})
- func (p *Stack) Ret(arity int, results ...interface{})
- func (p *Stack) Set(idx int, v interface{})
- func (p *Stack) SetLen(base int)
- type StructField
- type StructInfo
- type SymbolKind
- type Var
Constants ¶
const ( // SliceConstIndexLast - slice const index max SliceConstIndexLast = exec.SliceConstIndexLast // SliceDefaultIndex - unspecified index SliceDefaultIndex = exec.SliceDefaultIndex )
const ( // ConstBoundRune - bound type: rune ConstBoundRune = exec.ConstBoundRune // ConstBoundString - bound type: string ConstBoundString = exec.ConstBoundString // ConstUnboundInt - unbound int type ConstUnboundInt = exec.ConstUnboundInt // ConstUnboundFloat - unbound float type ConstUnboundFloat = exec.ConstUnboundFloat // ConstUnboundComplex - unbound complex type ConstUnboundComplex = exec.ConstUnboundComplex // ConstUnboundPtr - nil: unbound ptr ConstUnboundPtr = exec.ConstUnboundPtr )
const ( // SymbolVar - variable SymbolVar = exec.SymbolVar // SymbolFunc - function SymbolFunc = exec.SymbolFunc // SymbolFuncv - variadic function SymbolFuncv = exec.SymbolFuncv )
const ( // OpInvalid - invalid operator OpInvalid = exec.OpInvalid // OpAdd '+' String/Int/Uint/Float/Complex OpAdd = exec.OpAdd // OpSub '-' Int/Uint/Float/Complex OpSub = exec.OpSub // OpMul '*' Int/Uint/Float/Complex OpMul = exec.OpMul // OpDiv '/' Int/Uint/Float/Complex OpDiv = exec.OpDiv // OpMod '%' Int/Uint OpMod = exec.OpMod // OpBitAnd '&' Int/Uint OpBitAnd = exec.OpBitAnd // OpBitOr '|' Int/Uint OpBitOr = exec.OpBitOr // OpBitXor '^' Int/Uint OpBitXor = exec.OpBitXor // OpBitAndNot '&^' Int/Uint OpBitAndNot = exec.OpBitAndNot // OpBitSHL '<<' Int/Uint, Uint OpBitSHL = exec.OpBitSHL // OpBitSHR '>>' Int/Uint, Uint OpBitSHR = exec.OpBitSHR // OpLT '<' String/Int/Uint/Float OpLT = exec.OpLT // OpLE '<=' String/Int/Uint/Float OpLE = exec.OpLE // OpGT '>' String/Int/Uint/Float OpGT = exec.OpGT // OpGE '>=' String/Int/Uint/Float OpGE = exec.OpGE // OpEQ '==' ComparableType // Slice, map, and function values are not comparable. However, as a special case, a slice, map, // or function value may be compared to the predeclared identifier nil. OpEQ = exec.OpEQ // OpEQNil '==' nil OpEQNil = exec.OpEQNil // OpNE '!=' ComparableType OpNE = exec.OpNE // OpNENil '!=' nil OpNENil = exec.OpNENil // OpLAnd '&&' Bool OpLAnd = exec.OpLAnd // OpLOr '||' Bool OpLOr = exec.OpLOr // OpNeg '-' OpNeg = exec.OpNeg // OpNot '!' OpNot = exec.OpNot // OpBitNot '^' OpBitNot = exec.OpBitNot )
const ( // Bool type Bool = exec.Bool // Int type Int = exec.Int // Int8 type Int8 = exec.Int8 // Int16 type Int16 = exec.Int16 // Int32 type Int32 = exec.Int32 // Int64 type Int64 = exec.Int64 // Uint type Uint = exec.Uint // Uint8 type Uint8 = exec.Uint8 // Uint16 type Uint16 = exec.Uint16 // Uint32 type Uint32 = exec.Uint32 // Uint64 type Uint64 = exec.Uint64 // Uintptr type Uintptr = exec.Uintptr // Float32 type Float32 = exec.Float32 // Float64 type Float64 = exec.Float64 // Complex64 type Complex64 = exec.Complex64 // Complex128 type Complex128 = exec.Complex128 // String type String = exec.String // UnsafePointer type UnsafePointer = exec.UnsafePointer )
const ( // OpAddrVal `*addr` OpAddrVal = exec.OpAddrVal // OpAddAssign `+=` OpAddAssign = exec.OpAddAssign // OpSubAssign `-=` OpSubAssign = exec.OpSubAssign // OpMulAssign `*=` OpMulAssign = exec.OpMulAssign // OpDivAssign `/=` OpDivAssign = exec.OpDivAssign // OpModAssign `%=` OpModAssign = exec.OpModAssign // OpBitAndAssign '&=' OpBitAndAssign = exec.OpBitAndAssign // OpBitOrAssign '|=' OpBitOrAssign = exec.OpBitOrAssign // OpBitXorAssign '^=' OpBitXorAssign = exec.OpBitXorAssign // OpBitAndNotAssign '&^=' OpBitAndNotAssign = exec.OpBitAndNotAssign // OpBitSHLAssign '<<=' OpBitSHLAssign = exec.OpBitSHLAssign // OpBitSHRAssign '>>=' OpBitSHRAssign = exec.OpBitSHRAssign // OpAssign `=` OpAssign = exec.OpAssign // OpInc '++' OpInc = exec.OpInc // OpDec '--' OpDec = exec.OpDec )
const ( // GobLen - len: 1 GobLen = exec.GobLen // GobCap - cap: 2 GobCap = exec.GobCap // GobCopy - copy: 3 GobCopy = exec.GobCopy // GobDelete - delete: 4 GobDelete = exec.GobDelete // GobComplex - complex: 5 GobComplex = exec.GobComplex // GobReal - real: 6 GobReal = exec.GobReal // GobImag - imag: 7 GobImag = exec.GobImag // GobClose - close: 8 GobClose = exec.GobClose )
const InvalidReserved = exec.InvalidReserved
InvalidReserved is an invalid reserved position.
const ( // SameAsFirst means the second argument is same as first argument type. SameAsFirst = exec.SameAsFirst )
Variables ¶
This section is empty.
Functions ¶
func CallAddrOp ¶
func CallAddrOp(kind Kind, op AddrOperator, data ...interface{})
CallAddrOp calls AddrOp
func CallBuiltinOp ¶
CallBuiltinOp calls BuiltinOp
func GlobalInterface ¶
GlobalInterface returns the global Interface.
Types ¶
type AddrOperatorInfo ¶
type AddrOperatorInfo = exec.AddrOperatorInfo
AddrOperatorInfo represents an addr-operator information.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a class that generates executing byte code.
func NewBuilder ¶
NewBuilder creates a new Code Builder instance.
func (*Builder) CallGoClosure ¶
CallGoClosure instr
func (*Builder) CallGoFuncv ¶
func (p *Builder) CallGoFuncv(fun GoFuncvAddr, arity int) *Builder
CallGoFuncv instr
func (*Builder) DefineVars ¶
DefineVars defines variables.
func (*Builder) EndComprehension ¶
func (p *Builder) EndComprehension(c *Comprehension) *Builder
EndComprehension instr
func (*Builder) EndForPhrase ¶
EndForPhrase instr
func (*Builder) FilterForPhrase ¶
FilterForPhrase instr
func (*Builder) InCurrentCtx ¶
InCurrentCtx returns if a variable is in current context or not.
func (*Builder) ListComprehension ¶
func (p *Builder) ListComprehension(c *Comprehension) *Builder
ListComprehension instr
func (*Builder) MapComprehension ¶
func (p *Builder) MapComprehension(c *Comprehension) *Builder
MapComprehension instr
func (*Builder) ReservedAsPush ¶
ReservedAsPush sets Reserved as Push(v)
type Closure ¶
type Closure struct {
// contains filtered or unexported fields
}
Closure represents a qlang closure.
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
A Code represents generated instructions to execute.
type Comprehension ¶
Comprehension represents a list/map comprehension.
func NewComprehension ¶
func NewComprehension(out reflect.Type) *Comprehension
NewComprehension creates a new Comprehension instance.
type ConstKind ¶
A ConstKind represents the specific kind of type that a Type represents. The zero Kind is not a valid kind.
type Context ¶
type Context struct { *Stack // contains filtered or unexported fields }
A Context represents the context of an executor.
func NewContext ¶
NewContext returns a new context of an executor.
type ForPhrase ¶
type ForPhrase struct {
Key, Value *Var // Key, Value may be nil
Cond, End int
TypeIn reflect.Type
// contains filtered or unexported fields
}
ForPhrase represents a for range phrase.
func NewForPhrase ¶
NewForPhrase creates a new ForPhrase instance.
type FuncInfo ¶
type FuncInfo struct { Pkg *Package // contains filtered or unexported fields }
FuncInfo represents a qlang function information.
func (*FuncInfo) IsUnnamedOut ¶
IsUnnamedOut returns if function results unnamed or not.
func (*FuncInfo) IsVariadic ¶
IsVariadic returns if this function is variadic or not.
func (*FuncInfo) NumOut ¶
NumOut returns a function type's output parameter count. It panics if the type's Kind is not Func.
func (*FuncInfo) Out ¶
Out returns the type of a function type's i'th output parameter. It panics if i is not in the range [0, NumOut()).
type GoConstInfo ¶
type GoConstInfo = exec.GoConstInfo
GoConstInfo represents a Go constant information.
type GoFuncInfo ¶
type GoFuncInfo struct { Pkg *GoPackage Name string This interface{} // contains filtered or unexported fields }
GoFuncInfo represents a Go function information.
type GoFuncvAddr ¶
type GoFuncvAddr = exec.GoFuncvAddr
GoFuncvAddr represents a variadic Go function address.
type GoFuncvInfo ¶
type GoFuncvInfo struct { GoFuncInfo // contains filtered or unexported fields }
GoFuncvInfo represents a Go function information.
type GoPackage ¶
type GoPackage struct {
// contains filtered or unexported fields
}
GoPackage represents a Go package.
func FindGoPackage ¶
FindGoPackage lookups a Go package by pkgPath. It returns nil if not found.
func NewGoPackage ¶
NewGoPackage creates a new builtin Go Package.
func (*GoPackage) Const ¶
func (p *GoPackage) Const(name string, kind ConstKind, val interface{}) GoConstInfo
Const creates a GoConstInfo instance.
func (*GoPackage) Find ¶
func (p *GoPackage) Find(name string) (addr uint32, kind SymbolKind, ok bool)
Find lookups a symbol by specified its name.
func (*GoPackage) FindConst ¶
func (p *GoPackage) FindConst(name string) (ci *GoConstInfo, ok bool)
FindConst lookups a Go constant by name.
func (*GoPackage) FindFunc ¶
func (p *GoPackage) FindFunc(name string) (addr GoFuncAddr, ok bool)
FindFunc lookups a Go function by name.
func (*GoPackage) FindFuncv ¶
func (p *GoPackage) FindFuncv(name string) (addr GoFuncvAddr, ok bool)
FindFuncv lookups a Go function by name.
func (*GoPackage) Func ¶
func (p *GoPackage) Func(name string, fn interface{}, exec func(i int, p *Context)) GoFuncInfo
Func creates a GoFuncInfo instance.
func (*GoPackage) Funcv ¶
func (p *GoPackage) Funcv(name string, fn interface{}, exec func(i int, p *Context)) GoFuncvInfo
Funcv creates a GoFuncvInfo instance.
func (*GoPackage) RegisterConsts ¶
func (p *GoPackage) RegisterConsts(consts ...GoConstInfo)
RegisterConsts registers all exported Go constants of this package.
func (*GoPackage) RegisterFuncs ¶
func (p *GoPackage) RegisterFuncs(funs ...GoFuncInfo) (base GoFuncAddr)
RegisterFuncs registers all exported Go functions of this package.
func (*GoPackage) RegisterFuncvs ¶
func (p *GoPackage) RegisterFuncvs(funs ...GoFuncvInfo) (base GoFuncvAddr)
RegisterFuncvs registers all exported Go functions with variadic arguments of this package.
func (*GoPackage) RegisterTypes ¶
func (p *GoPackage) RegisterTypes(typinfos ...GoTypeInfo)
RegisterTypes registers all exported Go types defined by this package.
func (*GoPackage) RegisterVars ¶
RegisterVars registers all exported Go variables of this package.
func (*GoPackage) Rtype ¶
func (p *GoPackage) Rtype(typ reflect.Type) GoTypeInfo
Rtype gets the real type information.
type GoTypeInfo ¶
GoTypeInfo represents a Go type information.
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents a label.
type OperatorInfo ¶
type OperatorInfo = exec.OperatorInfo
OperatorInfo represents an operator information.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
A Stack represents a FILO container.
type StructField ¶
type StructField = reflect.StructField
A StructField describes a single field in a struct.
type StructInfo ¶
type StructInfo struct { Fields []StructField // contains filtered or unexported fields }
A StructInfo represents a struct information.
type Var ¶
type Var struct {
// contains filtered or unexported fields
}
Var represents a variable.
func (*Var) IsUnnamedOut ¶
IsUnnamedOut returns if variable unnamed or not.