internal

package
v0.0.0-...-895d70b Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: MIT Imports: 122 Imported by: 0

Documentation

Overview

Code generated by cmd/genstdlib/main.go; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadPackage

func LoadPackage(absolutePath string, optionalConfig *packages.Config) (*packages.Package, error)

func Map

func Map[T, U any](ts []T, f func(T) U) []U

func RunPackageFunction

func RunPackageFunction(pkg *Package, functionName string, optionalVM *VM) error

func WalkPackageFunction

func WalkPackageFunction(pkg *Package, functionName string, optionalVM *VM) error

Types

type ArrayType

type ArrayType struct {
	*ast.ArrayType
	Len Expr
	Elt Expr
}

func (ArrayType) Eval

func (a ArrayType) Eval(vm *VM)

used?

func (ArrayType) Flow

func (a ArrayType) Flow(g *graphBuilder) (head Step)

func (ArrayType) Instantiate

func (a ArrayType) Instantiate(vm *VM) reflect.Value

func (ArrayType) LiteralCompose

func (a ArrayType) LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value

composite is (a reflect on) a Go array or slice

func (ArrayType) String

func (a ArrayType) String() string

type AssignStmt

type AssignStmt struct {
	*ast.AssignStmt
	Lhs []Expr
	Rhs []Expr
}

func (AssignStmt) Eval

func (a AssignStmt) Eval(vm *VM)

func (AssignStmt) Flow

func (a AssignStmt) Flow(g *graphBuilder) (head Step)

func (AssignStmt) String

func (a AssignStmt) String() string

type BasicLit

type BasicLit struct {
	*ast.BasicLit
}

func (BasicLit) Eval

func (s BasicLit) Eval(vm *VM)

func (BasicLit) Flow

func (s BasicLit) Flow(g *graphBuilder) (head Step)

func (BasicLit) Loc

func (s BasicLit) Loc(f *token.File) string

func (BasicLit) String

func (s BasicLit) String() string

type BinaryExpr

type BinaryExpr struct {
	*ast.BinaryExpr
	X Expr // left
	Y Expr // right
}

func (BinaryExpr) Eval

func (s BinaryExpr) Eval(vm *VM)

func (BinaryExpr) Flow

func (s BinaryExpr) Flow(g *graphBuilder) (head Step)

func (BinaryExpr) String

func (s BinaryExpr) String() string

type BinaryExprValue

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

func (BinaryExprValue) BoolEval

func (b BinaryExprValue) BoolEval(left bool) reflect.Value

func (BinaryExprValue) ComplexOpComplex

func (b BinaryExprValue) ComplexOpComplex(left, right complex128) reflect.Value

func (BinaryExprValue) Eval

func (b BinaryExprValue) Eval() reflect.Value

func (BinaryExprValue) FloatEval

func (b BinaryExprValue) FloatEval(left float64) reflect.Value

func (BinaryExprValue) FloatOpFloat

func (b BinaryExprValue) FloatOpFloat(left float64, right float64) reflect.Value

func (BinaryExprValue) IntEval

func (b BinaryExprValue) IntEval(left int64) reflect.Value

func (BinaryExprValue) IntOpInt

func (b BinaryExprValue) IntOpInt(left int64, right int64) reflect.Value

func (BinaryExprValue) IsValid

func (b BinaryExprValue) IsValid() bool

func (BinaryExprValue) StringEval

func (b BinaryExprValue) StringEval(left string) reflect.Value

func (BinaryExprValue) UIntEval

func (b BinaryExprValue) UIntEval(left uint64) reflect.Value

func (BinaryExprValue) UIntOpUInt

func (b BinaryExprValue) UIntOpUInt(left uint64, right uint64) reflect.Value

type BlockStmt

type BlockStmt struct {
	*ast.BlockStmt
	List []Stmt
}

func (BlockStmt) Eval

func (b BlockStmt) Eval(vm *VM)

func (BlockStmt) Flow

func (b BlockStmt) Flow(g *graphBuilder) (head Step)

func (BlockStmt) String

func (b BlockStmt) String() string

type BranchStmt

type BranchStmt struct {
	*ast.BranchStmt
	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) String

func (s BranchStmt) String() string

type CallExpr

type CallExpr struct {
	*ast.CallExpr
	Fun  Expr
	Args []Expr
}

func (CallExpr) Eval

func (c CallExpr) Eval(vm *VM)

func (CallExpr) Flow

func (c CallExpr) Flow(g *graphBuilder) (head Step)

func (CallExpr) String

func (c CallExpr) String() string

type CanAssign

