bytecode

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bytecode implements a bytecode backend for the Go+ language.

Index

Constants

View Source
const (
	// SliceConstIndexLast - slice const index max
	SliceConstIndexLast = exec.SliceConstIndexLast
	// SliceDefaultIndex - unspecified index
	SliceDefaultIndex = exec.SliceDefaultIndex
)
View Source
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
)
View Source
const (
	// SymbolVar - variable
	SymbolVar = exec.SymbolVar
	// SymbolFunc - function
	SymbolFunc = exec.SymbolFunc
	// SymbolFuncv - variadic function
	SymbolFuncv = exec.SymbolFuncv
)
View Source
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
	// OpQuo '/' Int/Uint/Float/Complex
	OpQuo = exec.OpQuo
	// OpMod '%' Int/Uint
	OpMod = exec.OpMod
	// OpAnd '&' Int/Uint
	OpAnd = exec.OpAnd
	// OpOr '|' Int/Uint
	OpOr = exec.OpOr
	// OpXor '^' Int/Uint
	OpXor = exec.OpXor
	// OpAndNot '&^' Int/Uint
	OpAndNot = exec.OpAndNot
	// OpLsh '<<' Int/Uint, Uint
	OpLsh = exec.OpLsh
	// OpRsh '>>' Int/Uint, Uint
	OpRsh = exec.OpRsh
	// 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
	// OpLNot '!'
	OpLNot = exec.OpLNot
	// OpNeg '-'
	OpNeg = exec.OpNeg
	// OpBitNot '^'
	OpBitNot = exec.OpBitNot
)
View Source
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
	// BigInt type
	BigInt = exec.BigInt
	// BigRat type
	BigRat = exec.BigRat
	// BigFloat type
	BigFloat = exec.BigFloat
	// Slice type
	Slice = exec.Slice
	// Map type
	Map = exec.Map
	// Chan type
	Chan = exec.Chan
	// Ptr type
	Ptr = exec.Ptr
)
View Source
const (
	// OpAddrVal `*addr`
	OpAddrVal = exec.OpAddrVal
	// OpAddAssign `+=`
	OpAddAssign = exec.OpAddAssign
	// OpSubAssign `-=`
	OpSubAssign = exec.OpSubAssign
	// OpMulAssign `*=`
	OpMulAssign = exec.OpMulAssign
	// OpQuoAssign `/=`
	OpQuoAssign = exec.OpQuoAssign
	// OpModAssign `%=`
	OpModAssign = exec.OpModAssign

	// OpAndAssign '&='
	OpAndAssign = exec.OpAndAssign
	// OpOrAssign '|='
	OpOrAssign = exec.OpOrAssign
	// OpXorAssign '^='
	OpXorAssign = exec.OpXorAssign
	// OpAndNotAssign '&^='
	OpAndNotAssign = exec.OpAndNotAssign
	// OpLshAssign '<<='
	OpLshAssign = exec.OpLshAssign
	// OpRshAssign '>>='
	OpRshAssign = exec.OpRshAssign
	// OpAssign `=`
	OpAssign = exec.OpAssign
	// OpInc '++'
	OpInc = exec.OpInc
	// OpDec '--'
	OpDec = exec.OpDec
)
View Source
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
)
View Source
const InvalidReserved = exec.InvalidReserved

InvalidReserved is an invalid reserved position.

View Source
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

func CallBuiltinOp(kind Kind, op Operator, data ...interface{}) interface{}

CallBuiltinOp calls BuiltinOp

func DumpCodeBlock

func DumpCodeBlock(w io.Writer, data ...Instr)

DumpCodeBlock dumps a code block.

func FindGoPackage

func FindGoPackage(pkgPath string) exec.GoPackage

FindGoPackage lookups a Go package by pkgPath. It returns nil if not found.

func ProfileReport

func ProfileReport()

ProfileReport reports profile information.

func SetProfile

func SetProfile(profile bool)

SetProfile sets profile flag.

func ToValues

func ToValues(args []interface{}) []reflect.Value

ToValues converts []interface{} into []reflect.Value.

Types

type AddrOperator

type AddrOperator = exec.AddrOperator

AddrOperator type.

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

func NewBuilder(code *Code) *Builder

NewBuilder creates a new Code Builder instance.

func (*Builder) Addr

func (p *Builder) Addr(idx int32) *Builder

Addr instr

func (*Builder) AddrField

func (p *Builder) AddrField(typ reflect.Type, index []int) *Builder

AddrField instr

func (*Builder) AddrGoVar

func (p *Builder) AddrGoVar(addr GoVarAddr) *Builder

