ssa

package
v1.3.4-beta2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: AGPL-3.0 Imports: 29 Imported by: 0

README

HIR

Include 25+ Instruction

Instruction Description
Assert assert stmt
BasicBlock block with scope
BinOp binary operation
Call function call or undefined call, operation with Method/FormalParams and Returns
ConstInst constant value / literal
ErrorHandler error handler
Field field access, member call, like foo.bar, Op1 is foo, Op2 is bar
Function function definition, with FormalParams and Returns, support freevalues, closure function
If Standard if statement, with condition, then block, else block, if-elif-else like
Jump jump to another block
Loop loop statement, with condition, body block, and optional init block, and latch, classic for three block format
Make make statement, with type, and optional init block, create new value or mix type
Next next statement, with optional value, like continue
Panic panic statement, with optional value, like panic
Parameter Formal Parameters, in function definitions
Phi phi node, with type, and optional init block, like a = phi [b, c], generally if-phi and for-phi is common...
Recover relative for Panic, with optional value, like recover
Return return statement, with optional value, like return
SideEffect a freevalue in function is re-assigned, like a = 1; c = () => {a = a + 1}; c(); dump(a) will cause the last a is changed
Switch switch statement, with condition, and optional default block, and optional case blocks, like switch a { case b: c; default: d; }
TypeCast type cast, with type, and optional init block
TypeValue type literal, like make([]int, 1), the []int is type literal
UnOp unary operation
Undefined undefined value, like undefined

How Translate From AST?

the core operator is *Function instance, so keep the main in a package and u can use *Function to emit some ast structure to ssa ins.

in AST walker, the visitor mode is recommended, DO NOT USE listener

Advanced Syntax Support

Closure Function and Side Effect

var a = 0
c = () => { a += 1 }
c()

dump(a) // build/emit side effect via the lexical scope(name) 
Lexical Scope API
// in php code
<?php 

$a ="b";
$b = "123";
echo $$a; // operator for lexical scope
Yield Abstract Syntax

TBD

OOP, Interface with Object Blueprint

TBD

Documentation

Index

Constants

View Source
const (
	// loop
	LoopHeader    = "loop.header"    // first
	LoopCondition = "loop.condition" // second // condition
	LoopBody      = "loop.body"      // body
	LoopExit      = "loop.exit"      // exit
	LoopLatch     = "loop.latch"     // third // latch

	// if
	IfDone  = "if.done"
	IfTrue  = "if.true"
	IfFalse = "if.false"
	IfElif  = "if.elif"

	// try-catch
	TryStart   = "error.try"
	TryCatch   = "error.catch"
	TryFinally = "error.final"
	TryDone    = "error.done"

	// switch
	SwitchDone    = "switch.done"
	SwitchDefault = "switch.default"
	SwitchHandler = "switch.handler"
)
View Source
const (
	OpLogicAnd = `LogicAnd`
	OpLogicOr  = `LogicOr`
	OpAnd      = `and`
	OpAndNot   = `and-not`
	OpOr       = `or`
	OpXor      = `xor`
	OpShl      = `shl`
	OpShr      = `shr`
	OpAdd      = `add`
	OpSub      = `sub`
	OpMod      = `mod`
	OpMul      = `mul`
	OpDiv      = `div`
	OpGt       = `gt`
	OpLt       = `lt`
	OpLtEq     = `ltEq`
	OpGtEq     = `gtEq`
	OpNotEq    = `neq`
	OpEq       = `eq`
	OpIn       = `in`
	OpSend     = `send`
	OpPow      = `pow`
)
View Source
const (
	OpNot        = `not`
	OpPlus       = `plus`
	OpNeg        = `neg`
	OpChan       = `chan`
	OpBitwiseNot = `bitwise-not`
)
View Source
const (
	MAXTYPELEVEL = 15
)
View Source
const MAXTypeCompareDepth = 10
View Source
const (
	OpNone = ``
)

Variables

View Source
var (
	ConstMap      = make(map[any]*Const)
	ConstMapMutex = &sync.RWMutex{}
)
View Source
var (
	NextOk    = NewConst("ok")
	NextField = NewConst("field")
	NextKey   = NewConst("key")
)
View Source
var CompareOpcode = []string{OpGt, OpLt, OpLtEq, OpGtEq, OpNotEq, OpEq}
View Source
var SSAOpcode2Name = map[Opcode]string{
	SSAOpcodeUnKnow:          "UnKnow",
	SSAOpcodeAssert:          "Assert",
	SSAOpcodeBasicBlock:      "BasicBlock",
	SSAOpcodeBinOp:           "BinOp",
	SSAOpcodeCall:            "Call",
	SSAOpcodeConstInst:       "ConstInst",
	SSAOpcodeErrorHandler:    "ErrorHandler",
	SSAOpcodeExternLib:       "ExternLib",
	SSAOpcodeIf:              "If",
	SSAOpcodeJump:            "Jump",
	SSAOpcodeLoop:            "Loop",
	SSAOpcodeMake:            "Make",
	SSAOpcodeNext:            "Next",
	SSAOpcodePanic:           "Panic",
	SSAOpcodeParameter:       "Parameter",
	SSAOpcodeFreeValue:       "FreeValue",
	SSAOpcodeParameterMember: "ParameterMember",
	SSAOpcodePhi:             "Phi",
	SSAOpcodeRecover:         "Recover",
	SSAOpcodeReturn:          "Return",
	SSAOpcodeSideEffect:      "SideEffect",
	SSAOpcodeSwitch:          "Switch",
	SSAOpcodeTypeCast:        "TypeCast",
	SSAOpcodeTypeValue:       "TypeValue",
	SSAOpcodeUnOp:            "UnOp",
	SSAOpcodeUndefined:       "Undefined",
	SSAOpcodeFunction:        "Function",
}

Functions

func BindingNotFound added in v1.2.8

func BindingNotFound(v string, r *Range) string

func BindingNotFoundInCall added in v1.3.1

func BindingNotFoundInCall(v string) string

func CallAssignmentMismatch added in v1.3.1

func CallAssignmentMismatch(left int, right string) string

func CallAssignmentMismatchDropError added in v1.3.1

func CallAssignmentMismatchDropError(left int, right string) string

func CombineMemberCallVariableName added in v1.3.1

func CombineMemberCallVariableName(caller, callee Value) (string, bool)

func ContAssignExtern added in v1.2.8

func ContAssignExtern(name string) string

func DeleteInst added in v1.2.8

func DeleteInst(i Instruction)

func ExternFieldError added in v1.2.8

func ExternFieldError(instance, name, key, want string) string

func FreeValueNotMember added in v1.3.2

func FreeValueNotMember(name, key string, r *Range) string

func FreeValueNotMemberInCall added in v1.3.2

func FreeValueNotMemberInCall(name, key string) string

func FunctionContReturnError added in v1.3.1

func FunctionContReturnError() string

func GetAllKey added in v1.2.9

func GetAllKey(t Type) []string

func GetEndPosition added in v1.3.3

func GetEndPosition(t antlr.Token) (int, int)

func GetKeyString added in v1.3.1

func GetKeyString(key Value) string

func GetMethodsName added in v1.2.9

func GetMethodsName(t Type) []string

func GetTypeStr

func GetTypeStr(n Value) string

func InsertSortedIntSlice added in v1.3.3

func InsertSortedIntSlice(ts []int, t int) []int

func Instruction2IrCode added in v1.3.3

func Instruction2IrCode(inst Instruction, ir *ssadb.IrCode) error

Instruction2IrCode : marshal instruction to ir code, used in cache, to save to database

func IsCompareOpcode added in v1.3.3

func IsCompareOpcode(i BinaryOpcode) bool

func IsConst added in v1.3.1

func IsConst(v Instruction) bool

value

func IsControlInstruction added in v1.2.9

func IsControlInstruction(i Instruction) bool

func IsObjectType added in v1.2.9

func IsObjectType(t Type) bool

func LineDisasm added in v1.3.0

func LineDisasm(v Instruction) string

LineDisasm disasm a instruction to string

func LineShortDisasm added in v1.3.1

func LineShortDisasm(v Instruction) string

LineShortDisasm disasm a instruction to string, but will use id or name

func NewInstruction added in v1.2.8

func NewInstruction() anInstruction

func NewInstructionFromLazy added in v1.3.3

func NewInstructionFromLazy[T Instruction](id int64, Cover func(Instruction) (T, bool)) (T, error)

func NewValue added in v1.2.8

func NewValue() anValue

func NewVariable added in v1.3.0

func NewVariable(globalIndex int, name string, local bool, scope ssautil.ScopedVersionedTableIF[Value]) ssautil.VersionedIF[Value]

func NoCheckMustInFirst added in v1.2.8

func NoCheckMustInFirst() string

func ReplaceAllValue added in v1.2.9

func ReplaceAllValue(v Value, to Value)

func ReplaceMemberCall added in v1.3.1

func ReplaceMemberCall(v, to Value) map[string]Value

ReplaceMemberCall replace all member or object relationship and will fixup method function call

func ReplaceValue

func ReplaceValue(v Value, to Value, skip func(Instruction) bool)

func RunOnCoverOr added in v1.2.8

func RunOnCoverOr[T, U Instruction](insts []U, cover func(Instruction) (T, bool), f func(T), or func(U))

func SaveTypeToDB

func SaveTypeToDB(typ Type) int

func SetMemberCall added in v1.3.1

func SetMemberCall(obj, key, member Value)

value

func SpinHandle added in v1.3.1

func SpinHandle(name string, phiValue, header, latch Value) map[string]Value

func SyncFromDatabase added in v1.3.3

func SyncFromDatabase(s *Scope) error

func TryGetSimilarityKey added in v1.2.8

func TryGetSimilarityKey(table []string, name string) string

func TypeCompare added in v1.2.9

func TypeCompare(t1, t2 Type) bool

func ValueIsNull added in v1.3.1

func ValueIsNull() string

func ValueUndefined added in v1.3.1

func ValueUndefined(v string) string

Types

type AliasType added in v1.2.8

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

====================== alias type

func NewAliasType added in v1.2.8

func NewAliasType(name, pkg string, elem Type) *AliasType

func (*AliasType) AddMethod added in v1.2.9

func (b *AliasType) AddMethod(id string, f *Function)

func (*AliasType) GetMethod added in v1.2.8

func (a *AliasType) GetMethod() map[string]*Function

func (*AliasType) GetTypeKind added in v1.2.8

func (a *AliasType) GetTypeKind() TypeKind

func (*AliasType) PkgPathString added in v1.3.1

func (b *AliasType) PkgPathString() string

func (*AliasType) RawString added in v1.2.8

func (a *AliasType) RawString() string

func (*AliasType) SetMethod added in v1.2.8

func (a *AliasType) SetMethod(m map[string]*Function)

func (*AliasType) String added in v1.2.8

func (a *AliasType) String() string

type Assert added in v1.2.8

type Assert struct {
	Cond     Value
	Msg      string
	MsgValue Value
	// contains filtered or unexported fields
}

----------- assert

func NewAssert added in v1.2.8

func NewAssert(cond, msgValue Value, msg string) *Assert

func (*Assert) GetBlock added in v1.2.8

func (a *Assert) GetBlock() *BasicBlock

func (*Assert) GetFunc added in v1.2.8

func (a *Assert) GetFunc() *Function

func (*Assert) GetId added in v1.3.0

func (a *Assert) GetId() int64

func (*Assert) GetName added in v1.3.0

func (a *Assert) GetName() string

func (*Assert) GetOpcode added in v1.2.8

func (i *Assert) GetOpcode() Opcode

func (*Assert) GetProgram added in v1.3.0

func (a *Assert) GetProgram() *Program

func (*Assert) GetRange added in v1.3.0

func (c *Assert) GetRange() *Range

source code position

func (*Assert) GetShortVerboseName added in v1.3.2

func (i *Assert) GetShortVerboseName() string

func (*Assert) GetSourceCode added in v1.3.3

func (v *Assert) GetSourceCode() string

func (*Assert) GetSourceCodeContext added in v1.3.3

func (v *Assert) GetSourceCodeContext(n int) string

func (*Assert) GetUsers added in v1.2.8

func (r *Assert) GetUsers() Users

func (*Assert) GetValues added in v1.2.8

func (a *Assert) GetValues() Values

func (*Assert) GetVerboseName added in v1.3.1

func (i *Assert) GetVerboseName() string

func (*Assert) HasUsers added in v1.2.8

func (r *Assert) HasUsers() bool

func (*Assert) HasValues added in v1.2.8

func (a *Assert) HasValues() bool

----------- Assert

func (*Assert) IsExtern added in v1.2.8

func (c *Assert) IsExtern() bool

func (*Assert) IsUndefined added in v1.3.1

func (i *Assert) IsUndefined() bool

func (*Assert) LineDisasm added in v1.2.8

func (a *Assert) LineDisasm() string

func (*Assert) NewError added in v1.2.8

func (c *Assert) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*Assert) ReplaceValue added in v1.2.8

func (a *Assert) ReplaceValue(v, to Value)

func (*Assert) SelfDelete added in v1.3.1

func (i *Assert) SelfDelete()

func (*Assert) SetBlock added in v1.2.8

func (a *Assert) SetBlock(block *BasicBlock)

func (*Assert) SetExtern added in v1.2.8

func (c *Assert) SetExtern(b bool)

func (*Assert) SetFunc added in v1.2.8

func (a *Assert) SetFunc(f *Function)

ssa function and block

func (*Assert) SetId added in v1.3.0

func (a *Assert) SetId(id int64)

id

func (*Assert) SetName added in v1.3.0

func (a *Assert) SetName(v string)

variable

func (*Assert) SetRange added in v1.3.0

func (c *Assert) SetRange(pos *Range)

func (*Assert) SetVerboseName added in v1.3.1

func (i *Assert) SetVerboseName(verbose string)

func (*Assert) String added in v1.2.8

func (a *Assert) String() string

type AssignAble added in v1.3.3

type AssignAble interface {
	GetVariable(string) *Variable
	GetLastVariable() *Variable
	GetAllVariables() map[string]*Variable
	AddVariable(*Variable)
}

type BasicBlock

type BasicBlock struct {
	Index int
	// BasicBlock graph
	Preds, Succs []*BasicBlock

	/*
		if Condition == true: this block reach
	*/
	Condition Value

	// instruction list
	Insts []Instruction
	Phis  []*Phi

	// error catch
	Handler *ErrorHandler

	ScopeTable *Scope
	// contains filtered or unexported fields
}

implement Value

func ToBasicBlock added in v1.3.3

func ToBasicBlock(n Instruction) (*BasicBlock, bool)

func (*BasicBlock) AddMask added in v1.3.0

func (i *BasicBlock) AddMask(v Value)

func (*BasicBlock) AddMember added in v1.3.1

func (n *BasicBlock) AddMember(k, v Value)

func (*BasicBlock) AddReference

func (i *BasicBlock) AddReference(v Value)

func (*BasicBlock) AddSucc

func (b *BasicBlock) AddSucc(succ *BasicBlock)

func (*BasicBlock) AddUser

func (n *BasicBlock) AddUser(u User)

for Value

func (*BasicBlock) AddVariable added in v1.3.0

func (a *BasicBlock) AddVariable(v *Variable)

func (*BasicBlock) DeleteMember added in v1.3.1

func (n *BasicBlock) DeleteMember(k Value)

func (*BasicBlock) EmitInst added in v1.2.8

func (b *BasicBlock) EmitInst(i Instruction)

func (*BasicBlock) ForEachMember added in v1.3.3

func (n *BasicBlock) ForEachMember(fn func(Value, Value) bool)

func (*BasicBlock) GetAllMember added in v1.3.1

func (n *BasicBlock) GetAllMember() map[Value]Value

func (*BasicBlock) GetAllVariables added in v1.3.0

func (a *BasicBlock) GetAllVariables() map[string]*Variable

func (*BasicBlock) GetBlockById added in v1.2.8

func (b *BasicBlock) GetBlockById(name string) *BasicBlock

func (*BasicBlock) GetIndexMember added in v1.3.1

func (n *BasicBlock) GetIndexMember(i int) (Value, bool)

func (*BasicBlock) GetKey added in v1.3.1

func (n *BasicBlock) GetKey() Value

func (*BasicBlock) GetLastVariable added in v1.3.1

func (a *BasicBlock) GetLastVariable() *Variable

func (*BasicBlock) GetMask added in v1.3.0

func (i *BasicBlock) GetMask() []Value

func (*BasicBlock) GetMember added in v1.3.1

func (n *BasicBlock) GetMember(key Value) (Value, bool)

func (*BasicBlock) GetObject added in v1.3.1

func (n *BasicBlock) GetObject() Value

func (*BasicBlock) GetOpcode added in v1.2.8

func (i *BasicBlock) GetOpcode() Opcode

func (*BasicBlock) GetStringMember added in v1.3.1

func (n *BasicBlock) GetStringMember(key string) (Value, bool)

func (*BasicBlock) GetType

func (b *BasicBlock) GetType() Type

func (*BasicBlock) GetUsers

func (n *BasicBlock) GetUsers() Users

func (*BasicBlock) GetValues

func (b *BasicBlock) GetValues() Values

func (*BasicBlock) GetVariable added in v1.2.8

func (a *BasicBlock) GetVariable(name string) *Variable

func (*BasicBlock) HasUsers added in v1.2.8

func (n *BasicBlock) HasUsers() bool

has/get user and value

func (*BasicBlock) HasValues added in v1.2.8

func (b *BasicBlock) HasValues() bool

----------- BasicBlock

func (*BasicBlock) IsBlock added in v1.2.8

func (b *BasicBlock) IsBlock(name string) bool

func (*BasicBlock) IsMember added in v1.3.1

func (n *BasicBlock) IsMember() bool

func (*BasicBlock) IsObject added in v1.3.1

func (n *BasicBlock) IsObject() bool

func (*BasicBlock) LastInst

func (b *BasicBlock) LastInst() Instruction

func (*BasicBlock) Masked added in v1.3.0

func (i *BasicBlock) Masked() bool

func (*BasicBlock) Reachable added in v1.2.8

func (b *BasicBlock) Reachable() int

func (*BasicBlock) Reference

func (i *BasicBlock) Reference() Values

func (*BasicBlock) RemoveUser

func (n *BasicBlock) RemoveUser(u User)

func (*BasicBlock) SetKey added in v1.3.1

func (n *BasicBlock) SetKey(k Value)

func (*BasicBlock) SetObject added in v1.3.1

func (n *BasicBlock) SetObject(v Value)

func (*BasicBlock) SetType

func (b *BasicBlock) SetType(ts Type)

func (*BasicBlock) String

func (b *BasicBlock) String() string

----------- basic block

type BasicType

type BasicType struct {
	Kind TypeKind
	// contains filtered or unexported fields
}

func NewBasicType added in v1.3.1

func NewBasicType(kind TypeKind, name string) *BasicType

func (*BasicType) AddMethod added in v1.2.9

func (b *BasicType) AddMethod(id string, f *Function)

func (*BasicType) GetMethod added in v1.2.8

func (b *BasicType) GetMethod() map[string]*Function

func (*BasicType) GetTypeKind added in v1.2.8

func (b *BasicType) GetTypeKind() TypeKind

func (*BasicType) PkgPathString added in v1.3.1

func (b *BasicType) PkgPathString() string

func (*BasicType) RawString added in v1.2.8

func (b *BasicType) RawString() string

func (*BasicType) SetMethod added in v1.2.8

func (b *BasicType) SetMethod(method map[string]*Function)

func (*BasicType) String

func (b *BasicType) String() string

type BinOp

type BinOp struct {
	Op   BinaryOpcode
	X, Y Value
	// contains filtered or unexported fields
}

----------- BinOp

func NewBinOp added in v1.2.8

func NewBinOp(op BinaryOpcode, x, y Value) *BinOp

func ToBinOp added in v1.2.8

func ToBinOp(v Instruction) (*BinOp, bool)

func (*BinOp) AddMask added in v1.3.0

func (i *BinOp) AddMask(v Value)

func (*BinOp) AddMember added in v1.3.1

func (n *BinOp) AddMember(k, v Value)

func (*BinOp) AddReference

func (i *BinOp) AddReference(v Value)

func (*BinOp) AddUser

func (n *BinOp) AddUser(u User)

for Value

func (*BinOp) AddVariable added in v1.3.0

func (a *BinOp) AddVariable(v *Variable)

func (*BinOp) DeleteMember added in v1.3.1

func (n *BinOp) DeleteMember(k Value)

func (*BinOp) ForEachMember added in v1.3.3

func (n *BinOp) ForEachMember(fn func(Value, Value) bool)

func (*BinOp) GetAllMember added in v1.3.1

func (n *BinOp) GetAllMember() map[Value]Value

func (*BinOp) GetAllVariables added in v1.3.0

func (a *BinOp) GetAllVariables() map[string]*Variable

func (*BinOp) GetIndexMember added in v1.3.1

func (n *BinOp) GetIndexMember(i int) (Value, bool)

func (*BinOp) GetKey added in v1.3.1

func (n *BinOp) GetKey() Value

func (*BinOp) GetLastVariable added in v1.3.1