type CanAssign interface {
	// =
	Assign(vm *VM, value reflect.Value)
	// :=
	Define(vm *VM, value reflect.Value)
}

type CanCompose

type CanCompose interface {
	LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value
}

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
}

type CanInstantiate

type CanInstantiate interface {
	Instantiate(vm *VM) reflect.Value // , typeArgs []reflect.Type) reflect.Value
	LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value
}

type CaseClause

type CaseClause struct {
	*ast.CaseClause
	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) String

func (c CaseClause) String() string

type CompositeLit

type CompositeLit struct {
	*ast.CompositeLit
	Type Expr
	Elts []Expr
}

func (CompositeLit) Eval

func (s CompositeLit) Eval(vm *VM)

func (CompositeLit) Flow

func (s CompositeLit) Flow(g *graphBuilder) (head Step)

func (CompositeLit) String

func (s CompositeLit) String() string

type ConstOrVar

type ConstOrVar struct {
	*ast.ValueSpec
	// for each Name in ValueSpec there is a ConstOrVar
	Name  *Ident
	Type  Expr
	Value Expr
}

func (ConstOrVar) Assign

func (v ConstOrVar) Assign(vm *VM, value reflect.Value)

func (ConstOrVar) Declare

func (v ConstOrVar) Declare(vm *VM) bool

func (ConstOrVar) Define

func (v ConstOrVar) Define(vm *VM, value reflect.Value)

func (ConstOrVar) Eval

func (v ConstOrVar) Eval(vm *VM)

func (ConstOrVar) Flow

func (v ConstOrVar) Flow(g *graphBuilder) (head Step)

func (ConstOrVar) String

func (v ConstOrVar) String() string

type Decl

type Decl interface {
	Flowable
	// contains filtered or unexported methods
}

type DeclStmt

type DeclStmt struct {
	*ast.DeclStmt
	Decl Decl
}

func (DeclStmt) Eval

func (s DeclStmt) Eval(vm *VM)

func (DeclStmt) Flow

func (s DeclStmt) Flow(g *graphBuilder) (head Step)

func (DeclStmt) String

func (s DeclStmt) String() string

type DeferStmt

type DeferStmt struct {
	*ast.DeferStmt
	Call Expr
}

func (DeferStmt) Eval

func (d DeferStmt) Eval(vm *VM)

func (DeferStmt) Flow

func (d DeferStmt) Flow(g *graphBuilder) (head Step)

func (DeferStmt) String

func (d DeferStmt) String() string

type Ellipsis

type Ellipsis struct {
	*ast.Ellipsis
	Elt Expr // ellipsis element type (parameter lists only); or nil
}

func (Ellipsis) Eval

func (e Ellipsis) Eval(vm *VM)

func (Ellipsis) String

func (e Ellipsis) String() string

type Env

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

type Environment

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

func (*Environment) String

func (e *Environment) String() string

type Evaluable

type Evaluable interface {
	Eval(vm *VM)
}

type Expr

type Expr interface {
	Flowable
	Evaluable
}

type ExprStmt

type ExprStmt struct {
	*ast.ExprStmt
	X Expr
}

func (ExprStmt) Eval

func (s ExprStmt) Eval(vm *VM)

func (ExprStmt) Flow

func (s ExprStmt) Flow(g *graphBuilder) (head Step)

func (ExprStmt) String

func (s ExprStmt) String() string

type Field

type Field struct {
	*ast.Field
	Names []*Ident
	Type  Expr
}

func (Field) Eval

func (l Field) Eval(vm *VM)

func (Field) String

func (l Field) String() string

type FieldList

type FieldList struct {
	*ast.FieldList
	List []*Field
}

func (FieldList) Eval

func (l FieldList) Eval(vm *VM)

func (FieldList) String

func (l FieldList) String() string

type FieldSelectable

type FieldSelectable interface {
	Select(name string) reflect.Value
}

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 ForStmt

type ForStmt struct {
	*ast.ForStmt
	Init Stmt
	Cond Expr
	Post Stmt
	Body *BlockStmt
}

func (ForStmt) Eval

func (f ForStmt) Eval(vm *VM)

func (ForStmt) Flow

func (f ForStmt) Flow(g *graphBuilder) (head Step)

func (ForStmt) String

func (f ForStmt) String() string

type FuncDecl

type FuncDecl struct {
	*ast.FuncDecl
	Name *Ident
	Recv *FieldList
	Body *BlockStmt
	Type *FuncType
	// contains filtered or unexported fields
}

func (FuncDecl) Eval

func (f FuncDecl) Eval(vm *VM)

func (FuncDecl) Flow