AddrGoVar instr

func (*Builder) AddrIndex

func (p *Builder) AddrIndex(idx int) *Builder

AddrIndex instr

func (*Builder) AddrOp

func (p *Builder) AddrOp(kind Kind, op AddrOperator) *Builder

AddrOp instr

func (*Builder) AddrVar

func (p *Builder) AddrVar(v *Var) *Builder

AddrVar instr

func (*Builder) Append

func (p *Builder) Append(typ reflect.Type, arity int) *Builder

Append instr

func (*Builder) BuiltinOp

func (p *Builder) BuiltinOp(kind Kind, op Operator) *Builder

BuiltinOp instr

func (*Builder) CallClosure

func (p *Builder) CallClosure(arity int) *Builder

CallClosure instr

func (*Builder) CallFunc

func (p *Builder) CallFunc(fun *FuncInfo) *Builder

CallFunc instr

func (*Builder) CallFuncv

func (p *Builder) CallFuncv(fun *FuncInfo, arity int) *Builder

CallFuncv instr

func (*Builder) CallGoClosure

func (p *Builder) CallGoClosure(arity int) *Builder

CallGoClosure instr

func (*Builder) CallGoFunc

func (p *Builder) CallGoFunc(fun GoFuncAddr) *Builder

CallGoFunc instr

func (*Builder) CallGoFuncv

func (p *Builder) CallGoFuncv(fun GoFuncvAddr, arity int) *Builder

CallGoFuncv instr

func (*Builder) CaseNE

func (p *Builder) CaseNE(l *Label, arity int) *Builder

CaseNE instr

func (*Builder) Closure

func (p *Builder) Closure(fun *FuncInfo) *Builder

Closure instr

func (*Builder) Default

func (p *Builder) Default() *Builder

Default instr

func (*Builder) Defer

func (p *Builder) Defer() *Builder

Defer instr

func (*Builder) DefineFunc

func (p *Builder) DefineFunc(fun *FuncInfo) *Builder

DefineFunc instr

func (*Builder) DefineVar

func (p *Builder) DefineVar(vars ...*Var) *Builder

DefineVar defines variables.

func (*Builder) DefineVars

func (p *Builder) DefineVars(vars ...exec.Var) *Builder

DefineVars defines variables.

func (*Builder) EndComprehension

func (p *Builder) EndComprehension(c *Comprehension) *Builder

EndComprehension instr

func (*Builder) EndForPhrase

func (p *Builder) EndForPhrase(f *ForPhrase) *Builder

EndForPhrase instr

func (*Builder) EndFunc

func (p *Builder) EndFunc(fun *FuncInfo) *Builder

EndFunc instr

func (*Builder) ErrWrap

func (p *Builder) ErrWrap(nret int, retErr exec.Var, frame *errors.Frame, narg int) *Builder

ErrWrap instr

func (*Builder) FilterForPhrase

func (p *Builder) FilterForPhrase(f *ForPhrase) *Builder

FilterForPhrase instr

func (*Builder) ForPhrase

func (p *Builder) ForPhrase(f *ForPhrase, key, val *Var, hasExecCtx ...bool) *Builder

ForPhrase instr

func (*Builder) Go

func (p *Builder) Go() exec.Builder

Go instr

func (*Builder) GoBuiltin

func (p *Builder) GoBuiltin(typ reflect.Type, op GoBuiltin) *Builder

GoBuiltin instr

func (*Builder) GoClosure

func (p *Builder) GoClosure(fun *FuncInfo) *Builder

GoClosure instr

func (*Builder) InCurrentCtx

func (p *Builder) InCurrentCtx(v *Var) bool

InCurrentCtx returns if a variable is in current context or not.

func (*Builder) Index

func (p *Builder) Index(idx int) *Builder

Index instr

func (*Builder) Interface

func (p *Builder) Interface() exec.Builder

Interface converts *Builder to exec.Builder interface.

func (*Builder) Jmp

func (p *Builder) Jmp(l *Label) *Builder

Jmp instr

func (*Builder) JmpIf

func (p *Builder) JmpIf(cond exec.JmpCondFlag, l *Label) *Builder

JmpIf instr

func (*Builder) Label

func (p *Builder) Label(l *Label) *Builder

Label defines a label to jmp here.

func (*Builder) ListComprehension

func (p *Builder) ListComprehension(c *Comprehension) *Builder

ListComprehension instr

func (*Builder) Load

func (p *Builder) Load(idx int32) *Builder

Load instr

func (*Builder) LoadField

func (p *Builder) LoadField(typ reflect.Type, index []int) *Builder