func (a *BinOp) GetLastVariable() *Variable

func (*BinOp) GetMask added in v1.3.0

func (i *BinOp) GetMask() []Value

func (*BinOp) GetMember added in v1.3.1

func (n *BinOp) GetMember(key Value) (Value, bool)

func (*BinOp) GetObject added in v1.3.1

func (n *BinOp) GetObject() Value

func (*BinOp) GetOpcode added in v1.2.8

func (i *BinOp) GetOpcode() Opcode

func (*BinOp) GetStringMember added in v1.3.1

func (n *BinOp) GetStringMember(key string) (Value, bool)

func (*BinOp) GetType

func (n *BinOp) GetType() Type

for Value : type

func (*BinOp) GetUsers

func (n *BinOp) GetUsers() Users

func (*BinOp) GetValues

func (b *BinOp) GetValues() Values

func (*BinOp) GetVariable added in v1.2.8

func (a *BinOp) GetVariable(name string) *Variable

func (*BinOp) HasUsers added in v1.2.8

func (n *BinOp) HasUsers() bool

has/get user and value

func (*BinOp) HasValues added in v1.2.8

func (b *BinOp) HasValues() bool

----------- BinOp

func (*BinOp) IsMember added in v1.3.1

func (n *BinOp) IsMember() bool

func (*BinOp) IsObject added in v1.3.1

func (n *BinOp) IsObject() bool

func (*BinOp) Masked added in v1.3.0

func (i *BinOp) Masked() bool

func (*BinOp) Reference

func (i *BinOp) Reference() Values

func (*BinOp) RemoveUser

func (n *BinOp) RemoveUser(u User)

func (*BinOp) ReplaceValue

func (b *BinOp) ReplaceValue(v Value, to Value)

func (*BinOp) SetKey added in v1.3.1

func (n *BinOp) SetKey(k Value)

func (*BinOp) SetObject added in v1.3.1

func (n *BinOp) SetObject(v Value)

func (*BinOp) SetType

func (n *BinOp) SetType(typ Type)

func (*BinOp) String

func (b *BinOp) String() string

----------- BinOp

type BinaryOpcode

type BinaryOpcode string

type BluePrintMember added in v1.3.2

type BluePrintMember struct {
	Value Value
	Type  Type
}

type Build added in v1.3.3

type Build func(string, io.Reader, *FunctionBuilder) error

type Cache added in v1.3.2

type Cache struct {
	ProgramName string // mark which program handled
	DB          *gorm.DB

	InstructionCache *utils.CacheWithKey[int64, instructionIrCode] // instructionID to instruction
	VariableCache    *utils.CacheWithKey[string, []Instruction]    // variable(name:string) to []instruction
	Class2InstIndex  map[string][]Instruction
	// contains filtered or unexported fields
}

Cache : a cache in middle layer of database and application.

application will Get/Set Instruction,

and save the data to database when the data is expired, and load the data from database when the data is not in cache.

func GetCacheFromPool added in v1.3.3

func GetCacheFromPool(programName string) *Cache

func NewDBCache added in v1.3.2

func NewDBCache(programName string, ConfigTTL ...time.Duration) *Cache

NewDBCache : create a new ssa db cache. if ttl is 0, the cache will never expire, and never save to database.

func (*Cache) AddClassInstance

func (c *Cache) AddClassInstance(name string, inst Instruction)

func (*Cache) AddVariable added in v1.3.2

func (c *Cache) AddVariable(name string, inst Instruction)

func (*Cache) DeleteInstruction added in v1.3.2

func (c *Cache) DeleteInstruction(inst Instruction)

func (*Cache) ForEachVariable added in v1.3.2

func (c *Cache) ForEachVariable(handle func(string, []Instruction))

func (*Cache) GetByVariable added in v1.3.2

func (c *Cache) GetByVariable(name string) []Instruction

func (*Cache) GetByVariableExact added in v1.3.3

func (c *Cache) GetByVariableExact(mod int, name string) []Instruction

func (*Cache) GetByVariableGlob added in v1.3.3

func (c *Cache) GetByVariableGlob(mod int, g sfvm.Glob) []Instruction

GetByVariableGlob means get variable name(glob).

func (*Cache) GetByVariableRegexp added in v1.3.3

func (c *Cache) GetByVariableRegexp(mod int, r *regexp.Regexp) []Instruction

GetByVariableRegexp will filter Instruction via variable regexp name

func (*Cache) GetClassInstance

func (c *Cache) GetClassInstance(name string) []Instruction

func (*Cache) GetInstruction added in v1.3.2

func (c *Cache) GetInstruction(id int64) Instruction

GetInstruction : get instruction from cache.

func (*Cache) HaveDatabaseBackend added in v1.3.3

func (c *Cache) HaveDatabaseBackend() bool

func (*Cache) IrCodeToInstruction added in v1.3.3

func (c *Cache) IrCodeToInstruction(inst Instruction, ir *ssadb.IrCode) Instruction

IrCodeToInstruction : unmarshal ir code to instruction, used in LazyInstruction

func (*Cache) IsExistedSourceCodeHash added in v1.3.3

func (c *Cache) IsExistedSourceCodeHash(programName string, hashString string) bool

func (*Cache) RemoveVariable added in v1.3.2

func (c *Cache) RemoveVariable(name string, inst Instruction)

func (*Cache) SaveToDatabase added in v1.3.2

func (c *Cache) SaveToDatabase()

func (*Cache) SetInstruction added in v1.3.2

func (c *Cache) SetInstruction(inst Instruction)

SetInstruction : set instruction to cache.

func (*Cache) SetVariable added in v1.3.2

func (c *Cache) SetVariable(name string, instructions []Instruction)

type Call

type Call struct {

	// for call function
	Method    Value
	Args      []Value
	Binding   map[string]Value
	ArgMember []Value

	// go function
	Async  bool
	Unpack bool

	// caller
	// caller Value
	// ~ drop error
	IsDropError bool
	IsEllipsis  bool
	// contains filtered or unexported fields
}

----------- Call call instruction call method function with args as argument

func NewCall added in v1.2.8

func NewCall(target Value, args []Value, binding map[string]Value, block *BasicBlock) *Call

func ToCall added in v1.2.8

func ToCall(v Instruction) (*Call, bool)

func (*Call) AddMask added in v1.3.0

func (i *Call) AddMask(v Value)

func (*Call) AddMember added in v1.3.1

func (n *Call) AddMember(k, v Value)

func (*Call) AddReference

func (i *Call) AddReference(v Value)

func (*Call) AddUser

func (n *Call) AddUser(u User)

for Value

func (*Call) AddVariable added in v1.3.0

func (a *Call) AddVariable(v *Variable)

func (*Call) DeleteMember added in v1.3.1

func (n *Call) DeleteMember(k Value)

func (*Call) ForEachMember added in v1.3.3

func (n *Call) ForEachMember(fn func(Value, Value) bool)

func (*Call) GetAllMember added in v1.3.1

func (n *Call) GetAllMember() map[Value]Value

func (*Call) GetAllVariables added in v1.3.0

func (a *Call) GetAllVariables() map[string]*Variable

func (*Call) GetIndexMember added in v1.3.1

func (n *Call) GetIndexMember(i int) (Value, bool)

func (*Call) GetKey added in v1.3.1

func (n *Call) GetKey() Value

func (*Call) GetLastVariable added in v1.3.1

func (a *Call) GetLastVariable() *Variable

func (*Call) GetMask added in v1.3.0

func (i *Call) GetMask() []Value

func (*Call) GetMember added in v1.3.1

func (n *Call) GetMember(key Value) (Value, bool)

func (*Call) GetObject added in v1.3.1

func (n *Call) GetObject() Value

func (*Call) GetOpcode added in v1.2.8

func (i *Call) GetOpcode() Opcode

func (*Call) GetStringMember added in v1.3.1

func (n *Call) GetStringMember(key string) (Value, bool)

func (*Call) GetType

func (n *Call) GetType() Type

for Value : type

func (*Call) GetUsers

func (n *Call) GetUsers() Users

func (*Call) GetValues

func (c *Call) GetValues() Values

func (*Call) GetVariable added in v1.2.8

func (a *Call) GetVariable(name string) *Variable

func (*Call) HandleFreeValue added in v1.2.8

func (c *Call) HandleFreeValue(fvs []*Parameter)

func (*Call) HasUsers added in v1.2.8

func (n *Call) HasUsers() bool

has/get user and value

func (*Call) HasValues added in v1.2.8

func (c *Call) HasValues() bool

----------- Call

func (*Call) IsMember added in v1.3.1

func (n *Call) IsMember() bool

func (*Call) IsObject added in v1.3.1

func (n *Call) IsObject() bool

func (*Call) Masked added in v1.3.0

func (i *Call) Masked() bool

func (*Call) Reference

func (i *Call) Reference() Values

func (*Call) RemoveUser

func (n *Call) RemoveUser(u User)

func (*Call) ReplaceValue

func (c *Call) ReplaceValue(v Value, to Value)

func (*Call) SetKey added in v1.3.1

func (n *Call) SetKey(k Value)

func (*Call) SetObject added in v1.3.1

func (n *Call) SetObject(v Value)

func (*Call) SetType

func (n *Call) SetType(typ Type)

func (*Call) String

func (c *Call) String() string

----------- Call

type CanStartStopToken added in v1.3.3

type CanStartStopToken interface {
	GetStop() antlr.Token
	GetStart() antlr.Token
	GetText() string
}

/ ============================== Token ==============================

type ChanType

type ChanType struct {
	Elem Type
	// contains filtered or unexported fields
}

====================== chan type

func NewChanType

func NewChanType(elem Type) *ChanType

func (*ChanType) AddMethod added in v1.2.9

func (b *ChanType) AddMethod(id string, f *Function)

func (*ChanType) GetMethod added in v1.2.8

func (c *ChanType) GetMethod() map[string]*Function

func (*ChanType) GetTypeKind added in v1.2.8

func (c *ChanType) GetTypeKind() TypeKind

func (ChanType) PkgPathString added in v1.3.1

func (c ChanType) PkgPathString() string

func (ChanType) RawString added in v1.2.8

func (c ChanType) RawString() string

func (*ChanType) SetMethod added in v1.2.8

func (c *ChanType) SetMethod(m map[string]*Function)

func (ChanType) String

func (c ChanType) String() string

type ClassBluePrint added in v1.3.2

type ClassBluePrint struct {
	Name string

	Method       map[string]*Function
	StaticMethod map[string]*Function

	NormalMember map[string]BluePrintMember
	StaticMember map[string]Value

	CallBack []func()

	// magic method
	Copy        Value
	Constructor Value
	Destructor  Value

	ParentClass []*ClassBluePrint
}

ClassBluePrint is a class blue print, it is used to create a new class

func NewClassBluePrint added in v1.3.2

func NewClassBluePrint() *ClassBluePrint

func (*ClassBluePrint) AddMethod added in v1.3.2

func (c *ClassBluePrint) AddMethod(key string, fun *Function)

func (*ClassBluePrint) AddNormalMember added in v1.3.2

func (c *ClassBluePrint) AddNormalMember(name string, value Value)

AddNormalMember is used to add a normal member to the class,

func (*ClassBluePrint) AddNormalMemberOnlyType added in v1.3.2

func (c *ClassBluePrint) AddNormalMemberOnlyType(name string, typ Type)

func (*ClassBluePrint) AddParentClass added in v1.3.2

func (c *ClassBluePrint) AddParentClass(parent *ClassBluePrint)

AddParentClass is used to add a parent class to the class,

func (*ClassBluePrint) AddStaticMember added in v1.3.2

func (c *ClassBluePrint) AddStaticMember(name string, value Value)

AddStaticMember is used to add a static member to the class,

func (*ClassBluePrint) AddStaticMethod added in v1.3.2

func (c *ClassBluePrint) AddStaticMethod(name string, value *Function)

AddStaticMethod is used to add a static method to the class,

func (*ClassBluePrint) Apply added in v1.3.2

func (c *ClassBluePrint) Apply(obj Value) Type

func (*ClassBluePrint) GetMember added in v1.3.2

func (c *ClassBluePrint) GetMember(key string, get func(*ClassBluePrint) (Value, bool)) Value

func (*ClassBluePrint) GetMethod added in v1.3.2

func (c *ClassBluePrint) GetMethod() map[string]*Function

func (*ClassBluePrint) GetTypeKind added in v1.3.2

func (c *ClassBluePrint) GetTypeKind() TypeKind

func (*ClassBluePrint) PkgPathString added in v1.3.2

func (c *ClassBluePrint) PkgPathString() string

func (*ClassBluePrint) RawString added in v1.3.2

func (c *ClassBluePrint) RawString() string

func (*ClassBluePrint) SetMethod added in v1.3.2

func (c *ClassBluePrint) SetMethod(m map[string]*Function)

func (*ClassBluePrint) String added in v1.3.2

func (c *ClassBluePrint) String() string

type ClassModifier added in v1.3.2

type ClassModifier int
const (
	NoneModifier ClassModifier = 1 << iota
	Static
	Public
	Protected
	Private
	Abstract
	Final
	Readonly
)

type Const

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

func (*Const) Boolean added in v1.2.8

func (c *Const) Boolean() bool

func (*Const) Float added in v1.2.8

func (c *Const) Float() float64

func (*Const) GetRawValue added in v1.2.9

func (c *Const) GetRawValue() any

func (*Const) GetType

func (c *Const) GetType() Type

get type

func (*Const) GetTypeKind added in v1.2.8

func (c *Const) GetTypeKind() TypeKind

func (*Const) IsBoolean added in v1.2.8

func (c *Const) IsBoolean() bool

func (*Const) IsFloat added in v1.2.8

func (c *Const) IsFloat() bool

func (*Const) IsNumber added in v1.2.8

func (c *Const) IsNumber() bool

func (*Const) IsString added in v1.2.8

func (c *Const) IsString() bool

func (*Const) Number added in v1.2.8

func (c *Const) Number() int64

func (*Const) SetType

func (c *Const) SetType(ts Type)

func (Const) String

func (c Const) String() string

----------- const

func (*Const) VarString added in v1.2.8

func (c *Const) VarString() string

type ConstInst added in v1.2.8

type ConstInst struct {
	*Const

	Unary int

	Origin User
	// contains filtered or unexported fields
}

----------- Const ConstInst also have block pointer, which block set this const to variable

func CalcConstBinary added in v1.2.8

func CalcConstBinary(x, y *ConstInst, op BinaryOpcode) *ConstInst

func CalcConstUnary added in v1.2.8

func CalcConstUnary(x *ConstInst, op UnaryOpcode) *ConstInst

OpNone UnaryOpcode = iota OpNot // ! OpPlus // + OpNeg // - OpChan // ->

func NewAny added in v1.2.8

func NewAny() *ConstInst

func NewConst

func NewConst(i any) *ConstInst

func NewConstWithUnary

func NewConstWithUnary(i any, un int) *ConstInst

create const

func NewNil added in v1.2.8

func NewNil() *ConstInst

func ToConst added in v1.2.8

func ToConst(v Instruction) (*ConstInst, bool)

func (*ConstInst) AddMask added in v1.3.0

func (i *ConstInst) AddMask(v Value)

func (*ConstInst) AddMember added in v1.3.1

func (n *ConstInst) AddMember(k, v Value)

func (*ConstInst) AddReference

func (i *ConstInst) AddReference(v Value)

func (*ConstInst) AddUser added in v1.2.8

func (n *ConstInst) AddUser(u User)

for Value

func (*ConstInst) AddVariable added in v1.3.0

func (a *ConstInst) AddVariable(v *Variable)

func (*ConstInst) DeleteMember added in v1.3.1

func (n *ConstInst) DeleteMember(k Value)

func (*ConstInst) ForEachMember added in v1.3.3

func (n *ConstInst) ForEachMember(fn func(Value, Value) bool)

func (*ConstInst) GetAllMember added in v1.3.1

func (n *ConstInst) GetAllMember() map[Value]Value

func (*ConstInst) GetAllVariables added in v1.3.0

func (a *ConstInst) GetAllVariables() map[string]*Variable

func (*ConstInst) GetIndexMember added in v1.3.1

func (n *ConstInst) GetIndexMember(i int) (Value, bool)

func (*ConstInst) GetKey added in v1.3.1

func (n *ConstInst) GetKey() Value

func (*ConstInst) GetLastVariable added in v1.3.1

func (a *ConstInst) GetLastVariable() *Variable

func (*ConstInst) GetMask added in v1.3.0

func (i *ConstInst) GetMask() []Value

func (*ConstInst) GetMember added in v1.3.1

func (n *ConstInst) GetMember(key Value) (Value, bool)

func (*ConstInst) GetObject added in v1.3.1

func (n *ConstInst) GetObject() Value

func (*ConstInst) GetOpcode added in v1.2.8

func (i *ConstInst) GetOpcode() Opcode

func (*ConstInst) GetStringMember added in v1.3.1

func (n *ConstInst) GetStringMember(key string) (Value, bool)

func (*ConstInst) GetType added in v1.2.8

func (c *ConstInst) GetType() Type

ConstInst cont set Type

func (*ConstInst) GetUsers added in v1.2.8

func (n *ConstInst) GetUsers() Users

func (*ConstInst) GetValues added in v1.2.8

func (c *ConstInst) GetValues() Values

func (*ConstInst) GetVariable added in v1.2.8

func (a *ConstInst) GetVariable(name string) *Variable

func (*ConstInst) HasUsers added in v1.2.8

func (n *ConstInst) HasUsers() bool

has/get user and value

func (*ConstInst) HasValues added in v1.2.8

func (c *ConstInst) HasValues() bool

----------- ConstInst

func (*ConstInst) IsMember added in v1.3.1

func (n *ConstInst) IsMember() bool

func (*ConstInst) IsObject added in v1.3.1

func (n *ConstInst) IsObject() bool

func (*ConstInst) Masked added in v1.3.0

func (i *ConstInst) Masked() bool

func (*ConstInst) Reference

func (i *ConstInst) Reference() Values

func (*ConstInst) RemoveUser added in v1.2.8

func (n *ConstInst) RemoveUser(u User)

func (*ConstInst) ReplaceValue added in v1.3.0

func (c *ConstInst) ReplaceValue(v Value, to Value)

func (*ConstInst) SetKey added in v1.3.1

func (n *ConstInst) SetKey(k Value)

func (*ConstInst) SetObject added in v1.3.1

func (n *ConstInst) SetObject(v Value)

func (*ConstInst) SetType added in v1.2.8

func (c *ConstInst) SetType(ts Type)

func (*ConstInst) String added in v1.2.8

func (c *ConstInst) String() string

----------- const instruction

type DisasmLiner added in v1.3.0

type DisasmLiner interface {
	DisasmValue(v Value) string

	// level += 1; and check should stop?
	// if this method return true, should stop
	AddLevel() bool
	SkipLevelChecking() bool

	// cache // those method  should use `*cacheDisasmLiner`
	GetName(v Instruction) (string, bool)
	SetName(v Instruction, name string)
	DeleteName(v Instruction)
}

type ErrorComment added in v1.2.8

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

func (ErrorComment) Skip added in v1.2.8

func (ec ErrorComment) Skip(pos *Range) bool

type ErrorCommentId added in v1.2.8

type ErrorCommentId string
const (
	SSAIgnore  ErrorCommentId = "// @ssa-ignore"
	SSANoCheck ErrorCommentId = "// @ssa-nocheck"
)

type ErrorHandler added in v1.2.8

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

------------- ErrorHandler

func NewErrorHandler added in v1.2.8

func NewErrorHandler(try, catch *BasicBlock) *ErrorHandler

func (*ErrorHandler) AddDone added in v1.2.8

func (e *ErrorHandler) AddDone(d *BasicBlock)

func (*ErrorHandler) AddFinal added in v1.2.8

func (e *ErrorHandler) AddFinal(f *BasicBlock)

func (*ErrorHandler) GetBlock added in v1.2.8

func (a *ErrorHandler) GetBlock() *BasicBlock

func (*ErrorHandler) GetFunc added in v1.2.8

func (a *ErrorHandler) GetFunc() *Function

func (*ErrorHandler) GetId added in v1.3.0

func (a *ErrorHandler) GetId() int64

func (*ErrorHandler) GetName added in v1.3.0

func (a *ErrorHandler) GetName() string

func (*ErrorHandler) GetOpcode added in v1.2.8

func (i *ErrorHandler) GetOpcode() Opcode

func (*ErrorHandler) GetProgram added in v1.3.0

func (a *ErrorHandler) GetProgram() *Program

func (*ErrorHandler) GetRange added in v1.3.0

func (c *ErrorHandler) GetRange() *Range

source code position

func (*ErrorHandler) GetShortVerboseName added in v1.3.2

func (i *ErrorHandler) GetShortVerboseName() string

func (*ErrorHandler) GetSourceCode added in v1.3.3

func (v *ErrorHandler) GetSourceCode() string

func (*ErrorHandler) GetSourceCodeContext added in v1.3.3

func (v *ErrorHandler) GetSourceCodeContext(n int) string

func (*ErrorHandler) GetVerboseName added in v1.3.1

func (i *ErrorHandler) GetVerboseName() string