func (f FuncDecl) Flow(g *graphBuilder) (head Step)

func (FuncDecl) String

func (f FuncDecl) String() string

type FuncLit

type FuncLit struct {
	*ast.FuncLit
	Type *FuncType
	Body *BlockStmt // TODO not sure what to do when Body and/or Type is nil
	// contains filtered or unexported fields
}

func (FuncLit) Eval

func (s FuncLit) Eval(vm *VM)

func (FuncLit) Flow

func (s FuncLit) Flow(g *graphBuilder) (head Step)

func (FuncLit) String

func (s FuncLit) String() string

type FuncType

type FuncType struct {
	*ast.FuncType
	TypeParams *FieldList
	Params     *FieldList
	Returns    *FieldList
}

func (FuncType) Eval

func (t FuncType) Eval(vm *VM)

func (FuncType) String

func (t FuncType) String() string

type HasZeroValue

type HasZeroValue interface {
	ZeroValue(env Env) reflect.Value
}

type Ident

type Ident struct {
	*ast.Ident
}

func (Ident) Assign

func (i Ident) Assign(vm *VM, value reflect.Value)

func (Ident) Define

func (i Ident) Define(vm *VM, value reflect.Value)

func (Ident) Eval

func (i Ident) Eval(vm *VM)

func (Ident) Flow

func (i Ident) Flow(g *graphBuilder) (head Step)

func (Ident) String

func (i Ident) String() string

func (Ident) ZeroValue

func (i Ident) ZeroValue(env Env) reflect.Value

ZeroValue returns the zero value iff the Ident represents a standard type.

type IfStmt

type IfStmt struct {
	*ast.IfStmt
	Init Expr
	Cond Expr
	Body *BlockStmt
	Else Stmt // else if ...
}

func (IfStmt) Eval

func (i IfStmt) Eval(vm *VM)

func (IfStmt) Flow

func (i IfStmt) Flow(g *graphBuilder) (head Step)

func (IfStmt) String

func (i IfStmt) String() string

type ImportSpec

type ImportSpec struct {
	*ast.ImportSpec
}

type IncDecStmt

type IncDecStmt struct {
	*ast.IncDecStmt
	X Expr
}

func (IncDecStmt) Eval

func (i IncDecStmt) Eval(vm *VM)

func (IncDecStmt) Flow

func (i IncDecStmt) Flow(g *graphBuilder) (head Step)

func (IncDecStmt) String

func (i IncDecStmt) String() string

type IndexExpr

type IndexExpr struct {
	*ast.IndexExpr
	X     Expr
	Index Expr
}

func (IndexExpr) Assign

func (i IndexExpr) Assign(vm *VM, value reflect.Value)

func (IndexExpr) Define

func (i IndexExpr) Define(vm *VM, value reflect.Value)

func (IndexExpr) Eval

func (i IndexExpr) Eval(vm *VM)

func (IndexExpr) Flow

func (i IndexExpr) Flow(g *graphBuilder) (head Step)

func (IndexExpr) String

func (i IndexExpr) String() string

type Instance

type Instance struct {
	Type StructType
	// contains filtered or unexported fields
}

first for struct

func NewInstance

func NewInstance(vm *VM, t StructType) Instance

func (Instance) LiteralCompose

func (i Instance) LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value

composite is (a reflect on) an Instance

func (Instance) Select

func (i Instance) Select(name string) reflect.Value

func (Instance) String

func (i Instance) String() string

type KeyValue

type KeyValue struct {
	Key   reflect.Value
	Value reflect.Value
}

func (KeyValue) String

func (k KeyValue) String() string

type KeyValueExpr

type KeyValueExpr struct {
	*ast.KeyValueExpr
	Key   Expr
	Value Expr
}

func (KeyValueExpr) Eval

func (e KeyValueExpr) Eval(vm *VM)

func (KeyValueExpr) Flow

func (e KeyValueExpr) Flow(g *graphBuilder) (head Step)

func (KeyValueExpr) String

func (e KeyValueExpr) String() string

type LabeledStmt

type LabeledStmt struct {
	*ast.LabeledStmt
	Label *Ident
	Stmt  Stmt
}

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

func (s LabeledStmt) String() string

type MapType

type MapType struct {
	*ast.MapType
	Key   Expr
	Value Expr
}

func (MapType) Eval

func (m MapType) Eval(vm *VM)

func (MapType) Flow

func (m MapType) Flow(g *graphBuilder) (head Step)

func (MapType) Instantiate

func (m MapType) Instantiate(vm *VM) reflect.Value

func (MapType) LiteralCompose

func (m MapType) LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value