LoadField instr

func (*Builder) LoadGoVar

func (p *Builder) LoadGoVar(addr GoVarAddr) *Builder

LoadGoVar instr

func (*Builder) LoadVar

func (p *Builder) LoadVar(v *Var) *Builder

LoadVar instr

func (*Builder) Make

func (p *Builder) Make(typ reflect.Type, arity int) *Builder

Make instr

func (*Builder) MakeArray

func (p *Builder) MakeArray(typ reflect.Type, arity int) *Builder

MakeArray instr

func (*Builder) MakeMap

func (p *Builder) MakeMap(typ reflect.Type, arity int) *Builder

MakeMap instr

func (*Builder) MapComprehension

func (p *Builder) MapComprehension(c *Comprehension) *Builder

MapComprehension instr

func (*Builder) MapIndex

func (p *Builder) MapIndex(twoValue bool) *Builder

MapIndex instr

func (*Builder) New

func (p *Builder) New(typ reflect.Type) *Builder

New instr

func (*Builder) Pop

func (p *Builder) Pop(n int) *Builder

Pop instr

func (*Builder) Push

func (p *Builder) Push(val interface{}) *Builder

Push instr

func (*Builder) Recv

func (p *Builder) Recv() *Builder

Recv instr

func (*Builder) Reserve

func (p *Builder) Reserve() Reserved

Reserve reserves an instruction.

func (*Builder) ReservedAsOpLsh

func (p *Builder) ReservedAsOpLsh(r exec.Reserved, kind exec.Kind, op exec.Operator) *Builder

ReservedAsOpLsh instr

func (*Builder) ReservedAsPush

func (p *Builder) ReservedAsPush(r Reserved, val interface{})

ReservedAsPush sets Reserved as Push(v)

func (*Builder) Resolve

func (p *Builder) Resolve() *Code

Resolve resolves all unresolved labels/functions/consts/etc.

func (*Builder) Return

func (p *Builder) Return(n int32) *Builder

Return instr

func (*Builder) Send

func (p *Builder) Send() *Builder

Send instr

func (*Builder) SetIndex

func (p *Builder) SetIndex(idx int) *Builder

SetIndex instr

func (*Builder) SetMapIndex

func (p *Builder) SetMapIndex() *Builder

SetMapIndex instr

func (*Builder) Slice

func (p *Builder) Slice(i, j int) *Builder

Slice instr

func (*Builder) Slice3

func (p *Builder) Slice3(i, j, k int) *Builder

Slice3 instr

func (*Builder) Store

func (p *Builder) Store(idx int32) *Builder

Store instr

func (*Builder) StoreField

func (p *Builder) StoreField(typ reflect.Type, index []int) *Builder

StoreField instr

func (*Builder) StoreGoVar

func (p *Builder) StoreGoVar(addr GoVarAddr) *Builder

StoreGoVar instr

func (*Builder) StoreVar

func (p *Builder) StoreVar(v *Var) *Builder

StoreVar instr

func (*Builder) Struct

func (p *Builder) Struct(typ reflect.Type, arity int) *Builder

Struct instr

func (*Builder) TypeCast

func (p *Builder) TypeCast(from, to reflect.Type) *Builder

TypeCast instr

func (*Builder) WrapIfErr

func (p *Builder) WrapIfErr(nret int, l *Label) *Builder

WrapIfErr instr

func (*Builder) Zero

func (p *Builder) Zero(typ reflect.Type) *Builder

Zero instr

type Closure

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

Closure represents a Go+ closure.

func (*Closure) Call

func (p *Closure) Call(in []reflect.Value) (out []reflect.Value)

Call calls a closure.

type Code

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

A Code represents generated instructions to execute.

func NewCode

func NewCode() *Code

NewCode returns a new Code object.

func (*Code) Dump

func (p *Code) Dump(w io.Writer)

Dump dumps code.

func (*Code) Len

func (p *Code) Len() int

Len returns code length.

type Comprehension

type Comprehension struct {
	TypeOut reflect.Type
	End     int
}

Comprehension represents a list/map comprehension.

func NewComprehension

func NewComprehension(out reflect.Type) *Comprehension

NewComprehension creates a new Comprehension instance.

type ConstKind

type ConstKind = exec.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

func NewContext(in exec.Code) *Context

NewContext returns a new context of an executor.

func (*Context) Call

func (ctx *Context) Call(f exec.FuncInfo)

Call calls a function.

func (*Context) CloneSetVarScope

func (ctx *Context) CloneSetVarScope(new *Context)

CloneSetVarScope clone already set varScope to new context