func (*ErrorHandler) IsExtern added in v1.2.8

func (c *ErrorHandler) IsExtern() bool

func (*ErrorHandler) IsUndefined added in v1.3.1

func (i *ErrorHandler) IsUndefined() bool

func (*ErrorHandler) LineDisasm added in v1.2.8

func (a *ErrorHandler) LineDisasm() string

func (*ErrorHandler) NewError added in v1.2.8

func (c *ErrorHandler) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*ErrorHandler) ReplaceValue added in v1.3.1

func (i *ErrorHandler) ReplaceValue(Value, Value)

func (*ErrorHandler) SelfDelete added in v1.3.1

func (i *ErrorHandler) SelfDelete()

func (*ErrorHandler) SetBlock added in v1.2.8

func (a *ErrorHandler) SetBlock(block *BasicBlock)

func (*ErrorHandler) SetExtern added in v1.2.8

func (c *ErrorHandler) SetExtern(b bool)

func (*ErrorHandler) SetFunc added in v1.2.8

func (a *ErrorHandler) SetFunc(f *Function)

ssa function and block

func (*ErrorHandler) SetId added in v1.3.0

func (a *ErrorHandler) SetId(id int64)

id

func (*ErrorHandler) SetName added in v1.3.0

func (a *ErrorHandler) SetName(v string)

variable

func (*ErrorHandler) SetRange added in v1.3.0

func (c *ErrorHandler) SetRange(pos *Range)

func (*ErrorHandler) SetVerboseName added in v1.3.1

func (i *ErrorHandler) SetVerboseName(verbose string)

func (*ErrorHandler) String added in v1.2.8

func (e *ErrorHandler) String() string

type ErrorKind

type ErrorKind int
const (
	Warn ErrorKind = iota
	Error
)

type ErrorLogger added in v1.2.8

type ErrorLogger interface {
	NewError(ErrorKind, ErrorTag, string)
}

type ErrorTag added in v1.2.8

type ErrorTag string
const (
	SSATAG ErrorTag = "ssa"
)

type ExternLib added in v1.3.0

type ExternLib struct {
	MemberMap map[string]Value
	Member    []Value
	// contains filtered or unexported fields
}

----------- externLib

func NewExternLib added in v1.3.0

func NewExternLib(variable string, builder *FunctionBuilder, table map[string]any) *ExternLib

func ToExternLib added in v1.3.0

func ToExternLib(v Instruction) (*ExternLib, bool)

func (*ExternLib) AddMask added in v1.3.0

func (i *ExternLib) AddMask(v Value)

func (*ExternLib) AddMember added in v1.3.1

func (n *ExternLib) AddMember(k, v Value)

func (*ExternLib) AddReference

func (i *ExternLib) AddReference(v Value)

func (*ExternLib) AddUser added in v1.3.0

func (n *ExternLib) AddUser(u User)

for Value

func (*ExternLib) AddVariable added in v1.3.0

func (a *ExternLib) AddVariable(v *Variable)

func (*ExternLib) BuildField added in v1.3.0

func (ex *ExternLib) BuildField(key string) Value

func (*ExternLib) DeleteMember added in v1.3.1

func (n *ExternLib) DeleteMember(k Value)

func (*ExternLib) ForEachMember added in v1.3.3

func (n *ExternLib) ForEachMember(fn func(Value, Value) bool)

func (*ExternLib) GetAllMember added in v1.3.1

func (n *ExternLib) GetAllMember() map[Value]Value

func (*ExternLib) GetAllVariables added in v1.3.0

func (a *ExternLib) GetAllVariables() map[string]*Variable

func (*ExternLib) GetIndexMember added in v1.3.1

func (n *ExternLib) GetIndexMember(i int) (Value, bool)

func (*ExternLib) GetKey added in v1.3.1

func (n *ExternLib) GetKey() Value

func (*ExternLib) GetLastVariable added in v1.3.1

func (a *ExternLib) GetLastVariable() *Variable

func (*ExternLib) GetMask added in v1.3.0

func (i *ExternLib) GetMask() []Value

func (*ExternLib) GetMember added in v1.3.1

func (n *ExternLib) GetMember(key Value) (Value, bool)

func (*ExternLib) GetObject added in v1.3.1

func (n *ExternLib) GetObject() Value

func (*ExternLib) GetOpcode added in v1.3.0

func (i *ExternLib) GetOpcode() Opcode

func (*ExternLib) GetStringMember added in v1.3.1

func (n *ExternLib) GetStringMember(key string) (Value, bool)

func (*ExternLib) GetType added in v1.3.0

func (n *ExternLib) GetType() Type

for Value : type

func (*ExternLib) GetUsers added in v1.3.0

func (n *ExternLib) GetUsers() Users

func (*ExternLib) GetValues added in v1.3.0

func (e *ExternLib) GetValues() Values

func (*ExternLib) GetVariable added in v1.3.0

func (a *ExternLib) GetVariable(name string) *Variable

func (*ExternLib) HasUsers added in v1.3.0

func (n *ExternLib) HasUsers() bool

has/get user and value

func (*ExternLib) HasValues added in v1.3.0

func (e *ExternLib) HasValues() bool

/ ---- extern lib

func (*ExternLib) IsMember added in v1.3.1

func (n *ExternLib) IsMember() bool

func (*ExternLib) IsObject added in v1.3.1

func (n *ExternLib) IsObject() bool

func (*ExternLib) Masked added in v1.3.0

func (i *ExternLib) Masked() bool

func (*ExternLib) Reference

func (i *ExternLib) Reference() Values

func (*ExternLib) RemoveUser added in v1.3.0

func (n *ExternLib) RemoveUser(u User)

func (*ExternLib) ReplaceValue added in v1.3.0

func (e *ExternLib) ReplaceValue(v Value, to Value)

func (*ExternLib) SetKey added in v1.3.1

func (n *ExternLib) SetKey(k Value)

func (*ExternLib) SetObject added in v1.3.1

func (n *ExternLib) SetObject(v Value)

func (*ExternLib) SetType added in v1.3.0

func (n *ExternLib) SetType(typ Type)

func (*ExternLib) String added in v1.3.0

func (e *ExternLib) String() string

type FullDisasmLiner added in v1.3.1

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

func NewFullDisasmLiner added in v1.3.1

func NewFullDisasmLiner(max int) *FullDisasmLiner

func (*FullDisasmLiner) AddLevel added in v1.3.1

func (f *FullDisasmLiner) AddLevel() bool

func (FullDisasmLiner) DeleteName added in v1.3.1

func (b FullDisasmLiner) DeleteName(i Instruction)

func (*FullDisasmLiner) DisasmValue added in v1.3.1

func (f *FullDisasmLiner) DisasmValue(v Value) string

func (FullDisasmLiner) GetName added in v1.3.1

func (b FullDisasmLiner) GetName(i Instruction) (string, bool)

func (FullDisasmLiner) SetName added in v1.3.1

func (b FullDisasmLiner) SetName(i Instruction, name string)

func (*FullDisasmLiner) SkipLevelChecking added in v1.3.1

func (b *FullDisasmLiner) SkipLevelChecking() bool

type Function

type Function struct {

	// package, double link
	Package *Package

	// Type
	Type *FunctionType

	// just function parameter
	Param       []*Parameter
	ParamLength int
	// for closure function
	FreeValues map[string]*Parameter // store the captured variable form parent-function, just contain name, and type is Parameter
	// parameter member call
	ParameterMember []*ParameterMember
	// function side effects
	SideEffects []*FunctionSideEffect

	ChildFuncs []*Function // child function within this function

	Return []*Return

	// BasicBlock list
	Blocks []*BasicBlock
	// First and End block
	EnterBlock *BasicBlock
	ExitBlock  *BasicBlock
	// For Defer  semantic
	// this block will always execute when the function exits,
	// regardless of whether the function returns normally or exits due to a panic.
	DeferBlock *BasicBlock
	// contains filtered or unexported fields
}

implement Value

func GetMethod added in v1.2.9

func GetMethod(t Type, id string) *Function

func NewFunctionWithType added in v1.2.8

func NewFunctionWithType(name string, typ *FunctionType) *Function

just create a function define, only function parameter type \ return type \ ellipsis

func ToFunction added in v1.2.8

func ToFunction(n Instruction) (*Function, bool)

func (*Function) AddErrorComment added in v1.2.8

func (f *Function) AddErrorComment(str string, line int) error

func (*Function) AddForceSideEffect added in v1.3.2

func (f *Function) AddForceSideEffect(name string, v Value)

func (*Function) AddMask added in v1.3.0

func (i *Function) AddMask(v Value)

func (*Function) AddMember added in v1.3.1

func (n *Function) AddMember(k, v Value)

func (*Function) AddReference

func (i *Function) AddReference(v Value)

func (*Function) AddSideEffect added in v1.2.9

func (f *Function) AddSideEffect(name *Variable, v Value)

func (*Function) AddUser

func (n *Function) AddUser(u User)

for Value

func (*Function) AddVariable added in v1.3.0

func (a *Function) AddVariable(v *Variable)

func (*Function) DeleteMember added in v1.3.1

func (n *Function) DeleteMember(k Value)

func (*Function) DisAsm

func (f *Function) DisAsm(flag FunctionAsmFlag) string

func (*Function) Finish

func (f *Function) Finish()

Finish the function, set FunctionType, set EnterBlock/ExitBlock

func (*Function) FirstBlockInstruction added in v1.3.0

func (f *Function) FirstBlockInstruction() []Instruction

func (*Function) ForEachMember added in v1.3.3

func (n *Function) ForEachMember(fn func(Value, Value) bool)

func (*Function) GetAllMember added in v1.3.1

func (n *Function) GetAllMember() map[Value]Value

func (*Function) GetAllVariables added in v1.3.0

func (a *Function) GetAllVariables() map[string]*Variable

func (*Function) GetDeferBlock added in v1.2.9

func (f *Function) GetDeferBlock() *BasicBlock

func (*Function) GetFunc added in v1.2.8

func (f *Function) GetFunc() *Function

func (*Function) GetIndexMember added in v1.3.1

func (n *Function) GetIndexMember(i int) (Value, bool)

func (*Function) GetKey added in v1.3.1

func (n *Function) GetKey() Value

func (*Function) GetLastVariable added in v1.3.1

func (a *Function) GetLastVariable() *Variable

func (*Function) GetMask added in v1.3.0

func (i *Function) GetMask() []Value

func (*Function) GetMember added in v1.3.1

func (n *Function) GetMember(key Value) (Value, bool)

func (*Function) GetObject added in v1.3.1

func (n *Function) GetObject() Value

func (*Function) GetOpcode added in v1.2.8

func (i *Function) GetOpcode() Opcode

func (*Function) GetParent

func (f *Function) GetParent() *Function

func (*Function) GetProgram added in v1.3.0

func (f *Function) GetProgram() *Program

func (*Function) GetReferenceFiles added in v1.3.1

func (f *Function) GetReferenceFiles() []string

func (*Function) GetStringMember added in v1.3.1

func (n *Function) GetStringMember(key string) (Value, bool)

func (*Function) GetType

func (f *Function) GetType() Type

func (*Function) GetUsers

func (n *Function) GetUsers() Users

func (*Function) GetValues

func (f *Function) GetValues() Values

func (*Function) GetVariable added in v1.2.8

func (a *Function) GetVariable(name string) *Variable

func (*Function) HasUsers added in v1.2.8

func (n *Function) HasUsers() bool

has/get user and value

func (*Function) HasValues added in v1.2.8

func (f *Function) HasValues() bool

----------- Function

func (*Function) IsMain added in v1.2.8

func (f *Function) IsMain() bool

func (*Function) IsMember added in v1.3.1

func (n *Function) IsMember() bool

func (*Function) IsMethod added in v1.3.2

func (f *Function) IsMethod() bool

func (*Function) IsObject added in v1.3.1

func (n *Function) IsObject() bool

func (*Function) Masked added in v1.3.0

func (i *Function) Masked() bool

func (*Function) NewBasicBlock

func (f *Function) NewBasicBlock(name string) *BasicBlock

func (*Function) NewBasicBlockNotAddBlocks added in v1.2.9

func (f *Function) NewBasicBlockNotAddBlocks(name string) *BasicBlock

func (*Function) NewBasicBlockNotAddUnSealed added in v1.2.9

func (f *Function) NewBasicBlockNotAddUnSealed(name string) *BasicBlock

func (*Function) NewBasicBlockUnSealed

func (f *Function) NewBasicBlockUnSealed(name string) *BasicBlock

func (*Function) NewError added in v1.2.8

func (f *Function) NewError(kind ErrorKind, tag ErrorTag, format string)

func (*Function) NewErrorWithPos

func (f *Function) NewErrorWithPos(kind ErrorKind, tag ErrorTag, Pos *Range, message string)

func (*Function) PushReferenceFile added in v1.3.1

func (f *Function) PushReferenceFile(file, code string)

func (*Function) Reference

func (i *Function) Reference() Values

func (*Function) RemoveUser

func (n *Function) RemoveUser(u User)

func (*Function) ReturnValue

func (f *Function) ReturnValue() []Value

func (*Function) SetKey added in v1.3.1

func (n *Function) SetKey(k Value)

func (*Function) SetMethod added in v1.3.2

func (f *Function) SetMethod(is bool, objType Type)

func (*Function) SetObject added in v1.3.1

func (n *Function) SetObject(v Value)

func (*Function) SetType

func (f *Function) SetType(t Type)

func (*Function) String

func (f *Function) String() string

implement value

type FunctionAsmFlag

type FunctionAsmFlag int
const (
	DisAsmDefault FunctionAsmFlag = 1 << iota
	DisAsmWithSource
)

type FunctionBuilder

type FunctionBuilder struct {
	*Function

	// disable free-value
	SupportClosure bool
	// Support obtaining static members from the StaticMember of the class's blueprint,
	// even if the class is not instantiated
	SupportGetStaticMember bool

	RefParameter map[string]struct{}

	// for build
	CurrentBlock *BasicBlock // current block to build
	CurrentRange *Range      // current position in source code
	CurrentFile  string      // current file name

	DefineFunc map[string]any

	MarkedFuncType  *FunctionType
	MarkedFunctions []*Function

	MarkedVariable           *Variable
	MarkedThisObject         Value
	MarkedThisClassBlueprint *ClassBluePrint
	// contains filtered or unexported fields
}

Function builder API

func NewBuilder

func NewBuilder(editor *memedit.MemEditor, f *Function, parent *FunctionBuilder) *FunctionBuilder

func (*FunctionBuilder) AddCurrentPackagePath added in v1.3.3

func (b *FunctionBuilder) AddCurrentPackagePath(path []string) *FunctionBuilder

func (*FunctionBuilder) AddDefer

func (b *FunctionBuilder) AddDefer(call *Call)

add current function defer function

func (*FunctionBuilder) AddIncludePath added in v1.3.3

func (b *FunctionBuilder) AddIncludePath(path string)

func (*FunctionBuilder) AddLabel added in v1.2.8

func (b *FunctionBuilder) AddLabel(name string, block *BasicBlock)

for goto and label

func (FunctionBuilder) AddMask added in v1.3.0

func (i FunctionBuilder) AddMask(v Value)

func (FunctionBuilder) AddMember added in v1.3.1

func (n FunctionBuilder) AddMember(k, v Value)

func (FunctionBuilder) AddReference

func (i FunctionBuilder) AddReference(v Value)

func (FunctionBuilder) AddUser added in v1.2.8

func (n FunctionBuilder) AddUser(u User)

for Value

func (FunctionBuilder) AddVariable added in v1.3.0

func (a FunctionBuilder) AddVariable(v *Variable)

func (*FunctionBuilder) AppendBlockRange

func (b *FunctionBuilder) AppendBlockRange()

func (*FunctionBuilder) AssignVariable added in v1.3.1

func (b *FunctionBuilder) AssignVariable(variable *Variable, value Value)

AssignVariable assign value to variable

func (*FunctionBuilder) Break added in v1.3.1

func (b *FunctionBuilder) Break() bool

func (*FunctionBuilder) BuildDirectoryPackage added in v1.3.3

func (b *FunctionBuilder) BuildDirectoryPackage(name string, once bool) error

func (*FunctionBuilder) BuildFilePackage added in v1.3.3

func (b *FunctionBuilder) BuildFilePackage(filename string, once bool) error

func (*FunctionBuilder) BuildFreeValue

func (b *FunctionBuilder) BuildFreeValue(variable string) *Parameter

func (*FunctionBuilder) BuildSwitch added in v1.2.8

func (b *FunctionBuilder) BuildSwitch() *SwitchBuilder

func (*FunctionBuilder) BuildSyntaxBlock added in v1.3.1

func (b *FunctionBuilder) BuildSyntaxBlock(builder func())

func (*FunctionBuilder) BuildTry added in v1.2.8

func (b *FunctionBuilder) BuildTry() *TryBuilder

func (*FunctionBuilder) BuildValueFromAny added in v1.2.8

func (b *FunctionBuilder) BuildValueFromAny(id string, v any) (value Value)

func (*FunctionBuilder) CheckAndSetSideEffect

func (f *FunctionBuilder) CheckAndSetSideEffect(variable *Variable, v Value)

func (*FunctionBuilder) Continue added in v1.3.1

func (b *FunctionBuilder) Continue() bool

func (*FunctionBuilder) CoverReflectFunctionType added in v1.2.8

func (b *FunctionBuilder) CoverReflectFunctionType(itype reflect.Type, level int) *FunctionType

func (*FunctionBuilder) CreateClassBluePrint added in v1.3.2

func (b *FunctionBuilder) CreateClassBluePrint(name string) *ClassBluePrint

func (*FunctionBuilder) CreateIfBuilder added in v1.3.1

func (b *FunctionBuilder) CreateIfBuilder() *IfBuilder

CreateIfBuilder Create IfBuilder

func (*FunctionBuilder) CreateInterfaceWithMap added in v1.3.1

func (b *FunctionBuilder) CreateInterfaceWithMap(keys []Value, vs []Value) *Make

func (*FunctionBuilder) CreateInterfaceWithSlice added in v1.3.1

func (b *FunctionBuilder) CreateInterfaceWithSlice(vs []Value) *Make

func (*FunctionBuilder) CreateLocalVariable added in v1.3.1

func (b *FunctionBuilder) CreateLocalVariable(name string) *Variable

CreateVariable create variable

func (*FunctionBuilder) CreateLoopBuilder added in v1.3.1

func (b *FunctionBuilder) CreateLoopBuilder() *LoopBuilder

CreateLoopBuilder Create LoopBuilder

func (*FunctionBuilder) CreateMemberCallVariable added in v1.3.1

func (b *FunctionBuilder) CreateMemberCallVariable(object, key Value) *Variable

func (*FunctionBuilder) CreateVariable added in v1.3.1

func (b *FunctionBuilder) CreateVariable(name string, pos ...CanStartStopToken) *Variable

func (*FunctionBuilder) DeleteLabel added in v1.2.8

func (b *FunctionBuilder) DeleteLabel(name string)

func (FunctionBuilder) DeleteMember added in v1.3.1

func (n FunctionBuilder) DeleteMember(k Value)

func (*FunctionBuilder) EmitAssert added in v1.2.8

func (f *FunctionBuilder) EmitAssert(cond, msgValue Value, msg string) *Assert

func (*FunctionBuilder) EmitBinOp added in v1.2.8

func (f *FunctionBuilder) EmitBinOp(op BinaryOpcode, x, y Value) Value

func (*FunctionBuilder) EmitCall

func (f *FunctionBuilder) EmitCall(c *Call) *Call

func (*FunctionBuilder) EmitConstInst added in v1.2.8

func (f *FunctionBuilder) EmitConstInst(i any) *ConstInst

func (*FunctionBuilder) EmitConstInstNil added in v1.2.8

func (f *FunctionBuilder) EmitConstInstNil() *ConstInst

func (*FunctionBuilder) EmitConstInstWithUnary added in v1.2.8

func (f *FunctionBuilder) EmitConstInstWithUnary(i any, un int) *ConstInst

func (*FunctionBuilder) EmitErrorHandler added in v1.2.8

func (f *FunctionBuilder) EmitErrorHandler(try, catch *BasicBlock) *ErrorHandler

func (*FunctionBuilder) EmitFirst added in v1.3.1

func (b *FunctionBuilder) EmitFirst(i Instruction, block *BasicBlock)

func (*FunctionBuilder) EmitIf

func (f *FunctionBuilder) EmitIf() *If

func (*FunctionBuilder) EmitInstructionAfter added in v1.2.8

func (f *FunctionBuilder) EmitInstructionAfter(i, after Instruction)

func (*FunctionBuilder) EmitInstructionBefore added in v1.2.8

func (f *FunctionBuilder) EmitInstructionBefore(i, before Instruction)

func (*FunctionBuilder) EmitJump

func (f *FunctionBuilder) EmitJump(to *BasicBlock) *Jump

func (*FunctionBuilder) EmitLoop added in v1.2.8

func (f *FunctionBuilder) EmitLoop(body, exit *BasicBlock, cond Value) *Loop

func (*FunctionBuilder) EmitMakeBuildWithType added in v1.2.8