func (MapType) String

func (m MapType) String() string

type Package

type Package struct {
	*packages.Package
	Env         *PkgEnvironment
	Initialized bool
}

func BuildPackage

func BuildPackage(pkg *packages.Package, isStepping bool) (*Package, error)

func BuildPackageFromAST

func BuildPackageFromAST(ast *ast.File, isStepping bool) (*Package, error)

func ParseSource

func ParseSource(source string) (*Package, error)

func (*Package) Initialize

func (p *Package) Initialize(vm *VM) error

func (*Package) Select

func (p *Package) Select(name string) reflect.Value

func (*Package) String

func (p *Package) String() string

type PkgEnvironment

type PkgEnvironment struct {
	Env
	// contains filtered or unexported fields
}

func (*PkgEnvironment) String

func (p *PkgEnvironment) String() string

type RangeStmt

type RangeStmt struct {
	*ast.RangeStmt
	Key, Value Expr // Key, Value may be nil
	X          Expr
	Body       *BlockStmt
}

func (RangeStmt) Eval

func (r RangeStmt) Eval(vm *VM)

func (RangeStmt) Flow

func (r RangeStmt) Flow(g *graphBuilder) (head Step)

func (RangeStmt) String

func (r RangeStmt) String() string

type ReflectLenExpr

type ReflectLenExpr struct {
	// TODO position info
	X Expr
}

func (ReflectLenExpr) Eval

func (r ReflectLenExpr) Eval(vm *VM)

func (ReflectLenExpr) Flow

func (r ReflectLenExpr) Flow(g *graphBuilder) (head Step)

func (ReflectLenExpr) String

func (r ReflectLenExpr) String() string

type ReturnStmt

type ReturnStmt struct {
	*ast.ReturnStmt
	Results []Expr
}

func (ReturnStmt) Eval

func (r ReturnStmt) Eval(vm *VM)

func (ReturnStmt) Flow

func (r ReturnStmt) Flow(g *graphBuilder) (head Step)

func (ReturnStmt) String

func (r ReturnStmt) 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 StandardPackage

type StandardPackage struct {
	Name    string
	PkgPath string
	// contains filtered or unexported fields
}

func (StandardPackage) Select

func (p StandardPackage) Select(name string) reflect.Value

func (StandardPackage) String

func (p StandardPackage) String() string

type StarExpr

type StarExpr struct {
	X Expr
	*ast.StarExpr
}

func (StarExpr) Assign

func (s StarExpr) Assign(vm *VM, value reflect.Value)

func (StarExpr) Eval

func (s StarExpr) Eval(vm *VM)

func (StarExpr) String

func (s StarExpr) String() string

type Step

type Step interface {
	Evaluable
	StepTaker
	Traverseable
	SetNext(s Step)
	Next() Step
	ID() int
	String() string
}

type StepTaker

type StepTaker interface {
	Take(vm *VM) Step
}

type Stmt

type Stmt interface {
	Flowable
	// contains filtered or unexported methods
}

All statement nodes implement the Stmt interface.

type StructType

type StructType struct {
	*ast.StructType
	Fields  *FieldList
	Methods map[string]FuncDecl
}

func (StructType) Eval

func (s StructType) Eval(vm *VM)

func (StructType) Flow

func (s StructType) Flow(g *graphBuilder) (head Step)

func (StructType) Instantiate

func (s StructType) Instantiate(vm *VM) reflect.Value

func (StructType) LiteralCompose

func (s StructType) LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value

func (StructType) String

func (s StructType) String() string

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 Traverseable interface {
	Traverse(g *dot.Graph, visited map[int]dot.Node) dot.Node
}

type TypeSpec

type TypeSpec struct {
	*ast.TypeSpec
	Name       *Ident
	TypeParams *FieldList
	Type       Expr
}

func (TypeSpec) Eval

func (s TypeSpec) Eval(vm *VM)

func (TypeSpec) Instantiate

func (s TypeSpec) Instantiate(vm *VM) reflect.Value

func (TypeSpec) LiteralCompose

func (s TypeSpec) LiteralCompose(composite reflect.Value, values []reflect.Value) reflect.Value

func (TypeSpec) String

func (s TypeSpec) String() string

type UnaryExpr

type UnaryExpr struct {
	*ast.UnaryExpr
	X Expr
}

func (UnaryExpr) Eval

func (u UnaryExpr) Eval(vm *VM)

func (UnaryExpr) Flow

func (u UnaryExpr) Flow(g *graphBuilder) (head Step)

func (UnaryExpr) String

func (u UnaryExpr) String() string

type VM

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