func (*Context) Exec

func (ctx *Context) Exec(ip, ipEnd int) (currentIP int)

Exec executes a code block from ip to ipEnd.

func (*Context) GetVar

func (ctx *Context) GetVar(x *Var) interface{}

GetVar func.

func (*Context) Go

func (ctx *Context) Go(arity int, f func(goctx *Context))

Go starts a new goroutine to run.

func (*Context) Run

func (ctx *Context) Run()

Run executes the code.

func (*Context) SetVar

func (ctx *Context) SetVar(x *Var, v interface{})

SetVar func.

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

func NewForPhrase(in reflect.Type) *ForPhrase

NewForPhrase creates a new ForPhrase instance.

type FuncInfo

type FuncInfo struct {
	Pkg *Package
	// contains filtered or unexported fields
}

FuncInfo represents a Go+ function information.

func NewFunc

func NewFunc(name string, nestDepth uint32) *FuncInfo

NewFunc create a Go+ function.

func (*FuncInfo) Args

func (p *FuncInfo) Args(in ...reflect.Type) *FuncInfo

Args sets argument types of a Go+ function.

func (*FuncInfo) IsUnnamedOut

func (p *FuncInfo) IsUnnamedOut() bool

IsUnnamedOut returns if function results unnamed or not.

func (*FuncInfo) IsVariadic

func (p *FuncInfo) IsVariadic() bool

IsVariadic returns if this function is variadic or not.

func (*FuncInfo) Name

func (p *FuncInfo) Name() string

Name returns the function name.

func (*FuncInfo) NumIn

func (p *FuncInfo) NumIn() int

NumIn returns a function's input parameter count.

func (*FuncInfo) NumOut

func (p *FuncInfo) NumOut() int

NumOut returns a function's output parameter count.

func (*FuncInfo) Out

func (p *FuncInfo) Out(i int) *Var

Out returns the type of a function type's i'th output parameter.

func (*FuncInfo) Return

func (p *FuncInfo) Return(out ...*Var) *FuncInfo

Return sets return types of a Go+ function.

func (*FuncInfo) Type

func (p *FuncInfo) Type() reflect.Type

Type returns type of this function.

func (*FuncInfo) Vargs

func (p *FuncInfo) Vargs(in ...reflect.Type) *FuncInfo

Vargs sets argument types of a variadic Go+ function.

type GoBuiltin

type GoBuiltin = exec.GoBuiltin

GoBuiltin represents go builtin func.

type GoConstInfo

type GoConstInfo = exec.GoConstInfo

GoConstInfo represents a Go constant information.

type GoFuncAddr

type GoFuncAddr = exec.GoFuncAddr

GoFuncAddr represents a Go function address.

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 NewGoPackage

func NewGoPackage(pkgPath string) *GoPackage

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) FindType

func (p *GoPackage) FindType(name string) (typ reflect.Type, ok bool)

FindType lookups a Go type by name.

func (*GoPackage) FindVar

func (p *GoPackage) FindVar(name string) (addr GoVarAddr, ok bool)

FindVar lookups a Go variable 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) PkgPath

func (p *GoPackage) PkgPath() string

PkgPath returns the package path for importing.

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

func (p *GoPackage) RegisterVars(vars ...GoVarInfo) (base GoVarAddr)

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.

func (*GoPackage) Type

func (p *GoPackage) Type(name string, typ reflect.Type) GoTypeInfo

Type creates a GoTypeInfo instance.

func (*GoPackage) Var

func (p *GoPackage) Var(name string, addr interface{}) GoVarInfo

Var creates a GoVarInfo instance.

type GoTypeInfo

type GoTypeInfo struct {
	Pkg  *GoPackage
	Name string
	Type reflect.Type
}

GoTypeInfo represents a Go type information.

type GoVarAddr

type GoVarAddr = exec.GoVarAddr

GoVarAddr represents a variadic Go variable address.

type GoVarInfo

type GoVarInfo struct {
	Pkg  *GoPackage
	Name string
	Addr interface{}
}

GoVarInfo represents a Go variable information.

type Instr

type Instr = uint32

A Instr represents a instruction of the executor.

type InstrInfo

type InstrInfo struct {
	Name   string
	Arg1   string
	Arg2   string
	Params uint16
}

InstrInfo represents the information of an instr.

func DecodeInstr

func DecodeInstr(i Instr) (InstrInfo, int32, int32)

DecodeInstr returns

type Kind

type Kind = exec.Kind

A Kind represents the specific kind of type that a Type represents.

type Label

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

Label represents a label.

func NewLabel

func NewLabel(name string) *Label