func (f *FunctionBuilder) EmitMakeBuildWithType(typ Type, Len, Cap Value) *Make

func (*FunctionBuilder) EmitMakeSlice added in v1.2.8

func (f *FunctionBuilder) EmitMakeSlice(i Value, low, high, max Value) *Make

func (*FunctionBuilder) EmitMakeWithoutType added in v1.2.8

func (f *FunctionBuilder) EmitMakeWithoutType(Len, Cap Value) *Make

func (*FunctionBuilder) EmitNewClassBluePrint added in v1.3.2

func (f *FunctionBuilder) EmitNewClassBluePrint(memberCount int) *ClassBluePrint

func (*FunctionBuilder) EmitNext added in v1.2.8

func (f *FunctionBuilder) EmitNext(iter Value, isIn bool) (key, field, ok Value)

func (*FunctionBuilder) EmitNextOnly added in v1.2.8

func (f *FunctionBuilder) EmitNextOnly(iter Value, isIn bool) *Next

func (*FunctionBuilder) EmitOnly added in v1.2.9

func (f *FunctionBuilder) EmitOnly(i Instruction)

func (*FunctionBuilder) EmitPanic added in v1.2.8

func (f *FunctionBuilder) EmitPanic(info Value) *Panic

func (*FunctionBuilder) EmitPhi added in v1.3.1

func (f *FunctionBuilder) EmitPhi(name string, vs []Value) *Phi

func (*FunctionBuilder) EmitRecover added in v1.2.8

func (f *FunctionBuilder) EmitRecover() *Recover

func (*FunctionBuilder) EmitReturn

func (f *FunctionBuilder) EmitReturn(vs []Value) *Return

func (*FunctionBuilder) EmitSideEffect added in v1.3.1

func (f *FunctionBuilder) EmitSideEffect(name string, call *Call, value Value) *SideEffect

func (*FunctionBuilder) EmitSwitch

func (f *FunctionBuilder) EmitSwitch(cond Value, defaultb *BasicBlock, label []SwitchLabel) *Switch

func (*FunctionBuilder) EmitToBlock added in v1.2.8

func (f *FunctionBuilder) EmitToBlock(i Instruction, block *BasicBlock)

func (*FunctionBuilder) EmitTypeCast added in v1.2.8

func (f *FunctionBuilder) EmitTypeCast(v Value, typ Type) *TypeCast

func (*FunctionBuilder) EmitTypeValue added in v1.2.8

func (f *FunctionBuilder) EmitTypeValue(typ Type) *TypeValue

func (*FunctionBuilder) EmitUnOp added in v1.2.8

func (f *FunctionBuilder) EmitUnOp(op UnaryOpcode, v Value) Value

func (*FunctionBuilder) EmitUndefined added in v1.3.1

func (f *FunctionBuilder) EmitUndefined(name string) *Undefined

EmitUndefined emit undefined value the current block is finished. NOTE: the object/membercall will create vars in finished blocks

func (*FunctionBuilder) EmitValueOnlyDeclare added in v1.3.3

func (f *FunctionBuilder) EmitValueOnlyDeclare(name string) *Undefined

func (*FunctionBuilder) Fallthrough added in v1.3.1

func (b *FunctionBuilder) Fallthrough() bool

func (*FunctionBuilder) Finish

func (b *FunctionBuilder) Finish()

Finish current function builder

func (FunctionBuilder) ForEachMember added in v1.3.3

func (n FunctionBuilder) ForEachMember(fn func(Value, Value) bool)

func (FunctionBuilder) GetAllMember added in v1.3.1

func (n FunctionBuilder) GetAllMember() map[Value]Value

func (FunctionBuilder) GetAllVariables added in v1.3.0

func (a FunctionBuilder) GetAllVariables() map[string]*Variable

func (*FunctionBuilder) GetClassBluePrint added in v1.3.2

func (b *FunctionBuilder) GetClassBluePrint(name string) *ClassBluePrint

func (*FunctionBuilder) GetCurrentPackagePath added in v1.3.3

func (b *FunctionBuilder) GetCurrentPackagePath() []string

func (*FunctionBuilder) GetCurrentRange

func (b *FunctionBuilder) GetCurrentRange(fallback CanStartStopToken) *Range

func (*FunctionBuilder) GetEditor added in v1.3.3

func (b *FunctionBuilder) GetEditor() *memedit.MemEditor

func (FunctionBuilder) GetIndexMember added in v1.3.1

func (n FunctionBuilder) GetIndexMember(i int) (Value, bool)

func (FunctionBuilder) GetKey added in v1.3.1

func (n FunctionBuilder) GetKey() Value

func (*FunctionBuilder) GetLabel added in v1.2.8

func (b *FunctionBuilder) GetLabel(name string) *BasicBlock

func (FunctionBuilder) GetLastVariable added in v1.3.1

func (a FunctionBuilder) GetLastVariable() *Variable

func (*FunctionBuilder) GetMarkedFunction added in v1.3.1

func (b *FunctionBuilder) GetMarkedFunction() *FunctionType

func (FunctionBuilder) GetMask added in v1.3.0

func (i FunctionBuilder) GetMask() []Value

func (FunctionBuilder) GetMember added in v1.3.1

func (n FunctionBuilder) GetMember(key Value) (Value, bool)

func (FunctionBuilder) GetObject added in v1.3.1

func (n FunctionBuilder) GetObject() Value

func (*FunctionBuilder) GetPackage

func (f *FunctionBuilder) GetPackage(name string) *Package

func (*FunctionBuilder) GetStaticMember added in v1.3.2

func (b *FunctionBuilder) GetStaticMember(class, key string) *Variable

func (FunctionBuilder) GetStringMember added in v1.3.1

func (n FunctionBuilder) GetStringMember(key string) (Value, bool)

func (FunctionBuilder) GetUsers added in v1.2.8

func (n FunctionBuilder) GetUsers() Users

func (FunctionBuilder) GetVariable added in v1.2.8

func (a FunctionBuilder) GetVariable(name string) *Variable

func (FunctionBuilder) HandlerEllipsis

func (b FunctionBuilder) HandlerEllipsis()

function param

func (FunctionBuilder) HasUsers added in v1.2.8

func (n FunctionBuilder) HasUsers() bool

has/get user and value

func (*FunctionBuilder) InterfaceAddFieldBuild added in v1.3.1

func (b *FunctionBuilder) InterfaceAddFieldBuild(size int, keys func(int) Value, value func(int) Value) *Make

func (*FunctionBuilder) IsBlockFinish added in v1.3.0

func (b *FunctionBuilder) IsBlockFinish() bool

current block is finish?

func (FunctionBuilder) IsMember added in v1.3.1

func (n FunctionBuilder) IsMember() bool

func (FunctionBuilder) IsObject added in v1.3.1

func (n FunctionBuilder) IsObject() bool

func (*FunctionBuilder) IsParentFunctionVariable added in v1.3.1

func (b *FunctionBuilder) IsParentFunctionVariable(v *Variable) bool

func (FunctionBuilder) Masked added in v1.3.0

func (i FunctionBuilder) Masked() bool

func (*FunctionBuilder) NewCall

func (f *FunctionBuilder) NewCall(target Value, args []Value) *Call

func (*FunctionBuilder) NewError

func (b *FunctionBuilder) NewError(kind ErrorKind, tag ErrorTag, massage string, arg ...interface{})

func (*FunctionBuilder) NewFunc

func (b *FunctionBuilder) NewFunc(name string) *Function

new function

func (*FunctionBuilder) NewParam added in v1.3.1

func (f *FunctionBuilder) NewParam(name string, pos ...CanStartStopToken) *Parameter

func (*FunctionBuilder) NewParameterMember added in v1.3.3

func (f *FunctionBuilder) NewParameterMember(name string, obj *Parameter, key Value) *ParameterMember

func (*FunctionBuilder) PeekValue added in v1.3.1

func (b *FunctionBuilder) PeekValue(name string) Value

func (*FunctionBuilder) PeekValueByVariable added in v1.3.1

func (b *FunctionBuilder) PeekValueByVariable(v *Variable) Value

func (*FunctionBuilder) PeekValueInThisFunction added in v1.3.1

func (b *FunctionBuilder) PeekValueInThisFunction(name string) Value

func (*FunctionBuilder) PopFunction

func (b *FunctionBuilder) PopFunction() *FunctionBuilder

func (*FunctionBuilder) PopTarget

func (b *FunctionBuilder) PopTarget() bool

func (*FunctionBuilder) PushFunction

func (b *FunctionBuilder) PushFunction(newFunc *Function) *FunctionBuilder

function stack

func (*FunctionBuilder) PushTarget

func (b *FunctionBuilder) PushTarget(scope ssautil.LabelTarget[Value], _break, _continue, _fallthrough *BasicBlock)

target stack

func (*FunctionBuilder) ReadMemberCallVariable added in v1.3.1

func (b *FunctionBuilder) ReadMemberCallVariable(value, key Value) Value

func (*FunctionBuilder) ReadOrCreateMemberCallVariable added in v1.3.1

func (b *FunctionBuilder) ReadOrCreateMemberCallVariable(caller, callee Value) Value

func (*FunctionBuilder) ReadOrCreateVariable added in v1.3.1

func (b *FunctionBuilder) ReadOrCreateVariable(name string) Value

func (*FunctionBuilder) ReadValue added in v1.3.1

func (b *FunctionBuilder) ReadValue(name string) Value

ReadValue get value by name

func (*FunctionBuilder) ReadValueByVariable added in v1.3.1

func (b *FunctionBuilder) ReadValueByVariable(v *Variable) Value

ReadValueByVariable get value by variable

func (*FunctionBuilder) ReadValueInThisFunction added in v1.3.1

func (b *FunctionBuilder) ReadValueInThisFunction(name string) Value

func (FunctionBuilder) Reference

func (i FunctionBuilder) Reference() Values

func (*FunctionBuilder) ReferenceParameter added in v1.3.2

func (b *FunctionBuilder) ReferenceParameter(name string)

func (FunctionBuilder) RemoveUser added in v1.2.8

func (n FunctionBuilder) RemoveUser(u User)

func (*FunctionBuilder) SetClassBluePrint

func (b *FunctionBuilder) SetClassBluePrint(name string, class *ClassBluePrint)

func (*FunctionBuilder) SetCurrent added in v1.2.8

func (f *FunctionBuilder) SetCurrent(i Instruction, noChangeRanges ...bool) func()

func (*FunctionBuilder) SetEditor added in v1.3.3

func (b *FunctionBuilder) SetEditor(editor *memedit.MemEditor)

func (*FunctionBuilder) SetInstructionPosition added in v1.2.9

func (f *FunctionBuilder) SetInstructionPosition(i Instruction)

func (FunctionBuilder) SetKey added in v1.3.1

func (n FunctionBuilder) SetKey(k Value)

func (*FunctionBuilder) SetMarkedFunction added in v1.3.1

func (b *FunctionBuilder) SetMarkedFunction(name string)

func (FunctionBuilder) SetObject added in v1.3.1

func (n FunctionBuilder) SetObject(v Value)

func (*FunctionBuilder) SetRange added in v1.3.0

func (b *FunctionBuilder) SetRange(token CanStartStopToken) func()

func (*FunctionBuilder) SetRangeFromTerminalNode added in v1.3.3

func (b *FunctionBuilder) SetRangeFromTerminalNode(node antlr.TerminalNode) func()

func (*FunctionBuilder) TryBuildExternValue added in v1.2.8

func (b *FunctionBuilder) TryBuildExternValue(id string) Value

func (*FunctionBuilder) TryGetSimilarityKey added in v1.2.8

func (b *FunctionBuilder) TryGetSimilarityKey(name, key string) string

func (*FunctionBuilder) WithDefineFunction added in v1.3.1

func (b *FunctionBuilder) WithDefineFunction(defineFunc map[string]any)

func (*FunctionBuilder) WithExternLib added in v1.2.8

func (b *FunctionBuilder) WithExternLib(lib map[string]map[string]any)

func (*FunctionBuilder) WithExternMethod added in v1.2.9

func (b *FunctionBuilder) WithExternMethod(builder MethodBuilder)

func (*FunctionBuilder) WithExternValue added in v1.2.8

func (b *FunctionBuilder) WithExternValue(vs map[string]any)

type FunctionSideEffect added in v1.3.1

type FunctionSideEffect struct {
	Name        string
	VerboseName string
	Modify      Value
	// only call-side Scope > this Scope-level, this side-effect can be create
	// Scope *Scope
	Variable *Variable
	// contains filtered or unexported fields
}

FunctionSideEffect is a side-effect in a closure

func (FunctionSideEffect) Get added in v1.3.3

func (p FunctionSideEffect) Get(c *Call) (obj Value, ok bool)

type FunctionType added in v1.2.8

type FunctionType struct {
	Name string

	This            *Function
	ReturnType      Type
	ReturnValue     []*Return
	Parameter       Types
	ParameterLen    int
	ParameterValue  []*Parameter
	FreeValue       []*Parameter
	ParameterMember []*ParameterMember
	SideEffects     []*FunctionSideEffect
	IsVariadic      bool
	IsMethod        bool
	ObjectType      Type
	IsModifySelf    bool // if this is method function

	AnnotationFunc []func(Value)
	// contains filtered or unexported fields
}

func NewFunctionType added in v1.2.8

func NewFunctionType(name string, Parameter []Type, ReturnType Type, IsVariadic bool) *FunctionType

func NewFunctionTypeDefine added in v1.2.9

func NewFunctionTypeDefine(name string, Parameter []Type, ReturnType []Type, IsVariadic bool) *FunctionType

func ToFunctionType added in v1.2.8

func ToFunctionType(t Type) (*FunctionType, bool)

func (*FunctionType) AddAnnotationFunc

func (f *FunctionType) AddAnnotationFunc(handler ...func(Value))

func (*FunctionType) AddMethod added in v1.2.9

func (b *FunctionType) AddMethod(id string, f *Function)

func (*FunctionType) GetMethod added in v1.2.8

func (f *FunctionType) GetMethod() map[string]*Function

func (*FunctionType) GetParamString added in v1.2.8

func (s *FunctionType) GetParamString() string

func (*FunctionType) GetTypeKind added in v1.2.8

func (s *FunctionType) GetTypeKind() TypeKind

func (*FunctionType) PkgPathString added in v1.3.1

func (s *FunctionType) PkgPathString() string

func (*FunctionType) RawString added in v1.2.8

func (s *FunctionType) RawString() string

func (*FunctionType) SetFreeValue added in v1.2.8

func (s *FunctionType) SetFreeValue(fv map[string]*Parameter)

func (*FunctionType) SetMethod added in v1.2.8

func (f *FunctionType) SetMethod(m map[string]*Function)

func (*FunctionType) SetModifySelf added in v1.2.9

func (f *FunctionType) SetModifySelf(b bool)

func (*FunctionType) SetName added in v1.2.8

func (s *FunctionType) SetName(name string)

func (*FunctionType) SetSideEffect added in v1.2.9

func (s *FunctionType) SetSideEffect(se []*FunctionSideEffect)

func (*FunctionType) String added in v1.2.8

func (s *FunctionType) String() string

type If

type If struct {
	Cond  Value
	True  *BasicBlock
	False *BasicBlock
	// contains filtered or unexported fields
}

----------- IF The If instruction transfers control to one of the two successors of its owning block, depending on the boolean Cond: the first if true, the second if false.

func NewIf added in v1.2.8

func NewIf() *If

func (*If) AddFalse

func (i *If) AddFalse(f *BasicBlock)

func (*If) AddTrue

func (i *If) AddTrue(t *BasicBlock)

func (*If) GetBlock

func (a *If) GetBlock() *BasicBlock

func (*If) GetFunc added in v1.2.8

func (a *If) GetFunc() *Function

func (*If) GetId added in v1.3.0

func (a *If) GetId() int64

func (*If) GetName added in v1.3.0

func (a *If) GetName() string

func (*If) GetOpcode added in v1.2.8

func (i *If) GetOpcode() Opcode

func (*If) GetProgram added in v1.3.0

func (a *If) GetProgram() *Program

func (*If) GetRange added in v1.3.0

func (c *If) GetRange() *Range

source code position

func (*If) GetShortVerboseName added in v1.3.2

func (i *If) GetShortVerboseName() string

func (*If) GetSourceCode added in v1.3.3

func (v *If) GetSourceCode() string

func (*If) GetSourceCodeContext added in v1.3.3

func (v *If) GetSourceCodeContext(n int) string

func (*If) GetUsers

func (r *If) GetUsers() Users

func (*If) GetValues

func (i *If) GetValues() Values

func (*If) GetVerboseName added in v1.3.1

func (i *If) GetVerboseName() string

func (*If) HasUsers added in v1.2.8

func (r *If) HasUsers() bool

func (*If) HasValues added in v1.2.8

func (i *If) HasValues() bool

----------- IF

func (*If) IsExtern added in v1.2.8

func (c *If) IsExtern() bool

func (*If) IsUndefined added in v1.3.1

func (i *If) IsUndefined() bool

func (*If) LineDisasm added in v1.2.8

func (a *If) LineDisasm() string

func (*If) NewError

func (c *If) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*If) ReplaceValue

func (i *If) ReplaceValue(v Value, to Value)

func (*If) SelfDelete added in v1.3.1

func (i *If) SelfDelete()

func (*If) SetBlock added in v1.2.8

func (a *If) SetBlock(block *BasicBlock)

func (*If) SetCondition added in v1.3.1

func (i *If) SetCondition(t Value)

func (*If) SetExtern added in v1.2.8

func (c *If) SetExtern(b bool)

func (*If) SetFunc added in v1.2.8

func (a *If) SetFunc(f *Function)

ssa function and block

func (*If) SetId added in v1.3.0

func (a *If) SetId(id int64)

id

func (*If) SetName added in v1.3.0

func (a *If) SetName(v string)

variable

func (*If) SetRange added in v1.3.0

func (c *If) SetRange(pos *Range)

func (*If) SetVerboseName added in v1.3.1

func (i *If) SetVerboseName(verbose string)

func (*If) String

func (i *If) String() string

----------- IF

type IfBuilder added in v1.2.8

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

IfBuilder is a builder for if statement ssa control flow: if builder

func (*IfBuilder) AppendItem added in v1.3.1

func (i *IfBuilder) AppendItem(cond func() Value, body func()) *IfBuilder

AppendItem append IfBuilderItem to IfBuilder

func (*IfBuilder) Build added in v1.3.1

func (i *IfBuilder) Build() *IfBuilder

Build if statement

func (*IfBuilder) SetCondition added in v1.3.1

func (i *IfBuilder) SetCondition(cond func() Value, body func()) *IfBuilder

SetCondition build if condition and body, short for append item

func (*IfBuilder) SetElse added in v1.3.1

func (i *IfBuilder) SetElse(body func()) *IfBuilder

SetElse build else body

type IfBuilderItem added in v1.3.1

type IfBuilderItem struct {
	Condition func() Value
	Body      func()
}

IfBuilderItem is pair of condition and body, if condition is true, then run body

type Instruction

type Instruction interface {
	ErrorLogger

	GetOpcode() Opcode

	// function
	GetFunc() *Function
	SetFunc(*Function)
	// block
	GetBlock() *BasicBlock
	SetBlock(*BasicBlock)
	// program
	GetProgram() *Program

	GetName() string
	SetName(variable string)
	GetVerboseName() string
	GetShortVerboseName() string
	SetVerboseName(string)

	GetId() int64 // for identify
	SetId(int64)

	// position
	GetRange() *Range
	SetRange(*Range)
	GetSourceCode() string
	GetSourceCodeContext(n int) string

	// extern
	IsExtern() bool
	SetExtern(bool)

	SelfDelete()
}

func CreateInstruction added in v1.3.3

func CreateInstruction(op Opcode) Instruction

type InterfaceType

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

====================== interface type

func NewInterfaceType

func NewInterfaceType(name, pkgPath string) *InterfaceType

func (*InterfaceType) AddMethod added in v1.2.9

func (b *InterfaceType) AddMethod(id string, f *Function)

func (*InterfaceType) GetMethod added in v1.2.8

func (i *InterfaceType) GetMethod() map[string]*Function

func (*InterfaceType) GetTypeKind added in v1.2.8

func (i *InterfaceType) GetTypeKind() TypeKind

func (*InterfaceType) PkgPathString added in v1.3.1

func (i *InterfaceType) PkgPathString() string

func (*InterfaceType) RawString added in v1.2.8

func (i *InterfaceType) RawString() string

func (*InterfaceType) SetMethod added in v1.2.8

func (i *InterfaceType) SetMethod(m map[string]*Function)

func (*InterfaceType) String

func (i *InterfaceType) String() string

type Jump

type Jump struct {
	To *BasicBlock
	// contains filtered or unexported fields
}

----------- Jump The Jump instruction transfers control to the sole successor of its owning block.

the block containing Jump instruction only have one successor block

func NewJump added in v1.2.8

func NewJump(to *BasicBlock) *Jump

func (*Jump) GetBlock

func (a *Jump) GetBlock() *BasicBlock

func (*Jump) GetFunc added in v1.2.8

func (a *Jump) GetFunc() *Function

