Documentation
¶
Overview ¶
Code generated by cmd/genstdlib/main.go; DO NOT EDIT.
Code generated by cmd/genstdlib/main.go; DO NOT EDIT.
Code generated by cmd/genstdlib/main.go; DO NOT EDIT.
Index ¶
- func CallPackageFunction(pkg *Package, functionName string, args []any, optionalVM *VM) ([]any, error)
- func GetModulePath(name, version string) (string, error)
- func LoadGoMod(filename string) (*modfile.File, error)
- func LoadPackage(dir string, optionalConfig *packages.Config) (*packages.Package, error)
- func NewPackageIdent(path, name string) pkgIdent
- func RegisterPackage(pkgPath string, symbols map[string]reflect.Value)
- type ASTBuilder
- type ArrayType
- func (a ArrayType) Eval(vm *VM)
- func (a ArrayType) Flow(g *graphBuilder) (head Step)
- func (a ArrayType) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (a ArrayType) Make(vm *VM, size int, constructorArgs []reflect.Value) reflect.Value
- func (a ArrayType) Pos() token.Pos
- func (a ArrayType) String() string
- type AssignStmt
- type BasicLit
- type BinaryExpr
- type BinaryExpr2
- type BinaryExprFunc
- type BinaryExprValue
- func (b BinaryExprValue) BoolEval(left bool) reflect.Value
- func (b BinaryExprValue) ComplexOpComplex(left, right complex128) reflect.Value
- func (b BinaryExprValue) Eval() reflect.Value
- func (b BinaryExprValue) FloatEval(left float64) reflect.Value
- func (b BinaryExprValue) FloatOpFloat(left float64, right float64) reflect.Value
- func (b BinaryExprValue) IntEval(left int64) reflect.Value
- func (b BinaryExprValue) IntOpInt(left int64, right int64) reflect.Value
- func (b BinaryExprValue) InterfaceEval(left reflect.Value) reflect.Value
- func (b BinaryExprValue) PointerEval(left reflect.Value) reflect.Value
- func (b BinaryExprValue) StringEval(left string) reflect.Value
- func (b BinaryExprValue) UIntEval(left uint64) reflect.Value
- func (b BinaryExprValue) UIntOpUInt(left uint64, right uint64) reflect.Value
- func (b BinaryExprValue) UntypedNilEval(left reflect.Value) reflect.Value
- type BlockStmt
- type BranchStmt
- type CallExpr
- type CanAssign
- type CanCompose
- type CanDeclare
- type CanMake
- type CanSelect
- type CaseClause
- type ChanType
- func (c ChanType) Eval(vm *VM)
- func (c ChanType) Flow(g *graphBuilder) (head Step)
- func (c ChanType) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (c ChanType) Make(vm *VM, buffer int, constructorArgs []reflect.Value) reflect.Value
- func (c ChanType) Pos() token.Pos
- func (c ChanType) String() string
- type CompositeLit
- type ConstDecl
- type Decl
- type DeclStmt
- type DeferStmt
- type Ellipsis
- type Env
- type Environment
- type Evaluable
- type Expr
- type ExprStmt
- type ExternalPackage
- type Field
- type FieldAssignable
- type FieldList
- type Flowable
- type ForStmt
- type Func
- type FuncDecl
- func (f *FuncDecl) Eval(vm *VM)
- func (f *FuncDecl) Flow(g *graphBuilder) (head Step)
- func (f *FuncDecl) GotoReference(label string) statementReference
- func (f *FuncDecl) HasRecoverCall() bool
- func (f *FuncDecl) Params() *FieldList
- func (f FuncDecl) Pos() token.Pos
- func (f *FuncDecl) PutGotoReference(label string, ref statementReference)
- func (f *FuncDecl) Results() *FieldList
- func (f *FuncDecl) SetHasRecoverCall(bool)
- func (f FuncDecl) String() string
- type FuncLit
- func (f *FuncLit) Eval(vm *VM)
- func (f *FuncLit) Flow(g *graphBuilder) (head Step)
- func (f *FuncLit) GotoReference(label string) statementReference
- func (f *FuncLit) HasRecoverCall() bool
- func (f *FuncLit) Params() *FieldList
- func (f *FuncLit) Pos() token.Pos
- func (f *FuncLit) PutGotoReference(label string, ref statementReference)
- func (f *FuncLit) Results() *FieldList
- func (f *FuncLit) SetHasRecoverCall(bool)
- func (f *FuncLit) String() string
- type FuncType
- type Heap
- type HeapPointer
- type Ident
- type IfStmt
- type IncDecFunc
- type IncDecStmt
- type IndexExpr
- type KeyValueExpr
- type LabeledStmt
- type MapType
- func (m MapType) Eval(vm *VM)
- func (m MapType) Flow(g *graphBuilder) (head Step)
- func (m MapType) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (m MapType) Make(vm *VM, _ int, constructorArgs []reflect.Value) reflect.Value
- func (m MapType) Pos() token.Pos
- func (m MapType) String() string
- type Package
- type ParenExpr
- type PkgEnvironment
- type RangeStmt
- func (r RangeStmt) Eval(vm *VM)
- func (r RangeStmt) Flow(g *graphBuilder) (head Step)
- func (r RangeStmt) IntFlow(g *graphBuilder) (head Step)
- func (r RangeStmt) MapFlow(g *graphBuilder) (head Step)
- func (r RangeStmt) Pos() token.Pos
- func (r RangeStmt) SliceOrArrayFlow(g *graphBuilder) (head Step)
- func (r RangeStmt) String() string
- type ReturnStmt
- type SDKPackage
- type SelectorExpr
- type SendStmt
- type SliceExpr
- type StarExpr
- type Step
- type StepTaker
- type Stmt
- type StructType
- func (s StructType) Eval(vm *VM)
- func (s StructType) Flow(g *graphBuilder) (head Step)
- func (s StructType) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (s StructType) Make(vm *VM, size int, constructorArgs []reflect.Value) reflect.Value
- func (s StructType) Pos() token.Pos
- func (s StructType) String() string
- type StructValue
- func (i *StructValue) Assign(fieldName string, val reflect.Value)
- func (i *StructValue) Format(f fmt.State, verb rune)
- func (i *StructValue) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (i *StructValue) MarshalJSON() ([]byte, error)
- func (i *StructValue) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (i *StructValue) Select(name string) reflect.Value
- func (i *StructValue) String() string
- func (i *StructValue) UnmarshalJSON(data []byte) error
- type StructValueWrapper
- type SwitchStmt
- type Traverseable
- type TypeAssertExpr
- type TypeSpec
- func (s TypeSpec) Eval(vm *VM)
- func (s TypeSpec) Flow(g *graphBuilder) (head Step)
- func (s TypeSpec) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
- func (s TypeSpec) Make(vm *VM, _ int, constructorArgs []reflect.Value) reflect.Value
- func (s TypeSpec) Pos() token.Pos
- func (s TypeSpec) String() string
- type TypeSwitchStmt
- type UnaryExpr
- type UnaryExprFunc
- type VM
- type ValueSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallPackageFunction ¶
func GetModulePath ¶
https://stackoverflow.com/questions/67211875/how-to-get-the-path-to-a-go-module-dependency
func LoadPackage ¶
func NewPackageIdent ¶
func NewPackageIdent(path, name string) pkgIdent
NewPackageIdent allow plugins to add bindings.
Types ¶
type ASTBuilder ¶
type ASTBuilder struct {
// contains filtered or unexported fields
}
func (*ASTBuilder) Err ¶
func (b *ASTBuilder) Err() error
type ArrayType ¶
func (ArrayType) Eval ¶
Eval creates and pushes an instance of the array or slice type onto the operand stack.
func (ArrayType) LiteralCompose ¶
func (a ArrayType) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
composite is (a reflect on) a Go array or slice
type AssignStmt ¶
type AssignStmt struct {
TokPos token.Pos // position of Tok
Tok token.Token // assignment token, DEFINE
Lhs []Expr
Rhs []Expr
// contains filtered or unexported fields
}
func (AssignStmt) Eval ¶
func (a AssignStmt) Eval(vm *VM)
func (AssignStmt) Pos ¶
func (a AssignStmt) Pos() token.Pos
func (AssignStmt) String ¶
func (a AssignStmt) String() string
type BinaryExpr ¶
type BinaryExpr struct {
OpPos token.Pos // position of Op
Op token.Token // operator
X Expr // left
Y Expr // right
}
func (BinaryExpr) Eval ¶
func (b BinaryExpr) Eval(vm *VM)
func (BinaryExpr) Flow ¶
func (b BinaryExpr) Flow(g *graphBuilder) (head Step)
func (BinaryExpr) Pos ¶
func (b BinaryExpr) Pos() token.Pos
func (BinaryExpr) String ¶
func (b BinaryExpr) String() string
type BinaryExpr2 ¶
type BinaryExpr2 struct {
OpPos token.Pos
Op token.Token
X Expr // left
Y Expr // right
// contains filtered or unexported fields
}
func (BinaryExpr2) Eval ¶
func (b BinaryExpr2) Eval(vm *VM)
func (BinaryExpr2) Flow ¶
func (b BinaryExpr2) Flow(g *graphBuilder) (head Step)
func (BinaryExpr2) Pos ¶
func (b BinaryExpr2) Pos() token.Pos
func (BinaryExpr2) String ¶
func (b BinaryExpr2) String() string
type BinaryExprValue ¶
type BinaryExprValue struct {
// contains filtered or unexported fields
}
func (BinaryExprValue) ComplexOpComplex ¶
func (b BinaryExprValue) ComplexOpComplex(left, right complex128) reflect.Value
func (BinaryExprValue) Eval ¶
func (b BinaryExprValue) Eval() reflect.Value
func (BinaryExprValue) FloatOpFloat ¶
func (b BinaryExprValue) FloatOpFloat(left float64, right float64) reflect.Value
func (BinaryExprValue) IntOpInt ¶
func (b BinaryExprValue) IntOpInt(left int64, right int64) reflect.Value
func (BinaryExprValue) InterfaceEval ¶
func (b BinaryExprValue) InterfaceEval(left reflect.Value) reflect.Value
func (BinaryExprValue) PointerEval ¶
func (b BinaryExprValue) PointerEval(left reflect.Value) reflect.Value
func (BinaryExprValue) StringEval ¶
func (b BinaryExprValue) StringEval(left string) reflect.Value
func (BinaryExprValue) UIntOpUInt ¶
func (b BinaryExprValue) UIntOpUInt(left uint64, right uint64) reflect.Value
func (BinaryExprValue) UntypedNilEval ¶
func (b BinaryExprValue) UntypedNilEval(left reflect.Value) reflect.Value
type BranchStmt ¶
type BranchStmt struct {
TokPos token.Pos // position of Tok
Tok token.Token // keyword token (BREAK, CONTINUE, GOTO, FALLTHROUGH)
Label *Ident
}
BranchStmt represents a break, continue, goto, or fallthrough statement.
func (BranchStmt) Eval ¶
func (s BranchStmt) Eval(vm *VM)
func (BranchStmt) Flow ¶
func (s BranchStmt) Flow(g *graphBuilder) (head Step)
func (BranchStmt) Pos ¶
func (s BranchStmt) Pos() token.Pos
func (BranchStmt) String ¶
func (s BranchStmt) String() string
type CallExpr ¶
type CanCompose ¶
type CanDeclare ¶
type CanDeclare interface {
// Declare declares the variable in the current environment.
// It returns true if the declaration set a valid reflect Value.
Declare(vm *VM) bool
CallGraph() Step
}
TODO only ValueSpec implements CanDeclare
type CanSelect ¶
CanSelect is implemented by types that support selection of fields or methods by name.
type CaseClause ¶
type CaseClause struct {
CasePos token.Pos // position of "case" or "default" keyword
List []Expr // list of expressions; nil means default case
Body []Stmt
}
A CaseClause represents a case of an expression or type switch statement.
func (CaseClause) Eval ¶
func (c CaseClause) Eval(vm *VM)
func (CaseClause) Flow ¶
func (c CaseClause) Flow(g *graphBuilder) (head Step)
func (CaseClause) Pos ¶
func (c CaseClause) Pos() token.Pos
func (CaseClause) String ¶
func (c CaseClause) String() string
type ChanType ¶
type ChanType struct {
Begin token.Pos // position of "chan" keyword or "<-" (whichever comes first)
Arrow token.Pos // position of "<-" (token.NoPos if there is no "<-")
Dir ast.ChanDir // channel direction
Value Expr // value type
}
func (ChanType) LiteralCompose ¶
type CompositeLit ¶
type CompositeLit struct {
Lbrace token.Pos // position of "{"
Type Expr // literal type; or nil
ParserType types.Type // literal type; or nil
Elts []Expr // list of composite elements; or nil
}
func (CompositeLit) Eval ¶
func (c CompositeLit) Eval(vm *VM)
func (CompositeLit) Flow ¶
func (c CompositeLit) Flow(g *graphBuilder) (head Step)
func (CompositeLit) Pos ¶
func (c CompositeLit) Pos() token.Pos
func (CompositeLit) String ¶
func (c CompositeLit) String() string
type ConstDecl ¶
type ConstDecl struct {
Specs []ValueSpec
// contains filtered or unexported fields
}
type Ellipsis ¶
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func (*Environment) String ¶
func (e *Environment) String() string
type ExternalPackage ¶
type ExternalPackage struct {
SDKPackage
}
func (ExternalPackage) String ¶
func (p ExternalPackage) String() string
type Field ¶
type FieldAssignable ¶
type Flowable ¶
type Flowable interface {
// Flow builds the control flow graph using the provided grapher.
// Head is the entry point to that call flow graph.
Flow(g *graphBuilder) (head Step)
}
type Func ¶
type Func interface {
SetHasRecoverCall(bool)
HasRecoverCall() bool
PutGotoReference(label string, ref statementReference)
GotoReference(label string) statementReference
Results() *FieldList
Params() *FieldList
}
FuncDecl and FuncLit implement this
type FuncDecl ¶
type FuncDecl struct {
Name *Ident
Recv *FieldList // non-nil for methods
Body *BlockStmt
Type *FuncType
// contains filtered or unexported fields
}
func (*FuncDecl) GotoReference ¶
func (*FuncDecl) HasRecoverCall ¶
func (*FuncDecl) PutGotoReference ¶
func (*FuncDecl) SetHasRecoverCall ¶
type FuncLit ¶
type FuncLit struct {
Type *FuncType
Body *BlockStmt // TODO not sure what to do when Body and/or Type is nil
// contains filtered or unexported fields
}
func (*FuncLit) GotoReference ¶
func (*FuncLit) HasRecoverCall ¶
func (*FuncLit) PutGotoReference ¶
func (*FuncLit) SetHasRecoverCall ¶
type FuncType ¶
type HeapPointer ¶
type HeapPointer struct {
Addr uintptr // unique address in the heap
Type reflect.Type // type of the pointed-to value
EnvRef Env // if non-nil, this points to a variable in an environment
EnvVarName string // the variable name in the environment
}
HeapPointer represents a pointer to a value stored in the VM's heap. This is used to handle pointer escape analysis - when a local variable's address is taken, it needs to survive beyond its scope.
func (HeapPointer) String ¶
func (hp HeapPointer) String() string
String formats the HeapPointer to look like a real pointer address.
func (*HeapPointer) UnmarshalJSON ¶
func (hp *HeapPointer) UnmarshalJSON(data []byte) error
type Ident ¶
func (Ident) Assignable ¶
type IncDecStmt ¶
func (IncDecStmt) Eval ¶
func (i IncDecStmt) Eval(vm *VM)
func (IncDecStmt) Flow ¶
func (i IncDecStmt) Flow(g *graphBuilder) (head Step)
func (IncDecStmt) Pos ¶
func (i IncDecStmt) Pos() token.Pos
func (IncDecStmt) String ¶
func (i IncDecStmt) String() string
type KeyValueExpr ¶
func (KeyValueExpr) Eval ¶
func (k KeyValueExpr) Eval(vm *VM)
func (KeyValueExpr) Flow ¶
func (k KeyValueExpr) Flow(g *graphBuilder) (head Step)
func (KeyValueExpr) Pos ¶
func (k KeyValueExpr) Pos() token.Pos
func (KeyValueExpr) String ¶
func (k KeyValueExpr) String() string
type LabeledStmt ¶
LabeledStmt represents a labeled statement. https://go.dev/ref/spec#Labeled_statements https://go.dev/ref/spec#Label_scopes
func (LabeledStmt) Eval ¶
func (s LabeledStmt) Eval(vm *VM)
func (LabeledStmt) Flow ¶
func (s LabeledStmt) Flow(g *graphBuilder) (head Step)
func (LabeledStmt) Pos ¶
func (s LabeledStmt) Pos() token.Pos
func (LabeledStmt) String ¶
func (s LabeledStmt) String() string
type Package ¶
type Package struct {
*packages.Package // TODO look for actual data used here
Env *PkgEnvironment
Initialized bool
}
func ParseSource ¶
func (*Package) Initialize ¶
type PkgEnvironment ¶
type PkgEnvironment struct {
Env
// contains filtered or unexported fields
}
func (*PkgEnvironment) String ¶
func (p *PkgEnvironment) String() string
type RangeStmt ¶
type RangeStmt struct {
ForPos token.Pos
Tok token.Token // ILLEGAL if Key == nil, ASSIGN, DEFINE
Key, Value Expr // Key, Value may be nil
X Expr
XType types.Type // depending on type, different flows are created
Body *BlockStmt
}
func (RangeStmt) Flow ¶
Flow builds the control flow graph for the RangeStmt. Based on the Kind of X, it will branch into one of three flows:
- mapFlow for maps
- sliceOrArrayFlow for slices and arrays
- intFlow for integers
- funcFlow for functions of type iter.Seq[V any], iter.Seq2[K comparable, V any]
All four flows converge to a done step. The last 3 subflows are transformed into a ForStmt that uses a hidden index variable.
func (RangeStmt) SliceOrArrayFlow ¶
type ReturnStmt ¶
func (ReturnStmt) Eval ¶
func (r ReturnStmt) Eval(vm *VM)
func (ReturnStmt) Flow ¶
func (r ReturnStmt) Flow(g *graphBuilder) (head Step)
func (ReturnStmt) Pos ¶
func (r ReturnStmt) Pos() token.Pos
func (ReturnStmt) String ¶
func (r ReturnStmt) String() string
type SDKPackage ¶
func (SDKPackage) String ¶
func (p SDKPackage) String() string
type SelectorExpr ¶
type SelectorExpr struct {
*ast.SelectorExpr
X Expr
}
func (SelectorExpr) Eval ¶
func (s SelectorExpr) Eval(vm *VM)
func (SelectorExpr) Flow ¶
func (s SelectorExpr) Flow(g *graphBuilder) (head Step)
func (SelectorExpr) String ¶
func (s SelectorExpr) String() string
type SliceExpr ¶
type Stmt ¶
type Stmt interface {
Flowable
// contains filtered or unexported methods
}
All statement nodes implement the Stmt interface.
type StructType ¶
type StructType struct {
StructPos token.Pos
Name string
Fields *FieldList
// contains filtered or unexported fields
}
func (StructType) Eval ¶
func (s StructType) Eval(vm *VM)
func (StructType) Flow ¶
func (s StructType) Flow(g *graphBuilder) (head Step)
func (StructType) LiteralCompose ¶
func (StructType) Pos ¶
func (s StructType) Pos() token.Pos
func (StructType) String ¶
func (s StructType) String() string
type StructValue ¶
type StructValue struct {
// contains filtered or unexported fields
}
StructValue represents an instance of an interpreted struct.
func NewStructValue ¶
func NewStructValue(vm *VM, t StructType) *StructValue
NewStructValue creates a new StructValue of the given StructType.
func (*StructValue) LiteralCompose ¶
func (i *StructValue) LiteralCompose(vm *VM, composite reflect.Value, values []reflect.Value) reflect.Value
composite is (a reflect on) an StructValue
func (*StructValue) MarshalJSON ¶
func (i *StructValue) MarshalJSON() ([]byte, error)
func (*StructValue) MarshalXML ¶
func (i *StructValue) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
func (*StructValue) Select ¶
func (i *StructValue) Select(name string) reflect.Value
TODO maybe return extra bool for ok?
func (*StructValue) String ¶
func (i *StructValue) String() string
TODO must call String method of StructType if present and if not use default behavior
func (*StructValue) UnmarshalJSON ¶
func (i *StructValue) UnmarshalJSON(data []byte) error
type StructValueWrapper ¶
type StructValueWrapper struct {
// contains filtered or unexported fields
}
type SwitchStmt ¶
type SwitchStmt struct {
*ast.SwitchStmt
Init Stmt // initialization statement; or nil
Tag Expr // tag expression; or nil
Body BlockStmt
}
A SwitchStmt represents an expression switch statement.
func (SwitchStmt) Eval ¶
func (s SwitchStmt) Eval(vm *VM)
func (SwitchStmt) Flow ¶
func (s SwitchStmt) Flow(g *graphBuilder) (head Step)
func (SwitchStmt) String ¶
func (s SwitchStmt) String() string
type Traverseable ¶
type TypeAssertExpr ¶
type TypeAssertExpr struct {
X Expr
Type Expr // asserted type; nil means type switch X.(type)
Lparen token.Pos
}
func (TypeAssertExpr) Eval ¶
func (e TypeAssertExpr) Eval(vm *VM)
func (TypeAssertExpr) Flow ¶
func (e TypeAssertExpr) Flow(g *graphBuilder) (head Step)
func (TypeAssertExpr) Pos ¶
func (e TypeAssertExpr) Pos() token.Pos
func (TypeAssertExpr) String ¶
func (e TypeAssertExpr) String() string
type TypeSwitchStmt ¶
type TypeSwitchStmt struct {
SwitchPos token.Pos
Init Stmt // initialization statement; or nil
Assign Stmt // x := y.(type) or y.(type)
Body *BlockStmt
}
func (TypeSwitchStmt) Eval ¶
func (s TypeSwitchStmt) Eval(vm *VM)
func (TypeSwitchStmt) Flow ¶
func (s TypeSwitchStmt) Flow(g *graphBuilder) (head Step)
func (TypeSwitchStmt) Pos ¶
func (s TypeSwitchStmt) Pos() token.Pos
func (TypeSwitchStmt) String ¶
func (s TypeSwitchStmt) String() string
type UnaryExpr ¶
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
Runtime represents a virtual machine that can execute Go code.
Source Files
¶
- array.go
- assign.go
- ast_builder.go
- binary.go
- binary2.go
- binary_funcs.go
- call.go
- call_builtin.go
- concurrency.go
- converters.go
- debug_adapter.go
- decl.go
- env.go
- field.go
- for.go
- func.go
- gomod.go
- graph_builder.go
- heap.go
- ident.go
- if.go
- incdec.go
- incdec_funcs.go
- index.go
- interfaces.go
- keyvalue.go
- literal.go
- package.go
- range.go
- return.go
- selector.go
- stack.go
- star.go
- stdlib_builtin_funcs.go
- stdlib_builtin_types.go
- stdlib_funcs_generated.go
- stdlib_names_generated.go
- stdlib_types_generated.go
- step.go
- stmt.go
- struct_value.go
- struct_value_interfaces.go
- switch.go
- type.go
- unary.go
- unary_funcs.go
- utils.go
- var.go
- vm.go
Directories
¶
| Path | Synopsis |
|---|---|
|
perftests
|
|
|
tengobench
command
|
|
|
walkprofile
command
|
|
|
testexamples
|
|
|
stackonpanic
command
|