NewLabel creates a label object.

func (*Label) Name

func (p *Label) Name() string

Name returns the label name.

type Operator

type Operator = exec.Operator

Operator type.

type OperatorInfo

type OperatorInfo = exec.OperatorInfo

OperatorInfo represents an operator information.

type Package

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

Package represents a Go+ package.

func NewPackage

func NewPackage(code *Code) *Package

NewPackage creates a Go+ package instance.

func (*Package) FindGoPackage

func (p *Package) FindGoPackage(pkgPath string) exec.GoPackage

FindGoPackage lookups a Go package by pkgPath. It returns nil if not found.

func (*Package) GetGoFuncInfo

func (p *Package) GetGoFuncInfo(addr exec.GoFuncAddr) *exec.GoFuncInfo

GetGoFuncInfo returns a Go function's information.

func (*Package) GetGoFuncType

func (p *Package) GetGoFuncType(addr exec.GoFuncAddr) reflect.Type

GetGoFuncType returns a Go function's type.

func (*Package) GetGoFuncvInfo

func (p *Package) GetGoFuncvInfo(addr exec.GoFuncvAddr) *exec.GoFuncInfo

GetGoFuncvInfo returns a Go function's information.

func (*Package) GetGoFuncvType

func (p *Package) GetGoFuncvType(addr exec.GoFuncvAddr) reflect.Type

GetGoFuncvType returns a Go function's type.

func (*Package) GetGoVarInfo

func (p *Package) GetGoVarInfo(addr exec.GoVarAddr) *exec.GoVarInfo

GetGoVarInfo returns a Go variable's information.

func (*Package) NewComprehension

func (p *Package) NewComprehension(out reflect.Type) exec.Comprehension

NewComprehension creates a new Comprehension instance.

func (*Package) NewForPhrase

func (p *Package) NewForPhrase(in reflect.Type) exec.ForPhrase

NewForPhrase creates a new ForPhrase instance.

func (*Package) NewFunc

func (p *Package) NewFunc(name string, nestDepth uint32, funcType ...int) exec.FuncInfo

NewFunc create a Go+ function.

func (*Package) NewLabel

func (p *Package) NewLabel(name string) exec.Label

NewLabel creates a label object.

func (*Package) NewVar

func (p *Package) NewVar(typ reflect.Type, name string) exec.Var

NewVar creates a variable instance.

type Reserved

type Reserved = exec.Reserved

Reserved represents a reserved instruction position.

type Stack

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

A Stack represents a FILO container.

func NewStack

func NewStack() (p *Stack)

NewStack creates a Stack instance.

func (*Stack) Get

func (p *Stack) Get(idx int) interface{}

Get returns the value at specified index.

func (*Stack) GetArgs

func (p *Stack) GetArgs(arity int) []interface{}

GetArgs returns all arguments of a function.

func (*Stack) Init

func (p *Stack) Init()

Init initializes this Stack object.

func (*Stack) Len

func (p *Stack) Len() int

Len returns count of stack elements.

func (*Stack) Pop

func (p *Stack) Pop() interface{}

Pop pops a value from this stack.

func (*Stack) PopN

func (p *Stack) PopN(n int)

PopN pops n elements.

func (*Stack) Push

func (p *Stack) Push(v interface{})

Push pushes a value into this stack.

func (*Stack) Ret

func (p *Stack) Ret(arity int, results ...interface{})

Ret pops n values from this stack, and then pushes results.

func (*Stack) Set

func (p *Stack) Set(idx int, v interface{})

Set returns the value at specified index.

func (*Stack) SetLen

func (p *Stack) SetLen(base int)

SetLen sets count of stack elements.

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.

func Struct

func Struct(fields []StructField) *StructInfo

Struct creates a new struct.

func (*StructInfo) Type

func (p *StructInfo) Type() reflect.Type

Type returns the struct type.

type SymbolKind

type SymbolKind = exec.SymbolKind

SymbolKind represents symbol kind.

type Var

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

Var represents a variable.

func NewVar

func NewVar(typ reflect.Type, name string) *Var

NewVar creates a variable instance.

func (*Var) IsUnnamedOut

func (p *Var) IsUnnamedOut() bool

IsUnnamedOut returns if variable unnamed or not.

func (*Var) Name

func (p *Var) Name() string

Name returns variable's name.

func (*Var) SetAddr

func (p *Var) SetAddr(nestDepth, idx uint32)

SetAddr sets a variable address.

func (*Var) Type

func (p *Var) Type() reflect.Type

Type returns variable's type.

Jump to

Keyboard shortcuts

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