func (*Jump) GetId added in v1.3.0

func (a *Jump) GetId() int64

func (*Jump) GetName added in v1.3.0

func (a *Jump) GetName() string

func (*Jump) GetOpcode added in v1.2.8

func (i *Jump) GetOpcode() Opcode

func (*Jump) GetProgram added in v1.3.0

func (a *Jump) GetProgram() *Program

func (*Jump) GetRange added in v1.3.0

func (c *Jump) GetRange() *Range

source code position

func (*Jump) GetShortVerboseName added in v1.3.2

func (i *Jump) GetShortVerboseName() string

func (*Jump) GetSourceCode added in v1.3.3

func (v *Jump) GetSourceCode() string

func (*Jump) GetSourceCodeContext added in v1.3.3

func (v *Jump) GetSourceCodeContext(n int) string

func (*Jump) GetVerboseName added in v1.3.1

func (i *Jump) GetVerboseName() string

func (*Jump) IsExtern added in v1.2.8

func (c *Jump) IsExtern() bool

func (*Jump) IsUndefined added in v1.3.1

func (i *Jump) IsUndefined() bool

func (*Jump) LineDisasm added in v1.2.8

func (a *Jump) LineDisasm() string

func (*Jump) NewError

func (c *Jump) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*Jump) ReplaceValue added in v1.3.1

func (i *Jump) ReplaceValue(Value, Value)

func (*Jump) SelfDelete added in v1.3.1

func (i *Jump) SelfDelete()

func (*Jump) SetBlock added in v1.2.8

func (a *Jump) SetBlock(block *BasicBlock)

func (*Jump) SetExtern added in v1.2.8

func (c *Jump) SetExtern(b bool)

func (*Jump) SetFunc added in v1.2.8

func (a *Jump) SetFunc(f *Function)

ssa function and block

func (*Jump) SetId added in v1.3.0

func (a *Jump) SetId(id int64)

id

func (*Jump) SetName added in v1.3.0

func (a *Jump) SetName(v string)

variable

func (*Jump) SetRange added in v1.3.0

func (c *Jump) SetRange(pos *Range)

func (*Jump) SetVerboseName added in v1.3.1

func (i *Jump) SetVerboseName(verbose string)

func (*Jump) String

func (j *Jump) String() string

----------- Jump

type LazyInstruction added in v1.3.3

type LazyInstruction struct {
	Instruction
	Value
	User

	Modify bool
	// contains filtered or unexported fields
}

func ToLazyInstruction added in v1.3.3

func ToLazyInstruction(n any) (*LazyInstruction, bool)

func (*LazyInstruction) AddMask added in v1.3.3

func (lz *LazyInstruction) AddMask(v Value)

func (*LazyInstruction) AddMember added in v1.3.3

func (lz *LazyInstruction) AddMember(v1 Value, v2 Value)

func (*LazyInstruction) AddVariable added in v1.3.3

func (lz *LazyInstruction) AddVariable(v *Variable)

func (*LazyInstruction) DeleteMember added in v1.3.3

func (lz *LazyInstruction) DeleteMember(v Value)

func (*LazyInstruction) ForEachMember added in v1.3.3

func (lz *LazyInstruction) ForEachMember(fn func(Value, Value) bool)

func (*LazyInstruction) GetAllMember added in v1.3.3

func (lz *LazyInstruction) GetAllMember() map[Value]Value

func (*LazyInstruction) GetAllVariables added in v1.3.3

func (lz *LazyInstruction) GetAllVariables() map[string]*Variable

func (*LazyInstruction) GetBlock added in v1.3.3

func (lz *LazyInstruction) GetBlock() *BasicBlock

func (*LazyInstruction) GetFunc added in v1.3.3

func (lz *LazyInstruction) GetFunc() *Function

func (*LazyInstruction) GetId added in v1.3.3

func (lz *LazyInstruction) GetId() int64

just use lazy instruction

func (*LazyInstruction) GetIndexMember added in v1.3.3

func (lz *LazyInstruction) GetIndexMember(i int) (Value, bool)

func (*LazyInstruction) GetKey added in v1.3.3

func (lz *LazyInstruction) GetKey() Value

func (*LazyInstruction) GetLastVariable added in v1.3.3

func (lz *LazyInstruction) GetLastVariable() *Variable

func (*LazyInstruction) GetMask added in v1.3.3

func (lz *LazyInstruction) GetMask() []Value

func (*LazyInstruction) GetMember added in v1.3.3

func (lz *LazyInstruction) GetMember(v Value) (Value, bool)

func (*LazyInstruction) GetName added in v1.3.3

func (lz *LazyInstruction) GetName() string

just use IrCode

func (*LazyInstruction) GetObject added in v1.3.3

func (lz *LazyInstruction) GetObject() Value

func (*LazyInstruction) GetOpcode added in v1.3.3

func (lz *LazyInstruction) GetOpcode() Opcode

func (*LazyInstruction) GetProgram added in v1.3.3

func (lz *LazyInstruction) GetProgram() *Program

func (*LazyInstruction) GetRange added in v1.3.3

func (lz *LazyInstruction) GetRange() *Range

func (*LazyInstruction) GetShortVerboseName added in v1.3.3

func (lz *LazyInstruction) GetShortVerboseName() string

func (*LazyInstruction) GetSourceCode added in v1.3.3

func (lz *LazyInstruction) GetSourceCode() string

func (*LazyInstruction) GetSourceCodeContext added in v1.3.3

func (lz *LazyInstruction) GetSourceCodeContext(n int) string

func (*LazyInstruction) GetStringMember added in v1.3.3

func (lz *LazyInstruction) GetStringMember(n string) (Value, bool)

func (*LazyInstruction) GetType added in v1.3.3

func (lz *LazyInstruction) GetType() Type

func (*LazyInstruction) GetUsers added in v1.3.3

func (lz *LazyInstruction) GetUsers() Users

func (*LazyInstruction) GetValues added in v1.3.3

func (lz *LazyInstruction) GetValues() Values

func (*LazyInstruction) GetVariable added in v1.3.3

func (lz *LazyInstruction) GetVariable(n string) *Variable

func (*LazyInstruction) GetVerboseName added in v1.3.3

func (lz *LazyInstruction) GetVerboseName() string

func (*LazyInstruction) HasUsers added in v1.3.3

func (lz *LazyInstruction) HasUsers() bool

func (*LazyInstruction) HasValues added in v1.3.3

func (lz *LazyInstruction) HasValues() bool

func (*LazyInstruction) IsExtern added in v1.3.3

func (lz *LazyInstruction) IsExtern() bool

func (*LazyInstruction) IsMember added in v1.3.3

func (lz *LazyInstruction) IsMember() bool

func (*LazyInstruction) IsObject added in v1.3.3

func (lz *LazyInstruction) IsObject() bool

func (*LazyInstruction) IsUndefined added in v1.3.3

func (lz *LazyInstruction) IsUndefined() bool

func (*LazyInstruction) Masked added in v1.3.3

func (lz *LazyInstruction) Masked() bool

func (*LazyInstruction) NewError added in v1.3.3

func (lz *LazyInstruction) NewError(e ErrorKind, t ErrorTag, msg string)

func (*LazyInstruction) Reference

func (lz *LazyInstruction) Reference() Values

func (*LazyInstruction) ReplaceValue added in v1.3.3

func (lz *LazyInstruction) ReplaceValue(v1, v2 Value)

func (*LazyInstruction) Self added in v1.3.3

func (lz *LazyInstruction) Self() Value

func (*LazyInstruction) SelfDelete added in v1.3.3

func (lz *LazyInstruction) SelfDelete()

func (*LazyInstruction) SetBlock added in v1.3.3

func (lz *LazyInstruction) SetBlock(b *BasicBlock)

func (*LazyInstruction) SetExtern added in v1.3.3

func (lz *LazyInstruction) SetExtern(extern bool)

func (*LazyInstruction) SetFunc added in v1.3.3

func (lz *LazyInstruction) SetFunc(f *Function)

func (*LazyInstruction) SetId added in v1.3.3

func (lz *LazyInstruction) SetId(id int64)

func (*LazyInstruction) SetKey added in v1.3.3

func (lz *LazyInstruction) SetKey(v Value)

func (*LazyInstruction) SetName added in v1.3.3

func (lz *LazyInstruction) SetName(name string)

func (*LazyInstruction) SetObject added in v1.3.3

func (lz *LazyInstruction) SetObject(v Value)

func (*LazyInstruction) SetRange added in v1.3.3

func (lz *LazyInstruction) SetRange(r *Range)

func (*LazyInstruction) SetType added in v1.3.3

func (lz *LazyInstruction) SetType(t Type)

func (*LazyInstruction) SetVerboseName added in v1.3.3

func (lz *LazyInstruction) SetVerboseName(name string)

func (*LazyInstruction) ShouldSave added in v1.3.3

func (lz *LazyInstruction) ShouldSave() bool

func (*LazyInstruction) String added in v1.3.3

func (lz *LazyInstruction) String() string

type Loop added in v1.2.8

type Loop struct {
	Body, Exit *BasicBlock

	Init, Cond, Step Value
	Key              Value
	// contains filtered or unexported fields
}

----------- For for loop

func NewLoop added in v1.2.8

func NewLoop(cond Value) *Loop

func (*Loop) Finish added in v1.2.8

func (l *Loop) Finish(init, step []Value)

func (*Loop) GetBlock added in v1.2.8

func (a *Loop) GetBlock() *BasicBlock

func (*Loop) GetFunc added in v1.2.8

func (a *Loop) GetFunc() *Function

func (*Loop) GetId added in v1.3.0

func (a *Loop) GetId() int64

func (*Loop) GetName added in v1.3.0

func (a *Loop) GetName() string

func (*Loop) GetOpcode added in v1.2.8

func (i *Loop) GetOpcode() Opcode

func (*Loop) GetProgram added in v1.3.0

func (a *Loop) GetProgram() *Program

func (*Loop) GetRange added in v1.3.0

func (c *Loop) GetRange() *Range

source code position

func (*Loop) GetShortVerboseName added in v1.3.2

func (i *Loop) GetShortVerboseName() string

func (*Loop) GetSourceCode added in v1.3.3

func (v *Loop) GetSourceCode() string

func (*Loop) GetSourceCodeContext added in v1.3.3

func (v *Loop) GetSourceCodeContext(n int) string

func (*Loop) GetUsers added in v1.2.8

func (r *Loop) GetUsers() Users

func (*Loop) GetValues added in v1.2.8

func (l *Loop) GetValues() Values

func (*Loop) GetVerboseName added in v1.3.1

func (i *Loop) GetVerboseName() string

func (*Loop) HasUsers added in v1.2.8

func (r *Loop) HasUsers() bool

func (*Loop) HasValues added in v1.2.8

func (l *Loop) HasValues() bool

----------- Loop

func (*Loop) IsExtern added in v1.2.8

func (c *Loop) IsExtern() bool

func (*Loop) IsUndefined added in v1.3.1

func (i *Loop) IsUndefined() bool

func (*Loop) LineDisasm added in v1.2.8

func (a *Loop) LineDisasm() string

func (*Loop) NewError added in v1.2.8

func (c *Loop) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*Loop) ReplaceValue added in v1.2.8

func (l *Loop) ReplaceValue(v Value, to Value)

func (*Loop) SelfDelete added in v1.3.1

func (i *Loop) SelfDelete()

func (*Loop) SetBlock added in v1.2.8

func (a *Loop) SetBlock(block *BasicBlock)

func (*Loop) SetExtern added in v1.2.8

func (c *Loop) SetExtern(b bool)

func (*Loop) SetFunc added in v1.2.8

func (a *Loop) SetFunc(f *Function)

ssa function and block

func (*Loop) SetId added in v1.3.0

func (a *Loop) SetId(id int64)

id

func (*Loop) SetName added in v1.3.0

func (a *Loop) SetName(v string)

variable

func (*Loop) SetRange added in v1.3.0

func (c *Loop) SetRange(pos *Range)

func (*Loop) SetVerboseName added in v1.3.1

func (i *Loop) SetVerboseName(verbose string)

func (*Loop) String added in v1.2.8

func (l *Loop) String() string

----------- Loop

type LoopBuilder added in v1.2.8

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

enter:

       ...
	    // for first expression in here
     jump loop.header

loop.header: <- enter, loop.latch

// for stmt cond in here
If [cond] true -> loop.body, false -> loop.exit

loop.body: <- loop.header

// for body block in here

loop.latch: <- loop.body (target of continue)

// for third expr in here
jump loop.header

loop.exit: <- loop.header (target of break)

jump rest

rest:

...rest.code....

LoopBuilder is a builder for loop statement

func (*LoopBuilder) Finish added in v1.2.8

func (lb *LoopBuilder) Finish()

func (*LoopBuilder) SetBody added in v1.3.1

func (lb *LoopBuilder) SetBody(f func())

SetBody : Loop Body

func (*LoopBuilder) SetCondition added in v1.3.1

func (lb *LoopBuilder) SetCondition(f func() Value)

SetCondition : Loop Condition

func (*LoopBuilder) SetFirst added in v1.3.1

func (lb *LoopBuilder) SetFirst(f func() []Value)

SetFirst : Loop First Expression

func (*LoopBuilder) SetThird added in v1.3.1

func (lb *LoopBuilder) SetThird(f func() []Value)

SetThird : Loop Third Expression

type Make added in v1.2.8

type Make struct {

	// when slice or map
	Len, Cap Value
	// contains filtered or unexported fields
}

----------- Make

func NewMake added in v1.2.8

func NewMake(parentI Value, typ Type, low, high, step, Len, Cap Value) *Make

func ToMake added in v1.3.0

func ToMake(v Instruction) (*Make, bool)

func (*Make) AddMask added in v1.3.0

func (i *Make) AddMask(v Value)

func (*Make) AddMember added in v1.3.1

func (n *Make) AddMember(k, v Value)

func (*Make) AddReference

func (i *Make) AddReference(v Value)

func (*Make) AddUser added in v1.2.8

func (n *Make) AddUser(u User)

for Value

func (*Make) AddVariable added in v1.3.0

func (a *Make) AddVariable(v *Variable)

func (*Make) DeleteMember added in v1.3.1

func (n *Make) DeleteMember(k Value)

func (*Make) ForEachMember added in v1.3.3

func (n *Make) ForEachMember(fn func(Value, Value) bool)

func (*Make) GetAllMember added in v1.3.1

func (n *Make) GetAllMember() map[Value]Value

func (*Make) GetAllVariables added in v1.3.0

func (a *Make) GetAllVariables() map[string]*Variable

func (*Make) GetIndexMember added in v1.3.1

func (n *Make) GetIndexMember(i int) (Value, bool)

func (*Make) GetKey added in v1.3.1

func (n *Make) GetKey() Value

func (*Make) GetLastVariable added in v1.3.1

func (a *Make) GetLastVariable() *Variable

func (*Make) GetMask added in v1.3.0

func (i *Make) GetMask() []Value

func (*Make) GetMember added in v1.3.1

func (n *Make) GetMember(key Value) (Value, bool)

func (*Make) GetObject added in v1.3.1

func (n *Make) GetObject() Value

func (*Make) GetOpcode added in v1.2.8

func (i *Make) GetOpcode() Opcode

func (*Make) GetStringMember added in v1.3.1

func (n *Make) GetStringMember(key string) (Value, bool)

func (*Make) GetType added in v1.2.8

func (n *Make) GetType() Type

for Value : type

func (*Make) GetUsers added in v1.2.8

func (n *Make) GetUsers() Users

func (*Make) GetValues added in v1.2.8

func (i *Make) GetValues() Values

func (*Make) GetVariable added in v1.2.8

func (a *Make) GetVariable(name string) *Variable

func (*Make) HasUsers added in v1.2.8

func (n *Make) HasUsers() bool

has/get user and value

func (*Make) HasValues added in v1.2.8

func (i *Make) HasValues() bool

// ----------- Make

func (*Make) IsMember added in v1.3.1

func (n *Make) IsMember() bool

func (*Make) IsObject added in v1.3.1

func (n *Make) IsObject() bool

func (*Make) Masked added in v1.3.0

func (i *Make) Masked() bool

func (*Make) Reference

func (i *Make) Reference() Values

func (*Make) RemoveUser added in v1.2.8

func (n *Make) RemoveUser(u User)

func (*Make) ReplaceValue added in v1.2.8

func (i *Make) ReplaceValue(v, to Value)

func (*Make) SetKey added in v1.3.1

func (n *Make) SetKey(k Value)

func (*Make) SetObject added in v1.3.1

func (n *Make) SetObject(v Value)

func (*Make) SetType added in v1.2.8

func (n *Make) SetType(typ Type)

func (*Make) String added in v1.2.8

func (i *Make) String() string

----------- Interface

type Maskable added in v1.3.0

type Maskable interface {
	AddMask(Value)
	GetMask() []Value
	Masked() bool
}

type MemberCall added in v1.3.1

type MemberCall interface {
	// object  member caller
	IsObject() bool
	AddMember(Value, Value)
	GetMember(Value) (Value, bool)
	GetIndexMember(int) (Value, bool)
	GetStringMember(string) (Value, bool)
	DeleteMember(Value)            // delete by key
	GetAllMember() map[Value]Value // map[key]value
	ForEachMember(func(k Value, v Value) bool)

	// member, member callee
	IsMember() bool
	SetObject(Value)
	SetKey(Value)
	GetKey() Value
	GetObject() Value
}

type MethodBuilder added in v1.2.9

type MethodBuilder interface {
	Build(Type, string) *Function
	GetMethodNames(Type) []string
}
var ExternMethodBuilder MethodBuilder

type NameDisasmLiner added in v1.3.1

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

func NewNameDisasmLiner added in v1.3.1

func NewNameDisasmLiner() *NameDisasmLiner

func (*NameDisasmLiner) AddLevel added in v1.3.1

func (n *NameDisasmLiner) AddLevel() bool

func (NameDisasmLiner) DeleteName added in v1.3.1

func (b NameDisasmLiner) DeleteName(i Instruction)

func (*NameDisasmLiner) DisasmValue added in v1.3.1

func (n *NameDisasmLiner) DisasmValue(v Value) string

func (NameDisasmLiner) GetName added in v1.3.1

func (b NameDisasmLiner) GetName(i Instruction) (string, bool)

func (NameDisasmLiner) SetName added in v1.3.1

func (b NameDisasmLiner) SetName(i Instruction, name string)

func (*NameDisasmLiner) SkipLevelChecking added in v1.3.1

func (b *NameDisasmLiner) SkipLevelChecking() bool

type Next added in v1.2.8

type Next struct {
	Iter   Value
	InNext bool // "in" grammar
	// contains filtered or unexported fields
}

------------- Next

func NewNext added in v1.2.8

func NewNext(iter Value, isIn bool) *Next

func (*Next) AddMask added in v1.3.0

func (i *Next) AddMask(v Value)

func (*Next) AddMember added in v1.3.1

func (n *Next) AddMember(k, v Value)

func (*Next) AddReference

func (i *Next) AddReference(v Value)

func (*Next) AddUser added in v1.2.8

func (n *Next) AddUser(u User)

for Value

func (*Next) AddVariable added in v1.3.0

func (a *Next) AddVariable(v *Variable)

func (*Next) DeleteMember added in v1.3.1

func (n *Next) DeleteMember(k Value)

func (*Next) ForEachMember added in v1.3.3

func (n *Next) ForEachMember(fn func(Value, Value) bool)

func (*Next) GetAllMember added in v1.3.1

func (n *Next) GetAllMember() map[Value]Value

func (*Next) GetAllVariables added in v1.3.0

func (a *Next) GetAllVariables() map[string]*Variable

func (*Next) GetIndexMember added in v1.3.1

func (n *Next) GetIndexMember(i int) (Value, bool)

func (*Next) GetKey added in v1.3.1

func (n *Next) GetKey() Value

func (*Next) GetLastVariable added in v1.3.1

func (a *Next) GetLastVariable() *Variable

func (*Next) GetMask added in v1.3.0

func (i *Next) GetMask() []Value

func (*Next) GetMember added in v1.3.1

func (n *Next) GetMember(key Value) (Value, bool)

func (*Next) GetObject added in v1.3.1

func (n *Next) GetObject() Value

func (*Next) GetOpcode added in v1.2.8

func (i *Next) GetOpcode() Opcode

func (*Next) GetStringMember added in v1.3.1

func (n *Next) GetStringMember(key string) (Value, bool)

func (*Next) GetType added in v1.2.8

func (n *Next) GetType() Type

for Value : type

func (*Next) GetUsers added in v1.2.8

func (n *Next) GetUsers() Users

func (*Next) GetValues added in v1.2.8

func (n *Next) GetValues() Values

func (*Next) GetVariable added in v1.2.8

func (a *Next) GetVariable(name string) *Variable

func (*Next) HasUsers added in v1.2.8

func (n *Next) HasUsers() bool

has/get user and value

func (*Next) HasValues added in v1.2.8

func (n *Next) HasValues() bool

// ----------- Next

func (*Next) IsMember added in v1.3.1

func (n *Next) IsMember() bool

func (*Next) IsObject added in v1.3.1

func (n *Next) IsObject() bool

func (*Next) Masked added in v1.3.0

func (i *Next) Masked() bool

func (*Next) Reference

func (i *Next) Reference() Values

func (*Next) RemoveUser added in v1.2.8

func (n *Next) RemoveUser(u User)

func (*Next) ReplaceValue added in v1.2.8

func (n *Next) ReplaceValue(v, to Value)

func (*Next) SetKey added in v1.3.1

func (n *Next) SetKey(k Value)

func (*Next) SetObject added in v1.3.1

func (n *Next) SetObject(v Value)

func (*Next) SetType added in v1.2.8

func (n *Next) SetType(typ Type)

func (*Next) String added in v1.2.8

func (n *Next) String() string

type Node

type Node interface {
	// string
	String() string

	// for graph
	HasUsers() bool
	GetUsers() Users
	HasValues() bool
	GetValues() Values
	IsUndefined() bool
}

data-flow

func ToNode added in v1.2.8

func ToNode(a any) (Node, bool)

for DataFlowNode cover

type ObjectType added in v1.2.8

type ObjectType struct {
	Name string

	Kind TypeKind
	Len  int
	Keys []Value

	FieldTypes []Type

	AnonymousField []*ObjectType

	Combination bool // function multiple return will combined to struct

	KeyTyp    Type
	FieldType Type
	// contains filtered or unexported fields
}

==================== interface type

func NewMapType

func NewMapType(key, field Type) *ObjectType

func NewObjectType added in v1.2.8

func NewObjectType() *ObjectType

func NewSliceType

func NewSliceType(elem Type) *ObjectType

for slice build

func NewStructType added in v1.2.8

func NewStructType() *ObjectType

func ToObjectType added in v1.2.8

func ToObjectType(t Type) (*ObjectType, bool)

func (*ObjectType) AddField added in v1.2.8

func (s *ObjectType) AddField(key Value, field Type)

for struct build

func (*ObjectType) AddMethod added in v1.2.9

func (b *ObjectType) AddMethod(id string, f *Function)

func (*ObjectType) Finish added in v1.2.8

func (s *ObjectType) Finish()

===================== Finish simply

func (*ObjectType) GetField added in v1.2.8

func (s *ObjectType) GetField(key Value) Type

return (field-type, key-type)

func (*ObjectType) GetMethod added in v1.2.8

func (i *ObjectType) GetMethod() map[string]*Function

func (*ObjectType) GetTypeKind added in v1.2.8

func (i *ObjectType) GetTypeKind() TypeKind

func (*ObjectType) PkgPathString added in v1.3.1

func (i *ObjectType) PkgPathString() string

func (*ObjectType) RawString added in v1.2.8

func (itype *ObjectType) RawString() string

func (*ObjectType) SetMethod added in v1.2.8

func (i *ObjectType) SetMethod(m map[string]*Function)

func (*ObjectType) SetName added in v1.2.8

func (i *ObjectType) SetName(name string)

func (*ObjectType) SetPkgPath added in v1.3.3

func (i *ObjectType) SetPkgPath(pkg string)

func (*ObjectType) SetTypeKind added in v1.3.1

func (i *ObjectType) SetTypeKind(t TypeKind)

func (*ObjectType) String added in v1.2.8

func (itype *ObjectType) String() string

type OffsetItem added in v1.3.3

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

func (*OffsetItem) GetValue added in v1.3.3

func (item *OffsetItem) GetValue() Value

func (*OffsetItem) GetVariable added in v1.3.3

func (item *OffsetItem) GetVariable() *Variable

type Opcode added in v1.2.8

type Opcode int
const (
	SSAOpcodeUnKnow Opcode = iota
	SSAOpcodeAssert
	SSAOpcodeBasicBlock
	SSAOpcodeBinOp
	SSAOpcodeCall
	SSAOpcodeConstInst
	SSAOpcodeErrorHandler
	SSAOpcodeExternLib
	SSAOpcodeIf
	SSAOpcodeJump
	SSAOpcodeLoop
	SSAOpcodeMake
	SSAOpcodeNext
	SSAOpcodePanic
	SSAOpcodeParameter
	SSAOpcodeFreeValue
	SSAOpcodeParameterMember
	SSAOpcodePhi
	SSAOpcodeRecover
	SSAOpcodeReturn
	SSAOpcodeSideEffect
	SSAOpcodeSwitch
	SSAOpcodeTypeCast
	SSAOpcodeTypeValue
	SSAOpcodeUnOp
	SSAOpcodeUndefined
	SSAOpcodeFunction
)

type Package

type Package struct {
	Name string
	// point to program
	Prog *Program
	// function list
	Funcs map[string]*Function

	// class blue print
	ClassBluePrint map[string]*ClassBluePrint
}

func NewPackage added in v1.2.8

func NewPackage(name string) *Package

func (*Package) GetClassBluePrint

func (pkg *Package) GetClassBluePrint(name string) *ClassBluePrint

func (*Package) GetFunction added in v1.3.0

func (pkg *Package) GetFunction(name string) *Function

func (*Package) NewFunction

func (p *Package) NewFunction(name string) *Function

func (*Package) NewFunctionWithParent

func (p *Package) NewFunctionWithParent(name string, parent *Function) *Function

type Panic added in v1.2.8

type Panic struct {
	Info Value
	// contains filtered or unexported fields
}

-------------- PANIC

func (*Panic) AddMask added in v1.3.0

func (i *Panic) AddMask(v Value)

func (*Panic) AddMember added in v1.3.1

func (n *Panic) AddMember(k, v Value)

func (*Panic) AddReference

func (i *Panic) AddReference(v Value)

func (*Panic) AddUser added in v1.2.8

func (n *Panic) AddUser(u User)

for Value

func (*Panic) AddVariable added in v1.3.0

func (a *Panic) AddVariable(v *Variable)

func (*Panic) DeleteMember added in v1.3.1

func (n *Panic) DeleteMember(k Value)

func (*Panic) ForEachMember added in v1.3.3

func (n *Panic) ForEachMember(fn func(Value, Value) bool)

func (*Panic) GetAllMember added in v1.3.1

func (n *Panic) GetAllMember() map[Value]Value

func (*Panic) GetAllVariables added in v1.3.0

func (a *Panic) GetAllVariables() map[string]*Variable

func (*Panic) GetIndexMember added in v1.3.1

func (n *Panic) GetIndexMember(i int) (Value, bool)

func (*Panic) GetKey added in v1.3.1

func (n *Panic) GetKey() Value

func (*Panic) GetLastVariable added in v1.3.1

func (a *Panic) GetLastVariable() *Variable

func (*Panic) GetMask added in v1.3.0

func (i *Panic) GetMask() []Value

func (*Panic) GetMember added in v1.3.1

func (n *Panic) GetMember(key Value) (Value, bool)

func (*Panic) GetObject added in v1.3.1

func (n *Panic) GetObject() Value

func (*Panic) GetOpcode added in v1.2.8

func (i *Panic) GetOpcode() Opcode

func (*Panic) GetStringMember added in v1.3.1

func (n *Panic) GetStringMember(key string) (Value, bool)

func (*Panic) GetType added in v1.2.8

func (n *Panic) GetType() Type

for Value : type

func (*Panic) GetUsers added in v1.2.8

func (n *Panic) GetUsers() Users

func (*Panic) GetValues added in v1.2.8

func (p *Panic) GetValues() Values

func (*Panic) GetVariable added in v1.2.8

func (a *Panic) GetVariable(name string) *Variable

func (*Panic) HasUsers added in v1.2.8

func (n *Panic) HasUsers() bool

has/get user and value

func (*Panic) HasValues added in v1.2.8

func (p *Panic) HasValues() bool

------------- PANIC

func (*Panic) IsMember added in v1.3.1

func (n *Panic) IsMember() bool

func (*Panic) IsObject added in v1.3.1

func (n *Panic) IsObject() bool

func (*Panic) Masked added in v1.3.0

func (i *Panic) Masked() bool

func (*Panic) Reference

func (i *Panic) Reference() Values

func (*Panic) RemoveUser added in v1.2.8

func (n *Panic) RemoveUser(u User)

func (*Panic) ReplaceValue added in v1.2.8

func (p *Panic) ReplaceValue(v, to Value)

func (*Panic) SetKey added in v1.3.1

func (n *Panic) SetKey(k Value)

func (*Panic) SetObject added in v1.3.1

func (n *Panic) SetObject(v Value)

func (*Panic) SetType added in v1.2.8

func (n *Panic) SetType(typ Type)

func (*Panic) String added in v1.2.8

func (p *Panic) String() string

type Parameter

type Parameter struct {

	// for FreeValue
	IsFreeValue bool

	// Parameter Index
	FormalParameterIndex int
	// contains filtered or unexported fields
}

----------- Parameter

func NewParam added in v1.2.8

func NewParam(variable string, isFreeValue bool, builder *FunctionBuilder) *Parameter

func ToFreeValue added in v1.3.3

func ToFreeValue(n Node) (*Parameter, bool)

func ToParameter added in v1.2.8

func ToParameter(v Instruction) (*Parameter, bool)

func (*Parameter) AddMask added in v1.3.0

func (i *Parameter) AddMask(v Value)

func (*Parameter) AddMember added in v1.3.1

func (n *Parameter) AddMember(k, v Value)

func (*Parameter) AddReference

func (i *Parameter) AddReference(v Value)

func (*Parameter) AddUser

func (n *Parameter) AddUser(u User)

for Value

func (*Parameter) AddVariable added in v1.3.0

func (a *Parameter) AddVariable(v *Variable)

func (*Parameter) Copy added in v1.3.2

func (p *Parameter) Copy() *Parameter

func (*Parameter) DeleteMember added in v1.3.1

func (n *Parameter) DeleteMember(k Value)

func (*Parameter) ForEachMember added in v1.3.3

func (n *Parameter) ForEachMember(fn func(Value, Value) bool)

func (*Parameter) GetAllMember added in v1.3.1

func (n *Parameter) GetAllMember() map[Value]Value

func (*Parameter) GetAllVariables added in v1.3.0

func (a *Parameter) GetAllVariables() map[string]*Variable

func (*Parameter) GetDefault added in v1.3.1

func (p *Parameter) GetDefault() Value

func (*Parameter) GetIndexMember added in v1.3.1

func (n *Parameter) GetIndexMember(i int) (Value, bool)

func (*Parameter) GetKey added in v1.3.1

func (n *Parameter) GetKey() Value

func (*Parameter) GetLastVariable added in v1.3.1

func (a *Parameter) GetLastVariable() *Variable

func (*Parameter) GetMask added in v1.3.0

func (i *Parameter) GetMask() []Value

func (*Parameter) GetMember added in v1.3.1

func (n *Parameter) GetMember(key Value) (Value, bool)

func (*Parameter) GetObject added in v1.3.1

func (n *Parameter) GetObject() Value

func (*Parameter) GetOpcode added in v1.2.8

func (i *Parameter) GetOpcode() Opcode

func (*Parameter) GetStringMember added in v1.3.1

func (n *Parameter) GetStringMember(key string) (Value, bool)

func (*Parameter) GetType

func (n *Parameter) GetType() Type

for Value : type

func (*Parameter) GetUsers

func (n *Parameter) GetUsers() Users

func (*Parameter) GetValues

func (p *Parameter) GetValues() Values

func (*Parameter) GetVariable added in v1.2.8

func (a *Parameter) GetVariable(name string) *Variable

func (*Parameter) HasUsers added in v1.2.8

func (n *Parameter) HasUsers() bool

has/get user and value

func (*Parameter) HasValues added in v1.2.8

func (p *Parameter) HasValues() bool

// ----------- param

func (*Parameter) IsMember added in v1.3.1

func (n *Parameter) IsMember() bool

func (*Parameter) IsObject added in v1.3.1

func (n *Parameter) IsObject() bool

func (*Parameter) Masked added in v1.3.0

func (i *Parameter) Masked() bool

func (*Parameter) Reference

func (i *Parameter) Reference() Values

func (*Parameter) RemoveUser

func (n *Parameter) RemoveUser(u User)

func (*Parameter) SetDefault added in v1.2.8

func (p *Parameter) SetDefault(v Value)

func (*Parameter) SetKey added in v1.3.1

func (n *Parameter) SetKey(k Value)

func (*Parameter) SetObject added in v1.3.1

func (n *Parameter) SetObject(v Value)

func (*Parameter) SetType

func (n *Parameter) SetType(typ Type)

func (*Parameter) String

func (p *Parameter) String() string

type ParameterMember added in v1.3.3

type ParameterMember struct {
	FormalParameterIndex int
	// contains filtered or unexported fields
}

func NewParamMember added in v1.3.3

func NewParamMember(variable string, builder *FunctionBuilder, obj *Parameter, key Value) *ParameterMember

func (*ParameterMember) AddMask added in v1.3.3

func (i *ParameterMember) AddMask(v Value)

func (*ParameterMember) AddMember added in v1.3.3

func (n *ParameterMember) AddMember(k, v Value)

func (*ParameterMember) AddReference

func (i *ParameterMember) AddReference(v Value)

func (*ParameterMember) AddUser added in v1.3.3

func (n *ParameterMember) AddUser(u User)

for Value

func (*ParameterMember) AddVariable added in v1.3.3

func (a *ParameterMember) AddVariable(v *Variable)

func (*ParameterMember) DeleteMember added in v1.3.3

func (n *ParameterMember) DeleteMember(k Value)

func (*ParameterMember) ForEachMember added in v1.3.3

func (n *ParameterMember) ForEachMember(fn func(Value, Value) bool)

func (ParameterMember) Get added in v1.3.3

func (p ParameterMember) Get(c *Call) (obj Value, ok bool)

func (*ParameterMember) GetAllMember added in v1.3.3

func (n *ParameterMember) GetAllMember() map[Value]Value

func (*ParameterMember) GetAllVariables added in v1.3.3

func (a *ParameterMember) GetAllVariables() map[string]*Variable

func (*ParameterMember) GetIndexMember added in v1.3.3

func (n *ParameterMember) GetIndexMember(i int) (Value, bool)

func (*ParameterMember) GetKey added in v1.3.3

func (n *ParameterMember) GetKey() Value

func (*ParameterMember) GetLastVariable added in v1.3.3

func (a *ParameterMember) GetLastVariable() *Variable

func (*ParameterMember) GetMask added in v1.3.3

func (i *ParameterMember) GetMask() []Value

func (*ParameterMember) GetMember added in v1.3.3

func (n *ParameterMember) GetMember(key Value) (Value, bool)

func (*ParameterMember) GetObject added in v1.3.3

func (n *ParameterMember) GetObject() Value

func (*ParameterMember) GetOpcode added in v1.3.3

func (i *ParameterMember) GetOpcode() Opcode

func (*ParameterMember) GetStringMember added in v1.3.3

func (n *ParameterMember) GetStringMember(key string) (Value, bool)

func (*ParameterMember) GetType added in v1.3.3

func (n *ParameterMember) GetType() Type

for Value : type

func (*ParameterMember) GetUsers added in v1.3.3

func (n *ParameterMember) GetUsers() Users

func (*ParameterMember) GetValues added in v1.3.3

func (p *ParameterMember) GetValues() Values

func (*ParameterMember) GetVariable added in v1.3.3

func (a *ParameterMember) GetVariable(name string) *Variable

func (*ParameterMember) HasUsers added in v1.3.3

func (n *ParameterMember) HasUsers() bool

has/get user and value

func (*ParameterMember) HasValues added in v1.3.3

func (p *ParameterMember) HasValues() bool

func (*ParameterMember) IsMember added in v1.3.3

func (n *ParameterMember) IsMember() bool

func (*ParameterMember) IsObject added in v1.3.3

func (n *ParameterMember) IsObject() bool

func (*ParameterMember) Masked added in v1.3.3

func (i *ParameterMember) Masked() bool

func (*ParameterMember) Reference

func (i *ParameterMember) Reference() Values

func (*ParameterMember) RemoveUser added in v1.3.3

func (n *ParameterMember) RemoveUser(u User)

func (*ParameterMember) SetKey added in v1.3.3

func (n *ParameterMember) SetKey(k Value)

func (*ParameterMember) SetObject added in v1.3.3

func (n *ParameterMember) SetObject(v Value)

func (*ParameterMember) SetType added in v1.3.3

func (n *ParameterMember) SetType(typ Type)

func (*ParameterMember) String added in v1.3.3

func (p *ParameterMember) String() string

----------- Parameter

type ParameterMemberCallKind added in v1.3.3

type ParameterMemberCallKind int
const (
	NoMemberCall ParameterMemberCallKind = iota
	ParameterMemberCall
	FreeValueMemberCall
)

type ParentScope added in v1.3.1

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

func (*ParentScope) Create added in v1.3.1

func (p *ParentScope) Create(scope *Scope) *ParentScope

type Phi

type Phi struct {
	Edge []Value // edge[i] from phi.Block.Preds[i]
	// contains filtered or unexported fields
}

----------- Phi

func NewPhi

func NewPhi(block *BasicBlock, variable string) *Phi

func ToPhi added in v1.2.8

func ToPhi(v Instruction) (*Phi, bool)

func (*Phi) AddMask added in v1.3.0

func (i *Phi) AddMask(v Value)

func (*Phi) AddMember added in v1.3.1

func (n *Phi) AddMember(k, v Value)

func (*Phi) AddReference

func (i *Phi) AddReference(v Value)

func (*Phi) AddUser

func (n *Phi) AddUser(u User)

for Value

func (*Phi) AddVariable added in v1.3.0

func (a *Phi) AddVariable(v *Variable)

func (*Phi) DeleteMember added in v1.3.1

func (n *Phi) DeleteMember(k Value)

func (*Phi) ForEachMember added in v1.3.3

func (n *Phi) ForEachMember(fn func(Value, Value) bool)

func (*Phi) GetAllMember added in v1.3.1

func (n *Phi) GetAllMember() map[Value]Value

func (*Phi) GetAllVariables added in v1.3.0

func (a *Phi) GetAllVariables() map[string]*Variable

func (*Phi) GetIndexMember added in v1.3.1

func (n *Phi) GetIndexMember(i int) (Value, bool)

func (*Phi) GetKey added in v1.3.1

func (n *Phi) GetKey() Value

func (*Phi) GetLastVariable added in v1.3.1

func (a *Phi) GetLastVariable() *Variable

func (*Phi) GetMask added in v1.3.0

func (i *Phi) GetMask() []Value

func (*Phi) GetMember added in v1.3.1

func (n *Phi) GetMember(key Value) (Value, bool)

func (*Phi) GetObject added in v1.3.1

func (n *Phi) GetObject() Value

func (*Phi) GetOpcode added in v1.2.8

func (i *Phi) GetOpcode() Opcode

func (*Phi) GetStringMember added in v1.3.1

func (n *Phi) GetStringMember(key string) (Value, bool)

func (*Phi) GetType

func (n *Phi) GetType() Type

for Value : type

func (*Phi) GetUsers

func (n *Phi) GetUsers() Users

func (*Phi) GetValues

func (p *Phi) GetValues() Values

func (*Phi) GetVariable added in v1.2.8

func (a *Phi) GetVariable(name string) *Variable

func (*Phi) HasUsers added in v1.2.8

func (n *Phi) HasUsers() bool

has/get user and value

func (*Phi) HasValues added in v1.2.8

func (p *Phi) HasValues() bool

----------- Phi

func (*Phi) IsMember added in v1.3.1

func (n *Phi) IsMember() bool

func (*Phi) IsObject added in v1.3.1

func (n *Phi) IsObject() bool

func (*Phi) Masked added in v1.3.0

func (i *Phi) Masked() bool

func (*Phi) Reference

func (i *Phi) Reference() Values

func (*Phi) RemoveUser

func (n *Phi) RemoveUser(u User)

func (*Phi) ReplaceValue

func (p *Phi) ReplaceValue(v Value, to Value)

func (*Phi) SetKey added in v1.3.1

func (n *Phi) SetKey(k Value)

func (*Phi) SetObject added in v1.3.1

func (n *Phi) SetObject(v Value)

func (*Phi) SetType

func (n *Phi) SetType(typ Type)

func (*Phi) String

func (p *Phi) String() string

----------- Phi

type Position

type Position struct {
	Editor *memedit.MemEditor
	Line   int64
	Column int64
}

func NewPosition added in v1.3.0

func NewPosition(line, column int64) *Position

func (*Position) Compare added in v1.3.0

func (p *Position) Compare(other *Position) int

func (*Position) GetColumn added in v1.3.3

func (p *Position) GetColumn() int

func (*Position) GetLine added in v1.3.3

func (p *Position) GetLine() int

func (*Position) String

func (p *Position) String() string

type Program

type Program struct {
	// package list
	Name     string
	Packages map[string]*Package

	Cache *Cache

	// offset
	OffsetMap         map[int]*OffsetItem
	OffsetSortedSlice []int

	// package Loader
	Loader *ssautil.PackageLoader
	Build  Build

	ExternInstance map[string]any
	ExternLib      map[string]map[string]any
	// contains filtered or unexported fields
}

both instruction and value

func NewProgram

func NewProgram(dbProgramName string, fs filesys.FileSystem, programPath string) *Program

func NewProgramFromDatabase added in v1.3.3

func NewProgramFromDatabase(db *gorm.DB, program string) *Program

func (*Program) AddError added in v1.3.1

func (prog *Program) AddError(err *SSAError)

func (*Program) AddPackage added in v1.2.8

func (prog *Program) AddPackage(pkg *Package)

func (*Program) BuildValueFromAny added in v1.3.3

func (prog *Program) BuildValueFromAny(b *FunctionBuilder, id string, v any) (value Value)

func (*Program) CoverReflectFunctionType added in v1.3.3

func (prog *Program) CoverReflectFunctionType(itype reflect.Type, level int) *FunctionType

func (*Program) DeleteInstruction added in v1.3.0

func (p *Program) DeleteInstruction(inst Instruction)

func (*Program) EachFunction added in v1.3.0

func (prog *Program) EachFunction(handler func(*Function))

func (*Program) Finish added in v1.3.2

func (prog *Program) Finish()

func (*Program) GetAndCreateFunction added in v1.3.3

func (prog *Program) GetAndCreateFunction(pkgName string, funcName string) *Function

func (*Program) GetAndCreateFunctionBuilder added in v1.3.3

func (prog *Program) GetAndCreateFunctionBuilder(pkgName string, funcName string) *FunctionBuilder

create or get main function builder

func (*Program) GetEditor added in v1.3.3

func (p *Program) GetEditor(url string) (*memedit.MemEditor, bool)

func (*Program) GetErrors

func (prog *Program) GetErrors() SSAErrors

func (*Program) GetFrontValueByOffset added in v1.3.3

func (prog *Program) GetFrontValueByOffset(searchOffset int) (value Value)

func (*Program) GetFunctionFast added in v1.3.0

func (p *Program) GetFunctionFast(paths ...string) *Function

func (*Program) GetIncludeFiles added in v1.3.3

func (p *Program) GetIncludeFiles() []string

func (*Program) GetInstructionById added in v1.3.0

func (p *Program) GetInstructionById(id int64) Instruction

func (*Program) GetPackage added in v1.3.0

func (prog *Program) GetPackage(name string) *Package

func (*Program) GetProgramName added in v1.3.3

func (prog *Program) GetProgramName() string

func (*Program) IsPackagePathInList added in v1.3.3

func (prog *Program) IsPackagePathInList(pkgName string) bool

func (*Program) PopEditor added in v1.3.3

func (p *Program) PopEditor()

func (*Program) PushEditor added in v1.3.3

func (p *Program) PushEditor(e *memedit.MemEditor)

func (*Program) RemoveInstructionInVariable added in v1.3.2

func (p *Program) RemoveInstructionInVariable(name string, i Instruction)

func (*Program) SearchIndexAndOffsetByOffset added in v1.3.3

func (prog *Program) SearchIndexAndOffsetByOffset(searchOffset int) (index int, offset int)

func (*Program) SetInstructionWithName added in v1.3.0

func (p *Program) SetInstructionWithName(name string, i Instruction)

func (*Program) SetOffsetValue added in v1.3.3

func (prog *Program) SetOffsetValue(v Value, r *Range)

func (*Program) SetOffsetVariable added in v1.3.3

func (prog *Program) SetOffsetVariable(v *Variable, r *Range)

func (*Program) SetVirtualRegister added in v1.3.0

func (p *Program) SetVirtualRegister(i Instruction)

set virtual register, and this virtual-register will be instruction-id and set to the instruction

func (*Program) Show

func (p *Program) Show() *Program

func (*Program) ShowOffsetMap added in v1.3.3

func (prog *Program) ShowOffsetMap()

func (*Program) ShowWithSource

func (p *Program) ShowWithSource()

func (*Program) TryBuildExternValue added in v1.3.3

func (prog *Program) TryBuildExternValue(b *FunctionBuilder, id string) Value

func (*Program) TryGetSimilarityKey added in v1.3.3

func (prog *Program) TryGetSimilarityKey(name, key string) string

type Range added in v1.3.0

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

func GetRange added in v1.3.3

func GetRange(editor *memedit.MemEditor, token CanStartStopToken) *Range

func NewRange added in v1.3.0

func NewRange(editor *memedit.MemEditor, startIf, endIf memedit.PositionIf) *Range

func (*Range) Add

func (r *Range) Add(end *Range)

func (*Range) CompareEnd added in v1.3.0

func (p *Range) CompareEnd(other *Range) int

func (*Range) CompareStart added in v1.3.0

func (p *Range) CompareStart(other *Range) int

if ret < 0: p before other if ret == 0: p = other if ret > 0: p after other

func (*Range) GetEditor added in v1.3.3

func (r *Range) GetEditor() *memedit.MemEditor

func (*Range) GetEnd added in v1.3.3

func (r *Range) GetEnd() memedit.PositionIf

func (*Range) GetEndOffset added in v1.3.3

func (r *Range) GetEndOffset() int

func (*Range) GetOffset added in v1.3.3

func (p *Range) GetOffset() int

func (*Range) GetOffsetRange added in v1.3.3

func (r *Range) GetOffsetRange() (int, int)

func (*Range) GetStart added in v1.3.3

func (r *Range) GetStart() memedit.PositionIf

func (*Range) GetText added in v1.3.3

func (p *Range) GetText() string

func (*Range) GetTextContext added in v1.3.3

func (p *Range) GetTextContext(n int) string

func (*Range) GetWordText added in v1.3.3

func (p *Range) GetWordText() string

func (*Range) Len added in v1.3.3

func (r *Range) Len() int

func (*Range) String added in v1.3.0

func (p *Range) String() string

type Recover added in v1.2.8

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

--------------- RECOVER

func (*Recover) AddMask added in v1.3.0

func (i *Recover) AddMask(v Value)

func (*Recover) AddMember added in v1.3.1

func (n *Recover) AddMember(k, v Value)

func (*Recover) AddReference

func (i *Recover) AddReference(v Value)

func (*Recover) AddUser added in v1.2.8

func (n *Recover) AddUser(u User)

for Value

func (*Recover) AddVariable added in v1.3.0

func (a *Recover) AddVariable(v *Variable)

func (*Recover) DeleteMember added in v1.3.1

func (n *Recover) DeleteMember(k Value)

func (*Recover) ForEachMember added in v1.3.3

func (n *Recover) ForEachMember(fn func(Value, Value) bool)

func (*Recover) GetAllMember added in v1.3.1

func (n *Recover) GetAllMember() map[Value]Value

func (*Recover) GetAllVariables added in v1.3.0

func (a *Recover) GetAllVariables() map[string]*Variable

func (*Recover) GetIndexMember added in v1.3.1

func (n *Recover) GetIndexMember(i int) (Value, bool)

func (*Recover) GetKey added in v1.3.1

func (n *Recover) GetKey() Value

func (*Recover) GetLastVariable added in v1.3.1

func (a *Recover) GetLastVariable() *Variable

func (*Recover) GetMask added in v1.3.0

func (i *Recover) GetMask() []Value

func (*Recover) GetMember added in v1.3.1

func (n *Recover) GetMember(key Value) (Value, bool)

func (*Recover) GetObject added in v1.3.1

func (n *Recover) GetObject() Value

func (*Recover) GetOpcode added in v1.2.8

func (i *Recover) GetOpcode() Opcode

func (*Recover) GetStringMember added in v1.3.1

func (n *Recover) GetStringMember(key string) (Value, bool)

func (*Recover) GetType added in v1.2.8

func (n *Recover) GetType() Type

for Value : type

func (*Recover) GetUsers added in v1.2.8

func (n *Recover) GetUsers() Users

func (*Recover) GetValues added in v1.2.8

func (r *Recover) GetValues() Values

func (*Recover) GetVariable added in v1.2.8

func (a *Recover) GetVariable(name string) *Variable

func (*Recover) HasUsers added in v1.2.8

func (n *Recover) HasUsers() bool

has/get user and value

func (*Recover) HasValues added in v1.2.8

func (r *Recover) HasValues() bool

---------- RECOVER

func (*Recover) IsMember added in v1.3.1

func (n *Recover) IsMember() bool

func (*Recover) IsObject added in v1.3.1

func (n *Recover) IsObject() bool

func (*Recover) Masked added in v1.3.0

func (i *Recover) Masked() bool

func (*Recover) Reference

func (i *Recover) Reference() Values

func (*Recover) RemoveUser added in v1.2.8

func (n *Recover) RemoveUser(u User)

func (*Recover) SetKey added in v1.3.1

func (n *Recover) SetKey(k Value)

func (*Recover) SetObject added in v1.3.1

func (n *Recover) SetObject(v Value)

func (*Recover) SetType added in v1.2.8

func (n *Recover) SetType(typ Type)

func (*Recover) String added in v1.2.8

func (r *Recover) String() string

type Return

type Return struct {
	Results []Value
	// contains filtered or unexported fields
}

----------- Return The Return instruction returns values and control back to the calling function.

func NewReturn added in v1.2.8

func NewReturn(vs []Value) *Return

func ToReturn added in v1.3.3

func ToReturn(v Instruction) (*Return, bool)

func (*Return) AddMask added in v1.3.0

func (i *Return) AddMask(v Value)

func (*Return) AddMember added in v1.3.1

func (n *Return) AddMember(k, v Value)

func (*Return) AddReference

func (i *Return) AddReference(v Value)

func (*Return) AddUser added in v1.2.9

func (n *Return) AddUser(u User)

for Value

func (*Return) AddVariable added in v1.3.0

func (a *Return) AddVariable(v *Variable)

func (*Return) DeleteMember added in v1.3.1

func (n *Return) DeleteMember(k Value)

func (*Return) ForEachMember added in v1.3.3

func (n *Return) ForEachMember(fn func(Value, Value) bool)

func (*Return) GetAllMember added in v1.3.1

func (n *Return) GetAllMember() map[Value]Value

func (*Return) GetAllVariables added in v1.3.0

func (a *Return) GetAllVariables() map[string]*Variable

func (*Return) GetIndexMember added in v1.3.1

func (n *Return) GetIndexMember(i int) (Value, bool)

func (*Return) GetKey added in v1.3.1

func (n *Return) GetKey() Value

func (*Return) GetLastVariable added in v1.3.1

func (a *Return) GetLastVariable() *Variable

func (*Return) GetMask added in v1.3.0

func (i *Return) GetMask() []Value

func (*Return) GetMember added in v1.3.1

func (n *Return) GetMember(key Value) (Value, bool)

func (*Return) GetObject added in v1.3.1

func (n *Return) GetObject() Value

func (*Return) GetOpcode added in v1.2.8

func (i *Return) GetOpcode() Opcode

func (*Return) GetStringMember added in v1.3.1

func (n *Return) GetStringMember(key string) (Value, bool)

func (*Return) GetType

func (n *Return) GetType() Type

for Value : type

func (*Return) GetUsers

func (r *Return) GetUsers() Users

func (*Return) GetValues

func (r *Return) GetValues() Values

func (*Return) GetVariable added in v1.2.8

func (a *Return) GetVariable(name string) *Variable

func (*Return) HasUsers added in v1.2.8

func (r *Return) HasUsers() bool

node

func (*Return) HasValues added in v1.2.8

func (r *Return) HasValues() bool

----------- Return

func (*Return) IsMember added in v1.3.1

func (n *Return) IsMember() bool

func (*Return) IsObject added in v1.3.1

func (n *Return) IsObject() bool

func (*Return) Masked added in v1.3.0

func (i *Return) Masked() bool

func (*Return) Reference

func (i *Return) Reference() Values

func (*Return) RemoveUser added in v1.2.9

func (n *Return) RemoveUser(u User)

func (*Return) ReplaceValue

func (r *Return) ReplaceValue(v Value, to Value)

func (*Return) SetKey added in v1.3.1

func (n *Return) SetKey(k Value)

func (*Return) SetObject added in v1.3.1

func (n *Return) SetObject(v Value)

func (*Return) SetType

func (n *Return) SetType(typ Type)

func (*Return) String

func (r *Return) String() string

----------- Return

type SSAError

type SSAError struct {
	Pos     *Range
	Tag     ErrorTag
	Message string
	Kind    ErrorKind
}

func (SSAError) String

func (err SSAError) String() string

type SSAErrors

type SSAErrors []*SSAError

func (SSAErrors) String

func (errs SSAErrors) String() string

type Scope added in v1.3.0

type Scope struct {
	*ssautil.ScopedVersionedTable[Value]
}

func GetScopeFromIrScopeId added in v1.3.3

func GetScopeFromIrScopeId(i int64) *Scope

func NewScope added in v1.3.0

func NewScope(name string) *Scope

func (*Scope) CreateSubScope added in v1.3.1

func (s *Scope) CreateSubScope() ssautil.ScopedVersionedTableIF[Value]

type ScopeIF added in v1.3.1

type SideEffect added in v1.2.9

type SideEffect struct {
	CallSite Value // call instruction
	Value    Value // modify to this value
	// contains filtered or unexported fields
}

----------- SideEffect

func NewSideEffect added in v1.2.9

func NewSideEffect(variable string, call *Call, value Value) *SideEffect

func (*SideEffect) AddMask added in v1.3.0

func (i *SideEffect) AddMask(v Value)

func (*SideEffect) AddMember added in v1.3.1

func (n *SideEffect) AddMember(k, v Value)

func (*SideEffect) AddReference

func (i *SideEffect) AddReference(v Value)

func (*SideEffect) AddUser added in v1.2.9

func (n *SideEffect) AddUser(u User)

for Value

func (*SideEffect) AddVariable added in v1.3.0

func (a *SideEffect) AddVariable(v *Variable)

func (*SideEffect) DeleteMember added in v1.3.1

func (n *SideEffect) DeleteMember(k Value)

func (*SideEffect) ForEachMember added in v1.3.3

func (n *SideEffect) ForEachMember(fn func(Value, Value) bool)

func (*SideEffect) GetAllMember added in v1.3.1

func (n *SideEffect) GetAllMember() map[Value]Value

func (*SideEffect) GetAllVariables added in v1.3.0

func (a *SideEffect) GetAllVariables() map[string]*Variable

func (*SideEffect) GetIndexMember added in v1.3.1

func (n *SideEffect) GetIndexMember(i int) (Value, bool)

func (*SideEffect) GetKey added in v1.3.1

func (n *SideEffect) GetKey() Value

func (*SideEffect) GetLastVariable added in v1.3.1

func (a *SideEffect) GetLastVariable() *Variable

func (*SideEffect) GetMask added in v1.3.0

func (i *SideEffect) GetMask() []Value

func (*SideEffect) GetMember added in v1.3.1

func (n *SideEffect) GetMember(key Value) (Value, bool)

func (*SideEffect) GetObject added in v1.3.1

func (n *SideEffect) GetObject() Value

func (*SideEffect) GetOpcode added in v1.2.9

func (i *SideEffect) GetOpcode() Opcode

func (*SideEffect) GetStringMember added in v1.3.1

func (n *SideEffect) GetStringMember(key string) (Value, bool)

func (*SideEffect) GetType added in v1.2.9

func (n *SideEffect) GetType() Type

for Value : type

func (*SideEffect) GetUsers added in v1.2.9

func (n *SideEffect) GetUsers() Users

func (*SideEffect) GetValues added in v1.2.9

func (s *SideEffect) GetValues() Values

func (*SideEffect) GetVariable added in v1.2.9

func (a *SideEffect) GetVariable(name string) *Variable

func (*SideEffect) HasUsers added in v1.2.9

func (n *SideEffect) HasUsers() bool

has/get user and value

func (*SideEffect) HasValues added in v1.2.9

func (s *SideEffect) HasValues() bool

------------ SideEffect

func (*SideEffect) IsMember added in v1.3.1

func (n *SideEffect) IsMember() bool

func (*SideEffect) IsObject added in v1.3.1

func (n *SideEffect) IsObject() bool

func (*SideEffect) Masked added in v1.3.0

func (i *SideEffect) Masked() bool

func (*SideEffect) Reference

func (i *SideEffect) Reference() Values

func (*SideEffect) RemoveUser added in v1.2.9

func (n *SideEffect) RemoveUser(u User)

func (*SideEffect) ReplaceValue added in v1.2.9

func (s *SideEffect) ReplaceValue(v Value, to Value)

func (*SideEffect) SetKey added in v1.3.1

func (n *SideEffect) SetKey(k Value)

func (*SideEffect) SetObject added in v1.3.1

func (n *SideEffect) SetObject(v Value)

func (*SideEffect) SetType added in v1.2.9

func (n *SideEffect) SetType(typ Type)

func (*SideEffect) String added in v1.2.9

func (s *SideEffect) String() string

type Switch

type Switch struct {
	Cond         Value
	DefaultBlock *BasicBlock

	Label []SwitchLabel
	// contains filtered or unexported fields
}

func NewSwitch added in v1.2.8

func NewSwitch(cond Value, defaultb *BasicBlock, label []SwitchLabel) *Switch

func (*Switch) GetBlock

func (a *Switch) GetBlock() *BasicBlock

func (*Switch) GetFunc added in v1.2.8

func (a *Switch) GetFunc() *Function

func (*Switch) GetId added in v1.3.0

func (a *Switch) GetId() int64

func (*Switch) GetName added in v1.3.0

func (a *Switch) GetName() string

func (*Switch) GetOpcode added in v1.2.8

func (i *Switch) GetOpcode() Opcode

func (*Switch) GetProgram added in v1.3.0

func (a *Switch) GetProgram() *Program

func (*Switch) GetRange added in v1.3.0

func (c *Switch) GetRange() *Range

source code position

func (*Switch) GetShortVerboseName added in v1.3.2

func (i *Switch) GetShortVerboseName() string

func (*Switch) GetSourceCode added in v1.3.3

func (v *Switch) GetSourceCode() string

func (*Switch) GetSourceCodeContext added in v1.3.3

func (v *Switch) GetSourceCodeContext(n int) string

func (*Switch) GetUsers

func (r *Switch) GetUsers() Users

func (*Switch) GetValues

func (sw *Switch) GetValues() Values

func (*Switch) GetVerboseName added in v1.3.1

func (i *Switch) GetVerboseName() string

func (*Switch) HasUsers added in v1.2.8

func (r *Switch) HasUsers() bool

func (*Switch) HasValues added in v1.2.8

func (sw *Switch) HasValues() bool

----------- Switch

func (*Switch) IsExtern added in v1.2.8

func (c *Switch) IsExtern() bool

func (*Switch) IsUndefined added in v1.3.1

func (i *Switch) IsUndefined() bool

func (*Switch) LineDisasm added in v1.2.8

func (a *Switch) LineDisasm() string

func (*Switch) NewError

func (c *Switch) NewError(kind ErrorKind, tag ErrorTag, msg string)

error logger

func (*Switch) ReplaceValue

func (sw *Switch) ReplaceValue(v Value, to Value)

func (*Switch) SelfDelete added in v1.3.1

func (i *Switch) SelfDelete()

func (*Switch) SetBlock added in v1.2.8

func (a *Switch) SetBlock(block *BasicBlock)

func (*Switch) SetExtern added in v1.2.8

func (c *Switch) SetExtern(b bool)

func (*Switch) SetFunc added in v1.2.8

func (a *Switch) SetFunc(f *Function)

ssa function and block

func (*Switch) SetId added in v1.3.0

func (a *Switch) SetId(id int64)

id

func (*Switch) SetName added in v1.3.0

func (a *Switch) SetName(v string)

variable

func (*Switch) SetRange added in v1.3.0

func (c *Switch) SetRange(pos *Range)

func (*Switch) SetVerboseName added in v1.3.1

func (i *Switch) SetVerboseName(verbose string)

func (*Switch) String

func (sw *Switch) String() string

----------- Switch

type SwitchBuilder added in v1.2.8

type SwitchBuilder struct {
	AutoBreak bool
	// contains filtered or unexported fields
}

func (*SwitchBuilder) BuildBody added in v1.2.8

func (t *SwitchBuilder) BuildBody(f func(int))

func (*SwitchBuilder) BuildCaseSize added in v1.3.1

func (sw *SwitchBuilder) BuildCaseSize(size int)

func (*SwitchBuilder) BuildCondition added in v1.2.8

func (t *SwitchBuilder) BuildCondition(f func() Value)

func (*SwitchBuilder) BuildDefault added in v1.2.8

func (t *SwitchBuilder) BuildDefault(f func())

func (*SwitchBuilder) Finish added in v1.2.9

func (t *SwitchBuilder) Finish()

func (*SwitchBuilder) SetCase added in v1.3.1

func (sw *SwitchBuilder) SetCase(f func(int) []Value)

type SwitchLabel

type SwitchLabel struct {
	Value Value
	Dest  *BasicBlock
}

----------- Switch

func NewSwitchLabel

func NewSwitchLabel(v Value, dest *BasicBlock) SwitchLabel

type Token added in v1.3.3

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

func NewToken added in v1.3.3

func NewToken(node antlr.TerminalNode) *Token

func (*Token) GetStart added in v1.3.3

func (t *Token) GetStart() antlr.Token

func (*Token) GetStop added in v1.3.3

func (t *Token) GetStop() antlr.Token

func (*Token) GetText added in v1.3.3

func (t *Token) GetText() string

type TryBuilder added in v1.2.8

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

func (*TryBuilder) BuildCatch added in v1.2.8

func (t *TryBuilder) BuildCatch(f func())

func (*TryBuilder) BuildError added in v1.2.9

func (t *TryBuilder) BuildError(f func() string)

func (*TryBuilder) BuildFinally added in v1.2.8

func (t *TryBuilder) BuildFinally(f func())

func (*TryBuilder) BuildTryBlock added in v1.2.8

func (t *TryBuilder) BuildTryBlock(f func())

func (*TryBuilder) Finish added in v1.2.8

func (t *TryBuilder) Finish()

type Type

type Type interface {
	String() string        // only string
	PkgPathString() string // package path string
	RawString() string     // string contain inner information
	GetTypeKind() TypeKind // type kind

	// set/get method, method is a function
	SetMethod(map[string]*Function)
	AddMethod(string, *Function)
	GetMethod() map[string]*Function
}

func CalculateType added in v1.2.8

func CalculateType(ts []Type) Type

func GetAnyType added in v1.3.0

func GetAnyType() Type

func GetBooleanType added in v1.3.0

func GetBooleanType() Type

func GetBytesType added in v1.3.0

func GetBytesType() Type

func GetErrorType added in v1.3.0

func GetErrorType() Type

func GetNullType added in v1.3.0

func GetNullType() Type

func GetNumberType added in v1.3.0

func GetNumberType() Type

func GetStringType added in v1.3.0

func GetStringType() Type

func GetType

func GetType(i any) Type

func GetTypeByStr

func GetTypeByStr(typ string) Type

func GetTypeFromDB

func GetTypeFromDB(id int) Type

func GetUndefinedType added in v1.3.0

func GetUndefinedType() Type

func ParseClassBluePrint added in v1.3.2

func ParseClassBluePrint(this Value, objectTyp *ObjectType) (ret Type)

ParseClassBluePrint parse get classBluePrint if the ObjectType is a ClassFactor

type TypeCast added in v1.2.8

type TypeCast struct {
	Value Value
	// contains filtered or unexported fields
}

----------- Type-cast cast value -> type

func NewTypeCast added in v1.2.8

func NewTypeCast(typ Type, v Value) *TypeCast

func (*TypeCast) AddMask added in v1.3.0

func (i *TypeCast) AddMask(v Value)

func (*TypeCast) AddMember added in v1.3.1

func (n *TypeCast) AddMember(k, v Value)

func (*TypeCast) AddReference

func (i *TypeCast) AddReference(v Value)

func (*TypeCast) AddUser added in v1.2.8

func (n *TypeCast) AddUser(u User)

for Value

func (*TypeCast) AddVariable added in v1.3.0

func (a *TypeCast) AddVariable(v *Variable)

func (*TypeCast) DeleteMember added in v1.3.1

func (n *TypeCast) DeleteMember(k Value)

func (*TypeCast) ForEachMember added in v1.3.3

func (n *TypeCast) ForEachMember(fn func(Value, Value) bool)

func (*TypeCast) GetAllMember added in v1.3.1

func (n *TypeCast) GetAllMember() map[Value]Value

func (*TypeCast) GetAllVariables added in v1.3.0

func (a *TypeCast) GetAllVariables() map[string]*Variable

func (*TypeCast) GetIndexMember added in v1.3.1

func (n *TypeCast) GetIndexMember(i int) (Value, bool)

func (*TypeCast) GetKey added in v1.3.1

func (n *TypeCast) GetKey() Value

func (*TypeCast) GetLastVariable added in v1.3.1

func (a *TypeCast) GetLastVariable() *Variable

func (*TypeCast) GetMask added in v1.3.0

func (i *TypeCast) GetMask() []Value

func (*TypeCast) GetMember added in v1.3.1

func (n *TypeCast) GetMember(key Value) (Value, bool)

func (*TypeCast) GetObject added in v1.3.1

func (n *TypeCast) GetObject() Value

func (*TypeCast) GetOpcode added in v1.2.8

func (i *TypeCast) GetOpcode() Opcode

func (*TypeCast) GetStringMember added in v1.3.1

func (n *TypeCast) GetStringMember(key string) (Value, bool)

func (*TypeCast) GetType added in v1.2.8

func (n *TypeCast) GetType() Type

for Value : type

func (*TypeCast) GetUsers added in v1.2.8

func (n *TypeCast) GetUsers() Users

func (*TypeCast) GetValues added in v1.2.8

func (t *TypeCast) GetValues() Values

func (*TypeCast) GetVariable added in v1.2.8

func (a *TypeCast) GetVariable(name string) *Variable

func (*TypeCast) HasUsers added in v1.2.8

func (n *TypeCast) HasUsers() bool

has/get user and value

func (*TypeCast) HasValues added in v1.2.8

func (t *TypeCast) HasValues() bool

// ----------- Typecast

func (*TypeCast) IsMember added in v1.3.1

func (n *TypeCast) IsMember() bool

func (*TypeCast) IsObject added in v1.3.1

func (n *TypeCast) IsObject() bool

func (*TypeCast) Masked added in v1.3.0

func (i *TypeCast) Masked() bool

func (*TypeCast) Reference

func (i *TypeCast) Reference() Values

func (*TypeCast) RemoveUser added in v1.2.8

func (n *TypeCast) RemoveUser(u User)

func (*TypeCast) ReplaceValue added in v1.2.8

func (t *TypeCast) ReplaceValue(v, to Value)

func (*TypeCast) SetKey added in v1.3.1

func (n *TypeCast) SetKey(k Value)

func (*TypeCast) SetObject added in v1.3.1

func (n *TypeCast) SetObject(v Value)

func (*TypeCast) SetType added in v1.2.8

func (n *TypeCast) SetType(typ Type)

func (*TypeCast) String added in v1.2.8

func (t *TypeCast) String() string

type TypeKind

type TypeKind int

TypeKind is a Kind of ssa.type

const (
	// NumberTypeKind is all number type, int*/uint*/float/double/complex
	NumberTypeKind TypeKind = iota
	StringTypeKind
	BytesTypeKind
	BooleanTypeKind
	UndefinedTypeKind // undefined is nil in golang
	NullTypeKind      //
	AnyTypeKind       // any type
	ChanTypeKind
	ErrorTypeKind

	ObjectTypeKind
	SliceTypeKind  // slice
	MapTypeKind    // map
	StructTypeKind // struct
	TupleTypeKind  //  slice has fixed length

	InterfaceTypeKind
	FunctionTypeKind

	ClassBluePrintTypeKind
)

type TypeValue added in v1.2.8

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

------------- type value

func NewTypeValue added in v1.2.8

func NewTypeValue(typ Type) *TypeValue

func (*TypeValue) AddMask added in v1.3.0

func (i *TypeValue) AddMask(v Value)

func (*TypeValue) AddMember added in v1.3.1

func (n *TypeValue) AddMember(k, v Value)

func (*TypeValue) AddReference

func (i *TypeValue) AddReference(v Value)

func (*TypeValue) AddUser added in v1.2.8

func (n *TypeValue) AddUser(u User)

for Value

func (*TypeValue) AddVariable added in v1.3.0

func (a *TypeValue) AddVariable(v *Variable)

func (*TypeValue) DeleteMember added in v1.3.1

func (n *TypeValue) DeleteMember(k Value)

func (*TypeValue) ForEachMember added in v1.3.3

func (n *TypeValue) ForEachMember(fn func(Value, Value) bool)

func (*TypeValue) GetAllMember added in v1.3.1

func (n *TypeValue) GetAllMember() map[Value]Value

func (*TypeValue) GetAllVariables added in v1.3.0

func (a *TypeValue) GetAllVariables() map[string]*Variable

func (*TypeValue) GetIndexMember added in v1.3.1

func (n *TypeValue) GetIndexMember(i int) (Value, bool)

func (*TypeValue) GetKey added in v1.3.1

func (n *TypeValue) GetKey() Value

func (*TypeValue) GetLastVariable added in v1.3.1

func (a *TypeValue) GetLastVariable() *Variable

func (*TypeValue) GetMask added in v1.3.0

func (i *TypeValue) GetMask() []Value

func (*TypeValue) GetMember added in v1.3.1

func (n *TypeValue) GetMember(key Value) (Value, bool)

func (*TypeValue) GetObject added in v1.3.1

func (n *TypeValue) GetObject() Value

func (*TypeValue) GetOpcode added in v1.2.8

func (i *TypeValue) GetOpcode() Opcode

func (*TypeValue) GetStringMember added in v1.3.1

func (n *TypeValue) GetStringMember(key string) (Value, bool)

func (*TypeValue) GetType added in v1.2.8

func (n *TypeValue) GetType() Type

for Value : type

func (*TypeValue) GetUsers added in v1.2.8

func (n *TypeValue) GetUsers() Users

func (*TypeValue) GetValues added in v1.2.8

func (t *TypeValue) GetValues() Values

func (*TypeValue) GetVariable added in v1.2.8

func (a *TypeValue) GetVariable(name string) *Variable

func (*TypeValue) HasUsers added in v1.2.8

func (n *TypeValue) HasUsers() bool

has/get user and value

func (*TypeValue) HasValues added in v1.2.8

func (t *TypeValue) HasValues() bool

------------ type value

func (*TypeValue) IsMember added in v1.3.1

func (n *TypeValue) IsMember() bool

func (*TypeValue) IsObject added in v1.3.1

func (n *TypeValue) IsObject() bool

func (*TypeValue) Masked added in v1.3.0

func (i *TypeValue) Masked() bool

func (*TypeValue) Reference

func (i *TypeValue) Reference() Values

func (*TypeValue) RemoveUser added in v1.2.8

func (n *TypeValue) RemoveUser(u User)

func (*TypeValue) SetKey added in v1.3.1

func (n *TypeValue) SetKey(k Value)

func (*TypeValue) SetObject added in v1.3.1

func (n *TypeValue) SetObject(v Value)

func (*TypeValue) SetType added in v1.2.8

func (n *TypeValue) SetType(typ Type)

func (*TypeValue) String added in v1.2.8

func (t *TypeValue) String() string

type Typed added in v1.3.1

type Typed interface {
	// Node
	// type
	GetType() Type
	SetType(Type)
}

type Types

type Types []Type

func (Types) Compare

func (org Types) Compare(typs Types) bool

return true if org != typs return false if org == typs

func (Types) Contains added in v1.2.8

func (t Types) Contains(typ Types) bool

func (Types) Equal added in v1.2.8

func (t Types) Equal(typs Types) bool

func (Types) IsType added in v1.2.8

func (t Types) IsType(kind TypeKind) bool

func (Types) String

func (t Types) String() string

type UnOp

type UnOp struct {
	Op UnaryOpcode
	X  Value
	// contains filtered or unexported fields
}

func NewUnOp added in v1.2.8

func NewUnOp(op UnaryOpcode, x Value) *UnOp

func ToUnOp added in v1.2.8

func ToUnOp(v Instruction) (*UnOp, bool)

func (*UnOp) AddMask added in v1.3.0

func (i *UnOp) AddMask(v Value)

func (*UnOp) AddMember added in v1.3.1

func (n *UnOp) AddMember(k, v Value)

func (*UnOp) AddReference

func (i *UnOp) AddReference(v Value)

func (*UnOp) AddUser added in v1.2.8

func (n *UnOp) AddUser(u User)

for Value

func (*UnOp) AddVariable added in v1.3.0

func (a *UnOp) AddVariable(v *Variable)

func (*UnOp) DeleteMember added in v1.3.1

func (n *UnOp) DeleteMember(k Value)

func (*UnOp) ForEachMember added in v1.3.3

func (n *UnOp) ForEachMember(fn func(Value, Value) bool)

func (*UnOp) GetAllMember added in v1.3.1

func (n *UnOp) GetAllMember() map[Value]Value

func (*UnOp) GetAllVariables added in v1.3.0

func (a *UnOp) GetAllVariables() map[string]*Variable

func (*UnOp) GetIndexMember added in v1.3.1

func (n *UnOp) GetIndexMember(i int) (Value, bool)

func (*UnOp) GetKey added in v1.3.1

func (n *UnOp) GetKey() Value

func (*UnOp) GetLastVariable added in v1.3.1

func (a *UnOp) GetLastVariable() *Variable

func (*UnOp) GetMask added in v1.3.0

func (i *UnOp) GetMask() []Value

func (*UnOp) GetMember added in v1.3.1

func (n *UnOp) GetMember(key Value) (Value, bool)

func (*UnOp) GetObject added in v1.3.1

func (n *UnOp) GetObject() Value

func (*UnOp) GetOpcode added in v1.2.8

func (i *UnOp) GetOpcode() Opcode

func (*UnOp) GetStringMember added in v1.3.1

func (n *UnOp) GetStringMember(key string) (Value, bool)

func (*UnOp) GetType

func (n *UnOp) GetType() Type

for Value : type

func (*UnOp) GetUsers added in v1.2.8

func (n *UnOp) GetUsers() Users

func (*UnOp) GetValues added in v1.2.8

func (n *UnOp) GetValues() Values

func (*UnOp) GetVariable added in v1.2.8

func (a *UnOp) GetVariable(name string) *Variable

func (*UnOp) HasUsers added in v1.2.8

func (n *UnOp) HasUsers() bool

has/get user and value

func (*UnOp) HasValues added in v1.2.8

func (n *UnOp) HasValues() bool

----------- UnOp

func (*UnOp) IsMember added in v1.3.1

func (n *UnOp) IsMember() bool

func (*UnOp) IsObject added in v1.3.1

func (n *UnOp) IsObject() bool

func (*UnOp) Masked added in v1.3.0

func (i *UnOp) Masked() bool

func (*UnOp) Reference

func (i *UnOp) Reference() Values

func (*UnOp) RemoveUser added in v1.2.8

func (n *UnOp) RemoveUser(u User)

func (*UnOp) ReplaceValue added in v1.2.8

func (u *UnOp) ReplaceValue(v Value, to Value)

func (*UnOp) SetKey added in v1.3.1

func (n *UnOp) SetKey(k Value)

func (*UnOp) SetObject added in v1.3.1

func (n *UnOp) SetObject(v Value)

func (*UnOp) SetType

func (n *UnOp) SetType(typ Type)

func (*UnOp) String added in v1.2.8

func (u *UnOp) String() string

----------- UnOp

type UnaryOpcode

type UnaryOpcode string

type Undefined added in v1.2.8

type Undefined struct {
	Kind UndefinedKind
	// contains filtered or unexported fields
}

func NewUndefined added in v1.2.8

func NewUndefined(name string) *Undefined

func ToUndefined added in v1.2.8

func ToUndefined(v Instruction) (*Undefined, bool)

func (*Undefined) AddMask added in v1.3.0

func (i *Undefined) AddMask(v Value)

func (*Undefined) AddMember added in v1.3.1

func (n *Undefined) AddMember(k, v Value)

func (*Undefined) AddReference

func (i *Undefined) AddReference(v Value)

func (*Undefined) AddUser added in v1.2.8

func (n *Undefined) AddUser(u User)

for Value

func (*Undefined) AddVariable added in v1.3.0

func (a *Undefined) AddVariable(v *Variable)

func (*Undefined) DeleteMember added in v1.3.1

func (n *Undefined) DeleteMember(k Value)

func (*Undefined) ForEachMember added in v1.3.3

func (n *Undefined) ForEachMember(fn func(Value, Value) bool)

func (*Undefined) GetAllMember added in v1.3.1

func (n *Undefined) GetAllMember() map[Value]Value

func (*Undefined) GetAllVariables added in v1.3.0

func (a *Undefined) GetAllVariables() map[string]*Variable

func (*Undefined) GetIndexMember added in v1.3.1

func (n *Undefined) GetIndexMember(i int) (Value, bool)

func (*Undefined) GetKey added in v1.3.1

func (n *Undefined) GetKey() Value

func (*Undefined) GetLastVariable added in v1.3.1

func (a *Undefined) GetLastVariable() *Variable

func (*Undefined) GetMask added in v1.3.0

func (i *Undefined) GetMask() []Value

func (*Undefined) GetMember added in v1.3.1

func (n *Undefined) GetMember(key Value) (Value, bool)

func (*Undefined) GetObject added in v1.3.1

func (n *Undefined) GetObject() Value

func (*Undefined) GetOpcode added in v1.2.8

func (i *Undefined) GetOpcode() Opcode

func (*Undefined) GetStringMember added in v1.3.1

func (n *Undefined) GetStringMember(key string) (Value, bool)

func (*Undefined) GetType added in v1.2.8

func (n *Undefined) GetType() Type

for Value : type

func (*Undefined) GetUsers added in v1.2.8

func (n *Undefined) GetUsers() Users

func (*Undefined) GetValues added in v1.2.8

func (u *Undefined) GetValues() Values

func (*Undefined) GetVariable added in v1.2.8

func (a *Undefined) GetVariable(name string) *Variable

func (*Undefined) HasUsers added in v1.2.8

func (n *Undefined) HasUsers() bool

has/get user and value

func (*Undefined) HasValues added in v1.2.8

func (u *Undefined) HasValues() bool

----------- undefined

func (*Undefined) IsMember added in v1.3.1

func (n *Undefined) IsMember() bool

func (*Undefined) IsObject added in v1.3.1

func (n *Undefined) IsObject() bool

func (*Undefined) IsUndefined added in v1.3.1

func (u *Undefined) IsUndefined() bool

func (*Undefined) Masked added in v1.3.0

func (i *Undefined) Masked() bool

func (*Undefined) Reference

func (i *Undefined) Reference() Values

func (*Undefined) RemoveUser added in v1.2.8

func (n *Undefined) RemoveUser(u User)

func (*Undefined) SetKey added in v1.3.1

func (n *Undefined) SetKey(k Value)

func (*Undefined) SetObject added in v1.3.1

func (n *Undefined) SetObject(v Value)

func (*Undefined) SetType added in v1.2.8

func (n *Undefined) SetType(typ Type)

func (*Undefined) String added in v1.2.8

func (u *Undefined) String() string

----------- undefined

type UndefinedKind added in v1.3.1

type UndefinedKind int

UndefinedKind : mark undefined value type

const (
	// UndefinedValueInValid normal undefined value
	UndefinedValueInValid UndefinedKind = iota
	// UndefinedValueValid is variable only declare
	UndefinedValueValid
	// UndefinedMemberInValid member call but not this key
	UndefinedMemberInValid
	// UndefinedMemberValid member call, has this key, but not this value, this shouldn't mark error
	UndefinedMemberValid
)

type User

type User interface {
	Node
	Instruction
	ReplaceValue(Value, Value)
}

func ToUser added in v1.2.8

func ToUser(n Instruction) (User, bool)

type Users added in v1.2.8

type Users []User

func (Users) RunOnCall added in v1.2.8

func (u Users) RunOnCall(f func(*Call))

func (Users) RunOnCallOr added in v1.2.8

func (u Users) RunOnCallOr(f func(*Call), or func(User))

type Value

type Value interface {
	Node
	Instruction
	MemberCall
	Typed
	Maskable
	AssignAble
	AddUser(User)
	RemoveUser(User)

	// reference, this value same as other value
	// in use-def chain, this value use contain other value
	AddReference(Value)
	Reference() Values
}

basic handle item (interface)

func CalcBinary added in v1.2.8

func CalcBinary(b *BinOp) Value

func CalcConstBinarySide added in v1.2.8

func CalcConstBinarySide(c *ConstInst, v Value, op BinaryOpcode) Value

func HandlerBinOp added in v1.2.8

func HandlerBinOp(b *BinOp) (ret Value)

func HandlerUnOp added in v1.2.8

func HandlerUnOp(u *UnOp) (ret Value)

func NewLazyInstruction added in v1.3.3

func NewLazyInstruction(id int64) (Value, error)

NewLazyInstruction : create a new lazy instruction, only create in cache

func ToValue added in v1.2.8

func ToValue(n any) (Value, bool)

type Values added in v1.2.8

type Values []Value

type Variable added in v1.3.0

type Variable struct {
	*ssautil.Versioned[Value]
	DefRange *Range
	UseRange map[*Range]struct{}
	// contains filtered or unexported fields
}

func ReadVariableFromScope added in v1.3.1

func ReadVariableFromScope(scope *Scope, name string) *Variable

func (*Variable) AddRange added in v1.3.0

func (v *Variable) AddRange(r *Range, force bool)

func (*Variable) Assign added in v1.3.1

func (variable *Variable) Assign(value Value) error

func (*Variable) GetMemberCall added in v1.3.1

func (b *Variable) GetMemberCall() (Value, Value)

func (*Variable) GetProgram added in v1.3.3

func (b *Variable) GetProgram() *Program

func (*Variable) IsMemberCall added in v1.3.1

func (b *Variable) IsMemberCall() bool

func (*Variable) NewError added in v1.3.0

func (v *Variable) NewError(kind ErrorKind, tag ErrorTag, msg string)

func (*Variable) SetDefRange added in v1.3.1

func (v *Variable) SetDefRange(r *Range)

func (*Variable) SetMemberCall added in v1.3.1

func (v *Variable) SetMemberCall(obj, key Value)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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