ssa

package
v1.3.0-sp2 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: AGPL-3.0 Imports: 10 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
Update update statement, with type, and optional init block, like a = 1; a = a + 1 will cause the last a is changed

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 (
	OpUnknown Opcode = "unknown"

	OpFunction     = "Function"
	OpBasicBlock   = "BasicBlock"
	OpParameter    = "Parameter"
	OpExternLib    = "ExternLib"
	OpPhi          = "Phi"
	OpConstInst    = "ConstInst"
	OpUndefined    = "Undefined"
	OpBinOp        = "BinOp"
	OpUnOp         = "UnOp"
	OpCall         = "Call"
	OpSideEffect   = "SideEffect"
	OpReturn       = "Return"
	OpMake         = "Make"
	OpField        = "Field"
	OpUpdate       = "Update"
	OpNext         = "Next"
	OpAssert       = "Assert"
	OpTypeCast     = "TypeCast"
	OpTypeValue    = "TypeValue"
	OpErrorHandler = "ErrorHandler"
	OpPanic        = "Panic"
	OpRecover      = "Recover"
	OpJump         = "Jump"
	OpIf           = "If"
	OpLoop         = "Loop"
	OpSwitch       = "Switch"
)
View Source
const (
	// loop
	LoopHeader = "loop.header"
	LoopBody   = "loop.body"
	LoopExit   = "loop.exit"
	LoopLatch  = "loop.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    = ""

	// switch
	SwitchDone    = "switch.done"
	SwitchDefault = "switch.default"
	SwitchHandler = "switch.handler"
)
View Source
const (
	MAXTYPELEVEL = 15
)
View Source
const MAXTypeCompareDepth = 10

Variables

View Source
var (
	ConstMap      = make(map[any]*Const)
	ConstMapMutex = &sync.RWMutex{}
)
View Source
var BasicTypes = []*BasicType{
	Number:        NewBasicType(Number, "number"),
	String:        NewBasicType(String, "string"),
	Bytes:         NewBasicType(Bytes, "bytes"),
	Boolean:       NewBasicType(Boolean, "boolean"),
	UndefinedType: NewBasicType(UndefinedType, "undefined"),
	Null:          NewBasicType(Null, "null"),
	Any:           NewBasicType(Any, "any"),
	ErrorType:     NewBasicType(ErrorType, "error"),
}
View Source
var BinaryOpcodeName = map[BinaryOpcode]string{
	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`,
}
View Source
var UnaryOpcodeName = map[UnaryOpcode]string{
	OpNone:       ``,
	OpNot:        `not`,
	OpPlus:       `plus`,
	OpNeg:        `neg`,
	OpChan:       `chan`,
	OpBitwiseNot: `bitwise-not`,
}

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 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 GetAllKey added in v1.2.9

func GetAllKey(t Type) []string

func GetMethodsName added in v1.2.9

func GetMethodsName(t Type) []string

func GetTypeStr

func GetTypeStr(n Value) string

func InsertValueReplaceOriginal added in v1.2.9

func InsertValueReplaceOriginal(name string, original Value, insert 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

func NewInstruction added in v1.2.8

func NewInstruction() anInstruction

func NewValue added in v1.2.8

func NewValue() anValue

func NoCheckMustInFirst added in v1.2.8

func NoCheckMustInFirst() string

func ReplaceAllValue added in v1.2.9

func ReplaceAllValue(v Value, to Value)

func ReplaceValue

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

func ReplaceValueInSymbolTable added in v1.2.9

func ReplaceValueInSymbolTable(v, to Value)

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 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 TypeCompareEx added in v1.2.9

func TypeCompareEx(t1, t2 Type, depth int) bool

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 *FunctionType)

func (*AliasType) GetMethod added in v1.2.8

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

func (*AliasType) GetTypeKind added in v1.2.8

func (a *AliasType) GetTypeKind() TypeKind

func (*AliasType) PkgPath

func (b *AliasType) PkgPath() 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]*FunctionType)

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) AddMask added in v1.3.0

func (i *Assert) AddMask(v Value)

func (*Assert) AddVariable added in v1.3.0

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

func (*Assert) GetAllVariables added in v1.3.0

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

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() int

func (*Assert) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *Assert) GetOperand(i int) Value

func (*Assert) GetOperandNum added in v1.2.8

func (a *Assert) GetOperandNum() int

func (*Assert) GetOperands added in v1.2.8

func (a *Assert) GetOperands() Values

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) GetScope added in v1.3.0

func (a *Assert) GetScope() *Scope

symbol-table

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) GetVariable added in v1.2.8

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

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) LineDisasm added in v1.2.8

func (a *Assert) LineDisasm() string

func (*Assert) Masked added in v1.3.0

func (i *Assert) Masked() bool

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

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) SetScope added in v1.3.0

func (a *Assert) SetScope(s *Scope)

func (*Assert) String added in v1.2.8

func (a *Assert) String() string

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

	Skip bool // for phi build, avoid recursive
	// contains filtered or unexported fields
}

implement Value

func (*BasicBlock) AddMask added in v1.3.0

func (i *BasicBlock) AddMask(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) EmitInst added in v1.2.8

func (b *BasicBlock) EmitInst(i Instruction)

func (*BasicBlock) GetAllVariables added in v1.3.0

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

func (*BasicBlock) GetBlock added in v1.2.8

func (a *BasicBlock) GetBlock() *BasicBlock

func (*BasicBlock) GetBlockById added in v1.2.8

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

func (*BasicBlock) GetFunc added in v1.2.8

func (a *BasicBlock) GetFunc() *Function

func (*BasicBlock) GetId added in v1.3.0

func (a *BasicBlock) GetId() int

func (*BasicBlock) GetMask added in v1.3.0

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

func (*BasicBlock) GetName added in v1.3.0

func (a *BasicBlock) GetName() string

func (*BasicBlock) GetOpcode added in v1.2.8

func (i *BasicBlock) GetOpcode() Opcode

func (*BasicBlock) GetOperand added in v1.2.8

func (a *BasicBlock) GetOperand(i int) Value

func (*BasicBlock) GetOperandNum added in v1.2.8

func (a *BasicBlock) GetOperandNum() int

func (*BasicBlock) GetOperands added in v1.2.8

func (a *BasicBlock) GetOperands() Values

func (*BasicBlock) GetProgram added in v1.3.0

func (a *BasicBlock) GetProgram() *Program

func (*BasicBlock) GetRange added in v1.3.0

func (c *BasicBlock) GetRange() *Range

source code position

func (*BasicBlock) GetScope added in v1.3.0

func (a *BasicBlock) GetScope() *Scope

symbol-table

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) GetValuesByVariable added in v1.3.0

func (block *BasicBlock) GetValuesByVariable(name string) []Value

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) IsExtern added in v1.2.8

func (c *BasicBlock) IsExtern() bool

func (*BasicBlock) LastInst

func (b *BasicBlock) LastInst() Instruction

func (*BasicBlock) LineDisasm added in v1.2.8

func (a *BasicBlock) LineDisasm() string

func (*BasicBlock) Masked added in v1.3.0

func (i *BasicBlock) Masked() bool

func (*BasicBlock) NewError added in v1.2.8

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

error logger

func (*BasicBlock) Reachable added in v1.2.8

func (b *BasicBlock) Reachable() int

func (*BasicBlock) RemoveUser

func (n *BasicBlock) RemoveUser(u User)

func (*BasicBlock) Sealed

func (b *BasicBlock) Sealed()

func (*BasicBlock) SetBlock added in v1.2.8

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

func (*BasicBlock) SetExtern added in v1.2.8

func (c *BasicBlock) SetExtern(b bool)

func (*BasicBlock) SetFunc added in v1.2.8

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

ssa function and block

func (*BasicBlock) SetId added in v1.3.0

func (a *BasicBlock) SetId(id int)

id

func (*BasicBlock) SetName added in v1.3.0

func (a *BasicBlock) SetName(v string)

variable

func (*BasicBlock) SetRange added in v1.3.0

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

func (*BasicBlock) SetScope added in v1.3.0

func (a *BasicBlock) SetScope(s *Scope)

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 *FunctionType)

func (*BasicType) GetMethod added in v1.2.8

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

func (*BasicType) GetTypeKind added in v1.2.8

func (b *BasicType) GetTypeKind() TypeKind

func (*BasicType) PkgPath

func (b *BasicType) PkgPath() 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]*FunctionType)

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 NewBinOpOnly added in v1.2.8

func NewBinOpOnly(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) 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) GetAllVariables added in v1.3.0

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

func (*BinOp) GetBlock

func (a *BinOp) GetBlock() *BasicBlock

func (*BinOp) GetFunc added in v1.2.8

func (a *BinOp) GetFunc() *Function

func (*BinOp) GetId added in v1.3.0

func (a *BinOp) GetId() int

func (*BinOp) GetMask added in v1.3.0

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

func (*BinOp) GetName added in v1.3.0

func (a *BinOp) GetName() string

func (*BinOp) GetOpcode added in v1.2.8

func (i *BinOp) GetOpcode() Opcode

func (*BinOp) GetOperand added in v1.2.8

func (a *BinOp) GetOperand(i int) Value

func (*BinOp) GetOperandNum added in v1.2.8

func (a *BinOp) GetOperandNum() int

func (*BinOp) GetOperands added in v1.2.8

func (a *BinOp) GetOperands() Values

func (*BinOp) GetProgram added in v1.3.0

func (a *BinOp) GetProgram() *Program

func (*BinOp) GetRange added in v1.3.0

func (c *BinOp) GetRange() *Range

source code position

func (*BinOp) GetScope added in v1.3.0

func (a *BinOp) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *BinOp) IsExtern() bool

func (*BinOp) LineDisasm added in v1.2.8

func (a *BinOp) LineDisasm() string

func (*BinOp) Masked added in v1.3.0

func (i *BinOp) Masked() bool

func (*BinOp) NewError

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

error logger

func (*BinOp) RemoveUser

func (n *BinOp) RemoveUser(u User)

func (*BinOp) ReplaceValue

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

func (*BinOp) SetBlock added in v1.2.8

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

func (*BinOp) SetExtern added in v1.2.8

func (c *BinOp) SetExtern(b bool)

func (*BinOp) SetFunc added in v1.2.8

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

ssa function and block

func (*BinOp) SetId added in v1.3.0

func (a *BinOp) SetId(id int)

id

func (*BinOp) SetName added in v1.3.0

func (a *BinOp) SetName(v string)

variable

func (*BinOp) SetRange added in v1.3.0

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

func (*BinOp) SetScope added in v1.3.0

func (a *BinOp) SetScope(s *Scope)

func (*BinOp) SetType

func (n *BinOp) SetType(typ Type)

func (*BinOp) String

func (b *BinOp) String() string

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

type BinaryOpcode

type BinaryOpcode int
const (
	// Binary
	OpShl BinaryOpcode = iota // <<

	OpLogicAnd // &&
	OpLogicOr  // ||

	OpShr    // >>
	OpAnd    // &
	OpAndNot // &^
	OpOr     // |
	OpXor    // ^
	OpAdd    // +
	OpSub    // -
	OpDiv    // /
	OpMod    // %
	// mul
	OpMul // *

	// boolean opcode
	OpGt    // >
	OpLt    // <
	OpGtEq  // >=
	OpLtEq  // <=
	OpEq    // ==
	OpNotEq // != <>
	OpIn    //  a in b

	OpSend // <-
	OpPow  // **
)

type Call

type Call struct {

	// for call function
	Method Value
	Args   []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, binding []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) 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) GetAllVariables added in v1.3.0

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

func (*Call) GetBlock

func (a *Call) GetBlock() *BasicBlock

func (*Call) GetFunc added in v1.2.8

func (a *Call) GetFunc() *Function

func (*Call) GetId added in v1.3.0

func (a *Call) GetId() int

func (*Call) GetMask added in v1.3.0

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

func (*Call) GetName added in v1.3.0

func (a *Call) GetName() string

func (*Call) GetOpcode added in v1.2.8

func (i *Call) GetOpcode() Opcode

func (*Call) GetOperand added in v1.2.8

func (a *Call) GetOperand(i int) Value

func (*Call) GetOperandNum added in v1.2.8

func (a *Call) GetOperandNum() int

func (*Call) GetOperands added in v1.2.8

func (a *Call) GetOperands() Values

func (*Call) GetProgram added in v1.3.0

func (a *Call) GetProgram() *Program

func (*Call) GetRange added in v1.3.0

func (c *Call) GetRange() *Range

source code position

func (*Call) GetScope added in v1.3.0

func (a *Call) GetScope() *Scope

symbol-table

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 []string, sideEffect []string)

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) IsExtern added in v1.2.8

func (c *Call) IsExtern() bool

func (*Call) LineDisasm added in v1.2.8

func (a *Call) LineDisasm() string

func (*Call) Masked added in v1.3.0

func (i *Call) Masked() bool

func (*Call) NewError

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

error logger

func (*Call) RemoveUser

func (n *Call) RemoveUser(u User)

func (*Call) ReplaceValue

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

func (*Call) SetBlock added in v1.2.8

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

func (*Call) SetExtern added in v1.2.8

func (c *Call) SetExtern(b bool)

func (*Call) SetFunc added in v1.2.8

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

ssa function and block

func (*Call) SetId added in v1.3.0

func (a *Call) SetId(id int)

id

func (*Call) SetName added in v1.3.0

func (a *Call) SetName(v string)

variable

func (*Call) SetRange added in v1.3.0

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

func (*Call) SetScope added in v1.3.0

func (a *Call) SetScope(s *Scope)

func (*Call) SetType

func (n *Call) SetType(typ Type)

func (*Call) String

func (c *Call) String() string

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

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 *FunctionType)

func (*ChanType) GetMethod added in v1.2.8

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

func (*ChanType) GetTypeKind added in v1.2.8

func (c *ChanType) GetTypeKind() TypeKind

func (ChanType) PkgPath

func (c ChanType) PkgPath() 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]*FunctionType)

func (ChanType) String

func (c ChanType) String() string

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 NewConstInst added in v1.2.8

func NewConstInst(c *Const) *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)

value

func (*ConstInst) AddMask added in v1.3.0

func (i *ConstInst) AddMask(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) GetAllVariables added in v1.3.0

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

func (*ConstInst) GetBlock added in v1.2.8

func (a *ConstInst) GetBlock() *BasicBlock

func (*ConstInst) GetFunc added in v1.2.8

func (a *ConstInst) GetFunc() *Function

func (*ConstInst) GetId added in v1.3.0

func (a *ConstInst) GetId() int

func (*ConstInst) GetMask added in v1.3.0

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

func (*ConstInst) GetName added in v1.3.0

func (a *ConstInst) GetName() string

func (*ConstInst) GetOpcode added in v1.2.8

func (i *ConstInst) GetOpcode() Opcode

func (*ConstInst) GetOperand added in v1.2.8

func (a *ConstInst) GetOperand(i int) Value

func (*ConstInst) GetOperandNum added in v1.2.8

func (a *ConstInst) GetOperandNum() int

func (*ConstInst) GetOperands added in v1.2.8

func (a *ConstInst) GetOperands() Values

func (*ConstInst) GetProgram added in v1.3.0

func (a *ConstInst) GetProgram() *Program

func (*ConstInst) GetRange added in v1.3.0

func (c *ConstInst) GetRange() *Range

source code position

func (*ConstInst) GetScope added in v1.3.0

func (a *ConstInst) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *ConstInst) IsExtern() bool

func (*ConstInst) LineDisasm added in v1.2.8

func (a *ConstInst) LineDisasm() string

func (*ConstInst) Masked added in v1.3.0

func (i *ConstInst) Masked() bool

func (*ConstInst) NewError added in v1.2.8

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

error logger

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) SetBlock added in v1.2.8

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

func (*ConstInst) SetExtern added in v1.2.8

func (c *ConstInst) SetExtern(b bool)

func (*ConstInst) SetFunc added in v1.2.8

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

ssa function and block

func (*ConstInst) SetId added in v1.3.0

func (a *ConstInst) SetId(id int)

id

func (*ConstInst) SetName added in v1.3.0

func (a *ConstInst) SetName(v string)

variable

func (*ConstInst) SetRange added in v1.3.0

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

func (*ConstInst) SetScope added in v1.3.0

func (a *ConstInst) SetScope(s *Scope)

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 struct {
	// contains filtered or unexported fields
}
func readSymbolVariable(v Value) string {
	symbolLock.RLock()
	defer symbolLock.RUnlock()
	if name, ok := symbol[v]; ok {
		return name
	} else {
		return ""
	}
}

func NewDisasmLiner added in v1.3.0

func NewDisasmLiner() *DisasmLiner

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) AddMask added in v1.3.0

func (i *ErrorHandler) AddMask(v Value)

func (*ErrorHandler) AddVariable added in v1.3.0

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

func (*ErrorHandler) GetAllVariables added in v1.3.0

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

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() int

func (*ErrorHandler) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *ErrorHandler) GetOperand(i int) Value

func (*ErrorHandler) GetOperandNum added in v1.2.8

func (a *ErrorHandler) GetOperandNum() int

func (*ErrorHandler) GetOperands added in v1.2.8

func (a *ErrorHandler) GetOperands() Values

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) GetScope added in v1.3.0

func (a *ErrorHandler) GetScope() *Scope

symbol-table

func (*ErrorHandler) GetVariable added in v1.2.8

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

func (*ErrorHandler) IsExtern added in v1.2.8

func (c *ErrorHandler) IsExtern() bool

func (*ErrorHandler) LineDisasm added in v1.2.8

func (a *ErrorHandler) LineDisasm() string

func (*ErrorHandler) Masked added in v1.3.0

func (i *ErrorHandler) Masked() bool

func (*ErrorHandler) NewError added in v1.2.8

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

error logger

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

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) SetScope added in v1.3.0

func (a *ErrorHandler) SetScope(s *Scope)

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 {
	BuildField func(string) Value

	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) *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) 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) GetAllVariables added in v1.3.0

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

func (*ExternLib) GetBlock added in v1.3.0

func (a *ExternLib) GetBlock() *BasicBlock

func (*ExternLib) GetFunc added in v1.3.0

func (a *ExternLib) GetFunc() *Function

func (*ExternLib) GetId added in v1.3.0

func (a *ExternLib) GetId() int

func (*ExternLib) GetMask added in v1.3.0

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

func (*ExternLib) GetName added in v1.3.0

func (a *ExternLib) GetName() string

func (*ExternLib) GetOpcode added in v1.3.0

func (i *ExternLib) GetOpcode() Opcode

func (*ExternLib) GetOperand added in v1.3.0

func (a *ExternLib) GetOperand(i int) Value

func (*ExternLib) GetOperandNum added in v1.3.0

func (a *ExternLib) GetOperandNum() int

func (*ExternLib) GetOperands added in v1.3.0

func (a *ExternLib) GetOperands() Values

func (*ExternLib) GetProgram added in v1.3.0

func (a *ExternLib) GetProgram() *Program

func (*ExternLib) GetRange added in v1.3.0

func (c *ExternLib) GetRange() *Range

source code position

func (*ExternLib) GetScope added in v1.3.0

func (a *ExternLib) GetScope() *Scope

symbol-table

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) IsExtern added in v1.3.0

func (c *ExternLib) IsExtern() bool

func (*ExternLib) LineDisasm added in v1.3.0

func (a *ExternLib) LineDisasm() string

func (*ExternLib) Masked added in v1.3.0

func (i *ExternLib) Masked() bool

func (*ExternLib) NewError added in v1.3.0

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

error logger

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) SetBlock added in v1.3.0

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

func (*ExternLib) SetExtern added in v1.3.0

func (c *ExternLib) SetExtern(b bool)

func (*ExternLib) SetFunc added in v1.3.0

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

ssa function and block

func (*ExternLib) SetId added in v1.3.0

func (a *ExternLib) SetId(id int)

id

func (*ExternLib) SetName added in v1.3.0

func (a *ExternLib) SetName(v string)

variable

func (*ExternLib) SetRange added in v1.3.0

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

func (*ExternLib) SetScope added in v1.3.0

func (a *ExternLib) SetScope(s *Scope)

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 Field

type Field struct {

	// field
	Key Value
	Obj Value

	// Method or Field
	IsMethod bool
	// contains filtered or unexported fields
}

instruction ----------- Field

func GetField added in v1.2.8

func GetField(u, key Value) *Field

func GetFields added in v1.2.8

func GetFields(u Node) []*Field

func NewFieldOnly added in v1.2.8

func NewFieldOnly(key, obj Value, block *BasicBlock) *Field

func ToField added in v1.2.8

func ToField(v Instruction) (*Field, bool)

func (*Field) AddMask added in v1.3.0

func (i *Field) AddMask(v Value)

func (*Field) AddUser

func (n *Field) AddUser(u User)

for Value

func (*Field) AddVariable added in v1.3.0

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

func (*Field) Assign

func (field *Field) Assign(v Value, f *FunctionBuilder)

--------------- point variable to value `f.symbol[variable]value` --------------- it's memory address, not SSA value

func (*Field) GetAllVariables added in v1.3.0

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

func (*Field) GetBlock

func (a *Field) GetBlock() *BasicBlock

func (*Field) GetFunc added in v1.2.8

func (a *Field) GetFunc() *Function

func (*Field) GetId added in v1.3.0

func (a *Field) GetId() int

func (*Field) GetMask added in v1.3.0

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

func (*Field) GetName added in v1.3.0

func (a *Field) GetName() string

func (*Field) GetOpcode added in v1.2.8

func (i *Field) GetOpcode() Opcode

func (*Field) GetOperand added in v1.2.8

func (a *Field) GetOperand(i int) Value

func (*Field) GetOperandNum added in v1.2.8

func (a *Field) GetOperandNum() int

func (*Field) GetOperands added in v1.2.8

func (a *Field) GetOperands() Values

func (*Field) GetProgram added in v1.3.0

func (a *Field) GetProgram() *Program

func (*Field) GetRange added in v1.3.0

func (c *Field) GetRange() *Range

source code position

func (*Field) GetScope added in v1.3.0

func (a *Field) GetScope() *Scope

symbol-table

func (*Field) GetType

func (n *Field) GetType() Type

for Value : type

func (*Field) GetUsers

func (n *Field) GetUsers() Users

func (*Field) GetValue

func (f *Field) GetValue(_ *FunctionBuilder) Value

func (*Field) GetValues

func (f *Field) GetValues() Values

func (*Field) GetVariable added in v1.2.8

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

func (*Field) HasUsers added in v1.2.8

func (n *Field) HasUsers() bool

has/get user and value

func (*Field) HasValues added in v1.2.8

func (f *Field) HasValues() bool

// ----------- Field

func (*Field) IsExtern added in v1.2.8

func (c *Field) IsExtern() bool

func (*Field) LineDisasm added in v1.2.8

func (a *Field) LineDisasm() string

func (*Field) Masked added in v1.3.0

func (i *Field) Masked() bool

func (*Field) NewError

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

error logger

func (*Field) RemoveUser

func (n *Field) RemoveUser(u User)

func (*Field) ReplaceValue

func (f *Field) ReplaceValue(v, to Value)

func (*Field) SetBlock added in v1.2.8

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

func (*Field) SetExtern added in v1.2.8

func (c *Field) SetExtern(b bool)

func (*Field) SetFunc added in v1.2.8

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

ssa function and block

func (*Field) SetId added in v1.3.0

func (a *Field) SetId(id int)

id

func (*Field) SetName added in v1.3.0

func (a *Field) SetName(v string)

variable

func (*Field) SetRange added in v1.3.0

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

func (*Field) SetScope added in v1.3.0

func (a *Field) SetScope(s *Scope)

func (*Field) SetType

func (n *Field) SetType(typ Type)

func (*Field) String

func (f *Field) String() string

----------- Field

type Function

type Function struct {

	// package, double link
	Package *Package

	// just function parameter and all return instruction
	Param  []*Parameter
	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

	// for closure function
	FreeValues map[string]*Parameter // store the captured variable form parent-function, just contain name, and type is Parameter
	// closure function side effects
	// TODO: currently, this value is not being used, but it should be utilized in the future.
	SideEffects map[string]Value

	ChildFuncs []*Function // child function within this function
	// contains filtered or unexported fields
}

implement Value

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 Node) (*Function, bool)

func (*Function) AddErrorComment added in v1.2.8

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

func (*Function) AddMask added in v1.3.0

func (i *Function) AddMask(v Value)

func (*Function) AddSideEffect added in v1.2.9

func (f *Function) AddSideEffect(name string, 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) DisAsm

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

func (*Function) EachScope added in v1.3.0

func (f *Function) EachScope(handler func(*Scope))

func (*Function) Finish

func (f *Function) Finish()

current function finish

func (*Function) FirstBlockInstruction added in v1.3.0

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

func (*Function) GetAllSymbols added in v1.2.9

func (f *Function) GetAllSymbols() map[string]Values

func (*Function) GetAllVariables added in v1.3.0

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

func (*Function) GetBlock added in v1.2.8

func (a *Function) GetBlock() *BasicBlock

func (*Function) GetDeferBlock added in v1.2.9

func (f *Function) GetDeferBlock() *BasicBlock

func (*Function) GetFunc added in v1.2.8

func (a *Function) GetFunc() *Function

func (*Function) GetId added in v1.3.0

func (a *Function) GetId() int

func (*Function) GetMask added in v1.3.0

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

func (*Function) GetName added in v1.3.0

func (a *Function) GetName() string

func (*Function) GetOpcode added in v1.2.8

func (i *Function) GetOpcode() Opcode

func (*Function) GetOperand added in v1.2.8

func (a *Function) GetOperand(i int) Value

func (*Function) GetOperandNum added in v1.2.8

func (a *Function) GetOperandNum() int

func (*Function) GetOperands added in v1.2.8

func (a *Function) GetOperands() Values

func (*Function) GetParent

func (f *Function) GetParent() *Function

func (*Function) GetProgram added in v1.3.0

func (f *Function) GetProgram() *Program

func (*Function) GetRange added in v1.3.0

func (c *Function) GetRange() *Range

source code position

func (*Function) GetScope added in v1.3.0

func (a *Function) GetScope() *Scope

symbol-table

func (*Function) GetType

func (n *Function) GetType() Type

for Value : type

func (*Function) GetUsers

func (n *Function) GetUsers() Users

func (*Function) GetValues

func (f *Function) GetValues() Values

func (*Function) GetValuesByName added in v1.2.8

func (f *Function) GetValuesByName(name string) InstructionNodes

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) IsExtern added in v1.2.8

func (c *Function) IsExtern() bool

func (*Function) IsMain added in v1.2.8

func (f *Function) IsMain() bool

func (*Function) LineDisasm added in v1.2.8

func (a *Function) LineDisasm() string

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

func (n *Function) RemoveUser(u User)

func (*Function) ReplaceVariable added in v1.2.8

func (f *Function) ReplaceVariable(variable string, v, to Value)

func (*Function) ReturnValue

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

func (*Function) SetBlock added in v1.2.8

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

func (*Function) SetExtern added in v1.2.8

func (c *Function) SetExtern(b bool)

func (*Function) SetFunc added in v1.2.8

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

ssa function and block

func (*Function) SetId added in v1.3.0

func (a *Function) SetId(id int)

id

func (*Function) SetName added in v1.3.0

func (a *Function) SetName(v string)

variable

func (*Function) SetRange added in v1.3.0

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

func (*Function) SetScope added in v1.3.0

func (a *Function) SetScope(s *Scope)

func (*Function) SetType

func (n *Function) SetType(typ 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

	// for build
	CurrentBlock *BasicBlock // current block to build
	CurrentRange *Range      // current position in source code
	CurrentScope *Scope

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

Function builder API

func NewBuilder

func NewBuilder(f *Function, parent *FunctionBuilder) *FunctionBuilder

func (*FunctionBuilder) AddDefer

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

add current function defer function

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) AddToCmap added in v1.2.8

func (b *FunctionBuilder) AddToCmap(key string)

func (*FunctionBuilder) AddToLmap added in v1.2.8

func (b *FunctionBuilder) AddToLmap(key string)

func (*FunctionBuilder) AddUnsealedBlock added in v1.2.8

func (b *FunctionBuilder) AddUnsealedBlock(block *BasicBlock)

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

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

func (*FunctionBuilder) BuildIf added in v1.2.8

func (b *FunctionBuilder) BuildIf() *IfBuilder

func (*FunctionBuilder) BuildLoop added in v1.2.8

func (b *FunctionBuilder) BuildLoop() *LoopBuilder

func (*FunctionBuilder) BuildSwitch added in v1.2.8

func (b *FunctionBuilder) BuildSwitch() *SwitchBuilder

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

func (b *FunctionBuilder) CanBuildFreeValue(name string) bool

func (*FunctionBuilder) CoverReflectFunctionType added in v1.2.8

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

func (*FunctionBuilder) CreateInterfaceWithVs

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

func (*FunctionBuilder) DeleteLabel added in v1.2.8

func (b *FunctionBuilder) DeleteLabel(name string)

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) EmitConstInstAny added in v1.2.8

func (f *FunctionBuilder) EmitConstInstAny() *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) EmitField

func (f *FunctionBuilder) EmitField(i, key Value) Value

func (*FunctionBuilder) EmitFieldMust added in v1.2.8

func (f *FunctionBuilder) EmitFieldMust(i, key Value) *Field

func (*FunctionBuilder) EmitIf

func (f *FunctionBuilder) EmitIf(cond Value) *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) EmitInterfaceMake added in v1.3.0

func (b *FunctionBuilder) EmitInterfaceMake(f func(feed func(key Value, val Value))) *Make

EmitInterfaceMake quick build key=>value based object

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) 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) EmitRecover added in v1.2.8

func (f *FunctionBuilder) EmitRecover() *Recover

func (*FunctionBuilder) EmitReturn

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

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) EmitUndefine added in v1.2.8

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

func (*FunctionBuilder) EmitUpdate added in v1.2.8

func (f *FunctionBuilder) EmitUpdate(address, v Value) *Update

func (*FunctionBuilder) Finish

func (b *FunctionBuilder) Finish()

finish current function builder

func (FunctionBuilder) GetAllVariables added in v1.3.0

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

func (FunctionBuilder) GetBlock added in v1.2.8

func (a FunctionBuilder) GetBlock() *BasicBlock

func (*FunctionBuilder) GetBreak

func (b *FunctionBuilder) GetBreak() *BasicBlock

func (*FunctionBuilder) GetContinue

func (b *FunctionBuilder) GetContinue() *BasicBlock

func (*FunctionBuilder) GetFallthrough

func (b *FunctionBuilder) GetFallthrough() *BasicBlock

func (*FunctionBuilder) GetFromCmap added in v1.2.8

func (b *FunctionBuilder) GetFromCmap(key string) bool

func (*FunctionBuilder) GetFromLmap added in v1.2.8

func (b *FunctionBuilder) GetFromLmap(key string) bool

func (FunctionBuilder) GetFunc added in v1.2.8

func (a FunctionBuilder) GetFunc() *Function

func (FunctionBuilder) GetId added in v1.3.0

func (a FunctionBuilder) GetId() int

func (*FunctionBuilder) GetLabel added in v1.2.8

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

func (FunctionBuilder) GetMask added in v1.3.0

func (i FunctionBuilder) GetMask() []Value

func (FunctionBuilder) GetName added in v1.3.0

func (a FunctionBuilder) GetName() string

func (FunctionBuilder) GetOperand added in v1.2.8

func (a FunctionBuilder) GetOperand(i int) Value

func (FunctionBuilder) GetOperandNum added in v1.2.8

func (a FunctionBuilder) GetOperandNum() int

func (FunctionBuilder) GetOperands added in v1.2.8

func (a FunctionBuilder) GetOperands() Values

func (FunctionBuilder) GetParentBuilder

func (b FunctionBuilder) GetParentBuilder() *FunctionBuilder

get parent function

func (FunctionBuilder) GetRange added in v1.3.0

func (c FunctionBuilder) GetRange() *Range

source code position

func (FunctionBuilder) GetScope added in v1.3.0

func (a FunctionBuilder) GetScope() *Scope

symbol-table

func (*FunctionBuilder) GetScopeLocalVariable added in v1.3.0

func (b *FunctionBuilder) GetScopeLocalVariable(id string) string

func (FunctionBuilder) GetType added in v1.2.8

func (n FunctionBuilder) GetType() Type

for Value : type

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) IsBlockFinish added in v1.3.0

func (b *FunctionBuilder) IsBlockFinish() bool

current block is finish?

func (FunctionBuilder) IsExtern added in v1.2.8

func (c FunctionBuilder) IsExtern() bool

func (FunctionBuilder) LineDisasm added in v1.3.0

func (a FunctionBuilder) LineDisasm() string

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, *Scope)

new function

func (*FunctionBuilder) NewParam added in v1.3.1

func (f *FunctionBuilder) NewParam(name string) *Parameter

func (*FunctionBuilder) NewScopeId added in v1.3.0

func (b *FunctionBuilder) NewScopeId() int

func (*FunctionBuilder) PeekLexicalVariableByName added in v1.3.0

func (b *FunctionBuilder) PeekLexicalVariableByName(variable string) Value

PeekLexicalVariableByName find the static variable in lexical scope

func (*FunctionBuilder) PeekVariable added in v1.3.0

func (b *FunctionBuilder) PeekVariable(variable string, create bool) Value

PeekVariable just same like `ReadVariable` , but `PeekVariable` don't create `Variable` if your syntax read variable, please use `ReadVariable` if you just want see what Value this variable, just use `PeekVariable`

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, scope *Scope, block *BasicBlock) *FunctionBuilder

function stack

func (*FunctionBuilder) PushTarget

func (b *FunctionBuilder) PushTarget(_break, _continue, _fallthrough *BasicBlock)

target stack

func (*FunctionBuilder) ReadVariable

func (b *FunctionBuilder) ReadVariable(variable string, create bool) Value

* first check builder.currentDef

* if block sealed; just create a phi * if len(block.preds) == 0: undefined * if len(block.preds) == 1: just recursive * if len(block.preds) > 1: create phi and builder

func (*FunctionBuilder) ReadVariableBefore added in v1.2.8

func (b *FunctionBuilder) ReadVariableBefore(variable string, create bool, before Instruction) Value

func (*FunctionBuilder) ReadVariableEx added in v1.2.8

func (b *FunctionBuilder) ReadVariableEx(variable string, create bool, fun func([]Value))

func (FunctionBuilder) RemoveUser added in v1.2.8

func (n FunctionBuilder) RemoveUser(u User)

func (*FunctionBuilder) ScopeEnd added in v1.3.0

func (b *FunctionBuilder) ScopeEnd()

func (*FunctionBuilder) ScopeStart added in v1.3.0

func (b *FunctionBuilder) ScopeStart()

block symbol-table stack

func (FunctionBuilder) SetBlock added in v1.2.8

func (a FunctionBuilder) SetBlock(block *BasicBlock)

func (*FunctionBuilder) SetCurrent added in v1.2.8

func (f *FunctionBuilder) SetCurrent(i Instruction) func()

func (*FunctionBuilder) SetDefineFunc added in v1.3.1

func (b *FunctionBuilder) SetDefineFunc()

func (FunctionBuilder) SetExtern added in v1.2.8

func (c FunctionBuilder) SetExtern(b bool)

func (FunctionBuilder) SetFunc added in v1.2.8

func (a FunctionBuilder) SetFunc(f *Function)

ssa function and block

func (FunctionBuilder) SetId added in v1.3.0

func (a FunctionBuilder) SetId(id int)

id

func (*FunctionBuilder) SetInstructionPosition added in v1.2.9

func (f *FunctionBuilder) SetInstructionPosition(i Instruction)

func (FunctionBuilder) SetName added in v1.3.0

func (a FunctionBuilder) SetName(v string)

variable

func (FunctionBuilder) SetRange added in v1.3.0

func (c FunctionBuilder) SetRange(pos *Range)

func (FunctionBuilder) SetScope added in v1.3.0

func (a FunctionBuilder) SetScope(s *Scope)

func (*FunctionBuilder) SetScopeLocalVariable added in v1.3.0

func (b *FunctionBuilder) SetScopeLocalVariable(text string) string

func (FunctionBuilder) SetType added in v1.2.8

func (n FunctionBuilder) SetType(typ Type)

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)

func (*FunctionBuilder) WriteVariable added in v1.2.8

func (f *FunctionBuilder) WriteVariable(variable string, value Value)

--------------- `f.currentDef` handler, read && write

type FunctionType added in v1.2.8

type FunctionType struct {
	Name string

	ReturnType   Type
	Parameter    Types
	FreeValue    []string
	SideEffects  []string
	IsVariadic   bool
	IsMethod     bool
	IsModifySelf bool // if this is method function
	// contains filtered or unexported fields
}

func GetMethod added in v1.2.9

func GetMethod(t Type, id string) *FunctionType

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) AddMethod added in v1.2.9

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

func (*FunctionType) GetMethod added in v1.2.8

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

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

func (s *FunctionType) PkgPath() 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 []string)

func (*FunctionType) SetMethod added in v1.2.8

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

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 []string)

func (*FunctionType) String added in v1.2.8

func (s *FunctionType) String() string

type IdentifierLV

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

--------------- only point variable to value with `f.currentDef` --------------- is SSA value

func NewIdentifierLV added in v1.2.8

func NewIdentifierLV(variable string, pos *Range) *IdentifierLV

func (*IdentifierLV) Assign

func (i *IdentifierLV) Assign(v Value, f *FunctionBuilder)

func (*IdentifierLV) GetRange added in v1.3.0

func (i *IdentifierLV) GetRange() *Range

func (*IdentifierLV) GetValue

func (i *IdentifierLV) GetValue(f *FunctionBuilder) Value

func (*IdentifierLV) SetIsSideEffect added in v1.2.9

func (i *IdentifierLV) SetIsSideEffect(b bool)

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(cond Value) *If

func (*If) AddFalse

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

func (*If) AddMask added in v1.3.0

func (i *If) AddMask(v Value)

func (*If) AddTrue

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

func (*If) AddVariable added in v1.3.0

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

func (*If) GetAllVariables added in v1.3.0

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

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() int

func (*If) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *If) GetOperand(i int) Value

func (*If) GetOperandNum added in v1.2.8

func (a *If) GetOperandNum() int

func (*If) GetOperands added in v1.2.8

func (a *If) GetOperands() Values

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) GetScope added in v1.3.0

func (a *If) GetScope() *Scope

symbol-table

func (*If) GetUsers

func (r *If) GetUsers() Users

func (*If) GetValues

func (i *If) GetValues() Values

func (*If) GetVariable added in v1.2.8

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

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) LineDisasm added in v1.2.8

func (a *If) LineDisasm() string

func (*If) Masked added in v1.3.0

func (i *If) Masked() bool

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) SetBlock added in v1.2.8

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

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

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) SetScope added in v1.3.0

func (a *If) SetScope(s *Scope)

func (*If) String

func (i *If) String() string

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

type IfBuilder added in v1.2.8

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

func (*IfBuilder) BuildChild added in v1.2.8

func (i *IfBuilder) BuildChild(child *IfBuilder)

func (*IfBuilder) BuildCondition added in v1.2.8

func (i *IfBuilder) BuildCondition(condition func() Value) *IfBuilder

func (*IfBuilder) BuildElif added in v1.2.8

func (i *IfBuilder) BuildElif(condition func() Value, body func()) *IfBuilder

func (*IfBuilder) BuildFalse added in v1.2.8

func (i *IfBuilder) BuildFalse(body func()) *IfBuilder

func (*IfBuilder) BuildTrue added in v1.2.8

func (i *IfBuilder) BuildTrue(body func()) *IfBuilder

func (*IfBuilder) Finish added in v1.2.8

func (i *IfBuilder) Finish()

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)

	GetId() int // for identify
	SetId(int)

	// position
	GetRange() *Range
	SetRange(*Range)

	// Scope
	SetScope(*Scope)
	GetScope() *Scope

	// extern
	IsExtern() bool
	SetExtern(bool)

	GetVariable(string) *Variable
	GetAllVariables() map[string]*Variable
	AddVariable(*Variable)
}

type InstructionNode added in v1.2.8

type InstructionNode interface {
	Node
	Instruction
}

type InstructionNodes added in v1.2.8

type InstructionNodes []InstructionNode

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 *FunctionType)

func (*InterfaceType) GetMethod added in v1.2.8

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

func (*InterfaceType) GetTypeKind added in v1.2.8

func (i *InterfaceType) GetTypeKind() TypeKind

func (*InterfaceType) PkgPath

func (i *InterfaceType) PkgPath() 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]*FunctionType)

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) AddMask added in v1.3.0

func (i *Jump) AddMask(v Value)

func (*Jump) AddVariable added in v1.3.0

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

func (*Jump) GetAllVariables added in v1.3.0

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

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() int

func (*Jump) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *Jump) GetOperand(i int) Value

func (*Jump) GetOperandNum added in v1.2.8

func (a *Jump) GetOperandNum() int

func (*Jump) GetOperands added in v1.2.8

func (a *Jump) GetOperands() Values

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) GetScope added in v1.3.0

func (a *Jump) GetScope() *Scope

symbol-table

func (*Jump) GetVariable added in v1.2.8

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

func (*Jump) IsExtern added in v1.2.8

func (c *Jump) IsExtern() bool

func (*Jump) LineDisasm added in v1.2.8

func (a *Jump) LineDisasm() string

func (*Jump) Masked added in v1.3.0

func (i *Jump) Masked() bool

func (*Jump) NewError

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

error logger

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

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) SetScope added in v1.3.0

func (a *Jump) SetScope(s *Scope)

func (*Jump) String

func (j *Jump) String() string

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

type LeftValue

type LeftValue interface {
	Assign(Value, *FunctionBuilder)
	GetRange() *Range
	GetValue(*FunctionBuilder) Value
}

--------------- for assign

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) AddMask added in v1.3.0

func (i *Loop) AddMask(v Value)

func (*Loop) AddVariable added in v1.3.0

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

func (*Loop) Finish added in v1.2.8

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

func (*Loop) GetAllVariables added in v1.3.0

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

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() int

func (*Loop) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *Loop) GetOperand(i int) Value

func (*Loop) GetOperandNum added in v1.2.8

func (a *Loop) GetOperandNum() int

func (*Loop) GetOperands added in v1.2.8

func (a *Loop) GetOperands() Values

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) GetScope added in v1.3.0

func (a *Loop) GetScope() *Scope

symbol-table

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) GetVariable added in v1.2.8

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

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) LineDisasm added in v1.2.8

func (a *Loop) LineDisasm() string

func (*Loop) Masked added in v1.3.0

func (i *Loop) Masked() bool

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

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) SetScope added in v1.3.0

func (a *Loop) SetScope(s *Scope)

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
}

func (*LoopBuilder) BuildBody added in v1.2.8

func (lb *LoopBuilder) BuildBody(f func())

func (*LoopBuilder) BuildCondition added in v1.2.8

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

func (*LoopBuilder) BuildFirstExpr added in v1.2.8

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

func (*LoopBuilder) BuildThird added in v1.2.8

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

func (*LoopBuilder) Finish added in v1.2.8

func (lb *LoopBuilder) Finish()

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 ToObject added in v1.2.8

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

memory

func (*Make) AddMask added in v1.3.0

func (i *Make) AddMask(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) GetAllVariables added in v1.3.0

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

func (*Make) GetBlock added in v1.2.8

func (a *Make) GetBlock() *BasicBlock

func (*Make) GetFunc added in v1.2.8

func (a *Make) GetFunc() *Function

func (*Make) GetId added in v1.3.0

func (a *Make) GetId() int

func (*Make) GetMask added in v1.3.0

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

func (*Make) GetName added in v1.3.0

func (a *Make) GetName() string

func (*Make) GetOpcode added in v1.2.8

func (i *Make) GetOpcode() Opcode

func (*Make) GetOperand added in v1.2.8

func (a *Make) GetOperand(i int) Value

func (*Make) GetOperandNum added in v1.2.8

func (a *Make) GetOperandNum() int

func (*Make) GetOperands added in v1.2.8

func (a *Make) GetOperands() Values

func (*Make) GetProgram added in v1.3.0

func (a *Make) GetProgram() *Program

func (*Make) GetRange added in v1.3.0

func (c *Make) GetRange() *Range

source code position

func (*Make) GetScope added in v1.3.0

func (a *Make) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Make) IsExtern() bool

func (*Make) LineDisasm added in v1.2.8

func (a *Make) LineDisasm() string

func (*Make) Masked added in v1.3.0

func (i *Make) Masked() bool

func (*Make) NewError added in v1.2.8

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

error logger

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) SetBlock added in v1.2.8

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

func (*Make) SetExtern added in v1.2.8

func (c *Make) SetExtern(b bool)

func (*Make) SetFunc added in v1.2.8

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

ssa function and block

func (*Make) SetId added in v1.3.0

func (a *Make) SetId(id int)

id

func (*Make) SetName added in v1.3.0

func (a *Make) SetName(v string)

variable

func (*Make) SetRange added in v1.3.0

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

func (*Make) SetScope added in v1.3.0

func (a *Make) SetScope(s *Scope)

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 MethodBuilder added in v1.2.9

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

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) 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) GetAllVariables added in v1.3.0

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

func (*Next) GetBlock added in v1.2.8

func (a *Next) GetBlock() *BasicBlock

func (*Next) GetFunc added in v1.2.8

func (a *Next) GetFunc() *Function

func (*Next) GetId added in v1.3.0

func (a *Next) GetId() int

func (*Next) GetMask added in v1.3.0

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

func (*Next) GetName added in v1.3.0

func (a *Next) GetName() string

func (*Next) GetOpcode added in v1.2.8

func (i *Next) GetOpcode() Opcode

func (*Next) GetOperand added in v1.2.8

func (a *Next) GetOperand(i int) Value

func (*Next) GetOperandNum added in v1.2.8

func (a *Next) GetOperandNum() int

func (*Next) GetOperands added in v1.2.8

func (a *Next) GetOperands() Values

func (*Next) GetProgram added in v1.3.0

func (a *Next) GetProgram() *Program

func (*Next) GetRange added in v1.3.0

func (c *Next) GetRange() *Range

source code position

func (*Next) GetScope added in v1.3.0

func (a *Next) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Next) IsExtern() bool

func (*Next) LineDisasm added in v1.2.8

func (a *Next) LineDisasm() string

func (*Next) Masked added in v1.3.0

func (i *Next) Masked() bool

func (*Next) NewError added in v1.2.8

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

error logger

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) SetBlock added in v1.2.8

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

func (*Next) SetExtern added in v1.2.8

func (c *Next) SetExtern(b bool)

func (*Next) SetFunc added in v1.2.8

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

ssa function and block

func (*Next) SetId added in v1.3.0

func (a *Next) SetId(id int)

id

func (*Next) SetName added in v1.3.0

func (a *Next) SetName(v string)

variable

func (*Next) SetRange added in v1.3.0

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

func (*Next) SetScope added in v1.3.0

func (a *Next) SetScope(s *Scope)

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
}

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

var NextType *ObjectType = nil

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 *FunctionType)

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]*FunctionType

func (*ObjectType) GetTypeKind added in v1.2.8

func (i *ObjectType) GetTypeKind() TypeKind

func (ObjectType) PkgPath

func (i ObjectType) PkgPath() 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]*FunctionType)

func (*ObjectType) SetName added in v1.2.8

func (i *ObjectType) SetName(name string)

func (ObjectType) String added in v1.2.8

func (itype ObjectType) String() string

type Opcode added in v1.2.8

type Opcode string

type Package

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

func NewPackage added in v1.2.8

func NewPackage(name string) *Package

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) 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) GetAllVariables added in v1.3.0

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

func (*Panic) GetBlock added in v1.2.8

func (a *Panic) GetBlock() *BasicBlock

func (*Panic) GetFunc added in v1.2.8

func (a *Panic) GetFunc() *Function

func (*Panic) GetId added in v1.3.0

func (a *Panic) GetId() int

func (*Panic) GetMask added in v1.3.0

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

func (*Panic) GetName added in v1.3.0

func (a *Panic) GetName() string

func (*Panic) GetOpcode added in v1.2.8

func (i *Panic) GetOpcode() Opcode

func (*Panic) GetOperand added in v1.2.8

func (a *Panic) GetOperand(i int) Value

func (*Panic) GetOperandNum added in v1.2.8

func (a *Panic) GetOperandNum() int

func (*Panic) GetOperands added in v1.2.8

func (a *Panic) GetOperands() Values

func (*Panic) GetProgram added in v1.3.0

func (a *Panic) GetProgram() *Program

func (*Panic) GetRange added in v1.3.0

func (c *Panic) GetRange() *Range

source code position

func (*Panic) GetScope added in v1.3.0

func (a *Panic) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Panic) IsExtern() bool

func (*Panic) LineDisasm added in v1.2.8

func (a *Panic) LineDisasm() string

func (*Panic) Masked added in v1.3.0

func (i *Panic) Masked() bool

func (*Panic) NewError added in v1.2.8

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

error logger

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) SetBlock added in v1.2.8

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

func (*Panic) SetExtern added in v1.2.8

func (c *Panic) SetExtern(b bool)

func (*Panic) SetFunc added in v1.2.8

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

ssa function and block

func (*Panic) SetId added in v1.3.0

func (a *Panic) SetId(id int)

id

func (*Panic) SetName added in v1.3.0

func (a *Panic) SetName(v string)

variable

func (*Panic) SetRange added in v1.3.0

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

func (*Panic) SetScope added in v1.3.0

func (a *Panic) SetScope(s *Scope)

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 {
	IsFreeValue bool

	Function                *Function
	FormalParameterIndex    int
	FormalParameterName     string
	FormalParameterVariadic bool
	// contains filtered or unexported fields
}

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

func NewParam added in v1.2.8

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

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) 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) GetAllVariables added in v1.3.0

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

func (*Parameter) GetBlock added in v1.2.8

func (a *Parameter) GetBlock() *BasicBlock

func (*Parameter) GetFunc added in v1.2.8

func (a *Parameter) GetFunc() *Function

func (*Parameter) GetId added in v1.3.0

func (a *Parameter) GetId() int

func (*Parameter) GetMask added in v1.3.0

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

func (*Parameter) GetName added in v1.3.0

func (a *Parameter) GetName() string

func (*Parameter) GetOpcode added in v1.2.8

func (i *Parameter) GetOpcode() Opcode

func (*Parameter) GetOperand added in v1.2.8

func (a *Parameter) GetOperand(i int) Value

func (*Parameter) GetOperandNum added in v1.2.8

func (a *Parameter) GetOperandNum() int

func (*Parameter) GetOperands added in v1.2.8

func (a *Parameter) GetOperands() Values

func (*Parameter) GetProgram added in v1.3.0

func (a *Parameter) GetProgram() *Program

func (*Parameter) GetRange added in v1.3.0

func (c *Parameter) GetRange() *Range

source code position

func (*Parameter) GetScope added in v1.3.0

func (a *Parameter) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Parameter) IsExtern() bool

func (*Parameter) LineDisasm added in v1.2.8

func (a *Parameter) LineDisasm() string

func (*Parameter) Masked added in v1.3.0

func (i *Parameter) Masked() bool

func (*Parameter) NewError added in v1.2.8

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

error logger

func (*Parameter) RemoveUser

func (n *Parameter) RemoveUser(u User)

func (*Parameter) SetBlock added in v1.2.8

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

func (*Parameter) SetDefault added in v1.2.8

func (p *Parameter) SetDefault(v Value)

func (*Parameter) SetExtern added in v1.2.8

func (c *Parameter) SetExtern(b bool)

func (*Parameter) SetFunc added in v1.2.8

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

ssa function and block

func (*Parameter) SetId added in v1.3.0

func (a *Parameter) SetId(id int)

id

func (*Parameter) SetName added in v1.3.0

func (a *Parameter) SetName(v string)

variable

func (*Parameter) SetRange added in v1.3.0

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

func (*Parameter) SetScope added in v1.3.0

func (a *Parameter) SetScope(s *Scope)

func (*Parameter) SetType

func (n *Parameter) SetType(typ Type)

func (*Parameter) String

func (p *Parameter) String() string

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

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, create bool) *Phi

func ToPhi added in v1.2.8

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

func (*Phi) AddEdge added in v1.2.8

func (p *Phi) AddEdge(v Value)

func (*Phi) AddMask added in v1.3.0

func (i *Phi) AddMask(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) Build

func (phi *Phi) Build() Value

func (*Phi) GetAllVariables added in v1.3.0

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

func (*Phi) GetBlock

func (a *Phi) GetBlock() *BasicBlock

func (*Phi) GetFunc added in v1.2.8

func (a *Phi) GetFunc() *Function

func (*Phi) GetId added in v1.3.0

func (a *Phi) GetId() int

func (*Phi) GetMask added in v1.3.0

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

func (*Phi) GetName added in v1.3.0

func (a *Phi) GetName() string

func (*Phi) GetOpcode added in v1.2.8

func (i *Phi) GetOpcode() Opcode

func (*Phi) GetOperand added in v1.2.8

func (a *Phi) GetOperand(i int) Value

func (*Phi) GetOperandNum added in v1.2.8

func (a *Phi) GetOperandNum() int

func (*Phi) GetOperands added in v1.2.8

func (a *Phi) GetOperands() Values

func (*Phi) GetProgram added in v1.3.0

func (a *Phi) GetProgram() *Program

func (*Phi) GetRange added in v1.3.0

func (c *Phi) GetRange() *Range

source code position

func (*Phi) GetScope added in v1.3.0

func (a *Phi) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Phi) IsExtern() bool

func (*Phi) LineDisasm added in v1.2.8

func (a *Phi) LineDisasm() string

func (*Phi) Masked added in v1.3.0

func (i *Phi) Masked() bool

func (*Phi) Name

func (phi *Phi) Name() string

func (*Phi) NewError

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

error logger

func (*Phi) RemoveUser

func (n *Phi) RemoveUser(u User)

func (*Phi) Replace added in v1.2.8

func (phi *Phi) Replace(to Value)

func (*Phi) ReplaceValue

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

func (*Phi) SetBlock added in v1.2.8

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

func (*Phi) SetExtern added in v1.2.8

func (c *Phi) SetExtern(b bool)

func (*Phi) SetFunc added in v1.2.8

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

ssa function and block

func (*Phi) SetId added in v1.3.0

func (a *Phi) SetId(id int)

id

func (*Phi) SetName added in v1.3.0

func (a *Phi) SetName(v string)

variable

func (*Phi) SetRange added in v1.3.0

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

func (*Phi) SetScope added in v1.3.0

func (a *Phi) SetScope(s *Scope)

func (*Phi) SetType

func (n *Phi) SetType(typ Type)

func (*Phi) String

func (p *Phi) String() string

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

type Position

type Position struct {
	Offset int64
	Line   int64
	Column int64
}

func NewPosition added in v1.3.0

func NewPosition(offset, line, column int64) *Position

func (*Position) Compare added in v1.3.0

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

func (*Position) String

func (p *Position) String() string

type Program

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

	ConstInstruction   *omap.OrderedMap[int, *ConstInst]
	NameToInstructions *omap.OrderedMap[string, []Instruction]
	IdToInstructionMap *omap.OrderedMap[int, Instruction]
	// contains filtered or unexported fields
}

both instruction and value

func NewProgram

func NewProgram() *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) DeleteInstruction added in v1.3.0

func (p *Program) DeleteInstruction(i Instruction)

func (*Program) EachFunction added in v1.3.0

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

func (*Program) GetAndCreateMainFunction added in v1.3.0

func (prog *Program) GetAndCreateMainFunction() *Function

func (*Program) GetAndCreateMainFunctionBuilder added in v1.3.0

func (prog *Program) GetAndCreateMainFunctionBuilder() *FunctionBuilder

create or get main function builder

func (*Program) GetErrors

func (prog *Program) GetErrors() SSAErrors

func (*Program) GetFunctionFast added in v1.3.0

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

func (*Program) GetInstructionById added in v1.3.0

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

func (*Program) GetInstructionsByName added in v1.3.0

func (p *Program) GetInstructionsByName(name string) []Instruction

func (*Program) GetPackage added in v1.3.0

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

func (*Program) RemoveInstructionWithName added in v1.3.1

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

func (*Program) SetInstructionWithName added in v1.3.0

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

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

func (p *Program) ShowWithSource()

type Range added in v1.3.0

type Range struct {
	SourceCode *string
	Start, End *Position
}

func NewRange added in v1.3.0

func NewRange(start, end *Position, source string) *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) 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) 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) GetAllVariables added in v1.3.0

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

func (*Recover) GetBlock added in v1.2.8

func (a *Recover) GetBlock() *BasicBlock

func (*Recover) GetFunc added in v1.2.8

func (a *Recover) GetFunc() *Function

func (*Recover) GetId added in v1.3.0

func (a *Recover) GetId() int

func (*Recover) GetMask added in v1.3.0

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

func (*Recover) GetName added in v1.3.0

func (a *Recover) GetName() string

func (*Recover) GetOpcode added in v1.2.8

func (i *Recover) GetOpcode() Opcode

func (*Recover) GetOperand added in v1.2.8

func (a *Recover) GetOperand(i int) Value

func (*Recover) GetOperandNum added in v1.2.8

func (a *Recover) GetOperandNum() int

func (*Recover) GetOperands added in v1.2.8

func (a *Recover) GetOperands() Values

func (*Recover) GetProgram added in v1.3.0

func (a *Recover) GetProgram() *Program

func (*Recover) GetRange added in v1.3.0

func (c *Recover) GetRange() *Range

source code position

func (*Recover) GetScope added in v1.3.0

func (a *Recover) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Recover) IsExtern() bool

func (*Recover) LineDisasm added in v1.2.8

func (a *Recover) LineDisasm() string

func (*Recover) Masked added in v1.3.0

func (i *Recover) Masked() bool

func (*Recover) NewError added in v1.2.8

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

error logger

func (*Recover) RemoveUser added in v1.2.8

func (n *Recover) RemoveUser(u User)

func (*Recover) SetBlock added in v1.2.8

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

func (*Recover) SetExtern added in v1.2.8

func (c *Recover) SetExtern(b bool)

func (*Recover) SetFunc added in v1.2.8

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

ssa function and block

func (*Recover) SetId added in v1.3.0

func (a *Recover) SetId(id int)

id

func (*Recover) SetName added in v1.3.0

func (a *Recover) SetName(v string)

variable

func (*Recover) SetRange added in v1.3.0

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

func (*Recover) SetScope added in v1.3.0

func (a *Recover) SetScope(s *Scope)

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 (*Return) AddMask added in v1.3.0

func (i *Return) AddMask(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) GetAllVariables added in v1.3.0

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

func (*Return) GetBlock

func (a *Return) GetBlock() *BasicBlock

func (*Return) GetFunc added in v1.2.8

func (a *Return) GetFunc() *Function

func (*Return) GetId added in v1.3.0

func (a *Return) GetId() int

func (*Return) GetMask added in v1.3.0

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

func (*Return) GetName added in v1.3.0

func (a *Return) GetName() string

func (*Return) GetOpcode added in v1.2.8

func (i *Return) GetOpcode() Opcode

func (*Return) GetOperand added in v1.2.8

func (a *Return) GetOperand(i int) Value

func (*Return) GetOperandNum added in v1.2.8

func (a *Return) GetOperandNum() int

func (*Return) GetOperands added in v1.2.8

func (a *Return) GetOperands() Values

func (*Return) GetProgram added in v1.3.0

func (a *Return) GetProgram() *Program

func (*Return) GetRange added in v1.3.0

func (c *Return) GetRange() *Range

source code position

func (*Return) GetScope added in v1.3.0

func (a *Return) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Return) IsExtern() bool

func (*Return) LineDisasm added in v1.2.8

func (a *Return) LineDisasm() string

func (*Return) Masked added in v1.3.0

func (i *Return) Masked() bool

func (*Return) NewError

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

error logger

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) SetBlock added in v1.2.8

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

func (*Return) SetExtern added in v1.2.8

func (c *Return) SetExtern(b bool)

func (*Return) SetFunc added in v1.2.8

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

ssa function and block

func (*Return) SetId added in v1.3.0

func (a *Return) SetId(id int)

id

func (*Return) SetName added in v1.3.0

func (a *Return) SetName(v string)

variable

func (*Return) SetRange added in v1.3.0

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

func (*Return) SetScope added in v1.3.0

func (a *Return) SetScope(s *Scope)

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 {
	Id                 int // scope id in a function
	VarMap             map[string][]*Variable
	Var                []item            // sort by Position
	SymbolTable        map[string]string // variable -> variable-ID(variable-scopeID)
	SymbolTableReverse map[string]string // variable -> variable-ID(variable-scopeID)
	Range              *Range
	Function           *Function
	Parent             *Scope
	Children           []*Scope
}

func NewScope added in v1.3.0

func NewScope(id int, R *Range, Func *Function) *Scope

func (*Scope) AddChild added in v1.3.0

func (s *Scope) AddChild(child *Scope)

func (*Scope) AddVariable added in v1.3.0

func (s *Scope) AddVariable(v *Variable, R *Range)

func (*Scope) GetLocalVariable added in v1.3.0

func (s *Scope) GetLocalVariable(text string) string

func (*Scope) InsertByRange added in v1.3.0

func (s *Scope) InsertByRange(v *Variable, R *Range)

func (*Scope) PeekLexicalVariableByName added in v1.3.0

func (s *Scope) PeekLexicalVariableByName(i string) (*Variable, error)

func (*Scope) SetLocalVariable added in v1.3.0

func (s *Scope) SetLocalVariable(text string) string

func (*Scope) String added in v1.3.0

func (s *Scope) String() string

type SideEffect added in v1.2.9

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

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

func NewSideEffect added in v1.2.9

func NewSideEffect(variable string, target Value) *SideEffect

func (*SideEffect) AddMask added in v1.3.0

func (i *SideEffect) AddMask(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) GetAllVariables added in v1.3.0

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

func (*SideEffect) GetBlock added in v1.2.9

func (a *SideEffect) GetBlock() *BasicBlock

func (*SideEffect) GetFunc added in v1.2.9

func (a *SideEffect) GetFunc() *Function

func (*SideEffect) GetId added in v1.3.0

func (a *SideEffect) GetId() int

func (*SideEffect) GetMask added in v1.3.0

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

func (*SideEffect) GetName added in v1.3.0

func (a *SideEffect) GetName() string

func (*SideEffect) GetOpcode added in v1.2.9

func (i *SideEffect) GetOpcode() Opcode

func (*SideEffect) GetOperand added in v1.2.9

func (a *SideEffect) GetOperand(i int) Value

func (*SideEffect) GetOperandNum added in v1.2.9

func (a *SideEffect) GetOperandNum() int

func (*SideEffect) GetOperands added in v1.2.9

func (a *SideEffect) GetOperands() Values

func (*SideEffect) GetProgram added in v1.3.0

func (a *SideEffect) GetProgram() *Program

func (*SideEffect) GetRange added in v1.3.0

func (c *SideEffect) GetRange() *Range

source code position

func (*SideEffect) GetScope added in v1.3.0

func (a *SideEffect) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.9

func (c *SideEffect) IsExtern() bool

func (*SideEffect) LineDisasm added in v1.2.9

func (a *SideEffect) LineDisasm() string

func (*SideEffect) Masked added in v1.3.0

func (i *SideEffect) Masked() bool

func (*SideEffect) NewError added in v1.2.9

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

error logger

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) SetBlock added in v1.2.9

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

func (*SideEffect) SetExtern added in v1.2.9

func (c *SideEffect) SetExtern(b bool)

func (*SideEffect) SetFunc added in v1.2.9

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

ssa function and block

func (*SideEffect) SetId added in v1.3.0

func (a *SideEffect) SetId(id int)

id

func (*SideEffect) SetName added in v1.3.0

func (a *SideEffect) SetName(v string)

variable

func (*SideEffect) SetRange added in v1.3.0

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

func (*SideEffect) SetScope added in v1.3.0

func (a *SideEffect) SetScope(s *Scope)

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) AddMask added in v1.3.0

func (i *Switch) AddMask(v Value)

func (*Switch) AddVariable added in v1.3.0

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

func (*Switch) GetAllVariables added in v1.3.0

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

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() int

func (*Switch) GetMask added in v1.3.0

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

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) GetOperand added in v1.2.8

func (a *Switch) GetOperand(i int) Value

func (*Switch) GetOperandNum added in v1.2.8

func (a *Switch) GetOperandNum() int

func (*Switch) GetOperands added in v1.2.8

func (a *Switch) GetOperands() Values

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) GetScope added in v1.3.0

func (a *Switch) GetScope() *Scope

symbol-table

func (*Switch) GetUsers

func (r *Switch) GetUsers() Users

func (*Switch) GetValues

func (sw *Switch) GetValues() Values

func (*Switch) GetVariable added in v1.2.8

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

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) LineDisasm added in v1.2.8

func (a *Switch) LineDisasm() string

func (*Switch) Masked added in v1.3.0

func (i *Switch) Masked() bool

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

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) SetScope added in v1.3.0

func (a *Switch) SetScope(s *Scope)

func (*Switch) String

func (sw *Switch) String() string

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

type SwitchBuilder added in v1.2.8

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

func (*SwitchBuilder) BuildBody added in v1.2.8

func (t *SwitchBuilder) BuildBody(f func(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) BuildHandler added in v1.2.9

func (t *SwitchBuilder) BuildHandler(f func() (int, []Value))

func (*SwitchBuilder) Finish added in v1.2.9

func (t *SwitchBuilder) Finish()

type SwitchLabel

type SwitchLabel struct {
	Value Value
	Dest  *BasicBlock
}

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

func NewSwitchLabel

func NewSwitchLabel(v Value, dest *BasicBlock) SwitchLabel

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
	PkgPath() string // package path string
	RawString() string
	GetTypeKind() TypeKind

	// set/get method
	SetMethod(map[string]*FunctionType)
	AddMethod(string, *FunctionType)
	GetMethod() map[string]*FunctionType
}

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 GetUndefinedType added in v1.3.0

func GetUndefinedType() Type

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) 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) GetAllVariables added in v1.3.0

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

func (*TypeCast) GetBlock added in v1.2.8

func (a *TypeCast) GetBlock() *BasicBlock

func (*TypeCast) GetFunc added in v1.2.8

func (a *TypeCast) GetFunc() *Function

func (*TypeCast) GetId added in v1.3.0

func (a *TypeCast) GetId() int

func (*TypeCast) GetMask added in v1.3.0

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

func (*TypeCast) GetName added in v1.3.0

func (a *TypeCast) GetName() string

func (*TypeCast) GetOpcode added in v1.2.8

func (i *TypeCast) GetOpcode() Opcode

func (*TypeCast) GetOperand added in v1.2.8

func (a *TypeCast) GetOperand(i int) Value

func (*TypeCast) GetOperandNum added in v1.2.8

func (a *TypeCast) GetOperandNum() int

func (*TypeCast) GetOperands added in v1.2.8

func (a *TypeCast) GetOperands() Values

func (*TypeCast) GetProgram added in v1.3.0

func (a *TypeCast) GetProgram() *Program

func (*TypeCast) GetRange added in v1.3.0

func (c *TypeCast) GetRange() *Range

source code position

func (*TypeCast) GetScope added in v1.3.0

func (a *TypeCast) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *TypeCast) IsExtern() bool

func (*TypeCast) LineDisasm added in v1.2.8

func (a *TypeCast) LineDisasm() string

func (*TypeCast) Masked added in v1.3.0

func (i *TypeCast) Masked() bool

func (*TypeCast) NewError added in v1.2.8

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

error logger

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) SetBlock added in v1.2.8

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

func (*TypeCast) SetExtern added in v1.2.8

func (c *TypeCast) SetExtern(b bool)

func (*TypeCast) SetFunc added in v1.2.8

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

ssa function and block

func (*TypeCast) SetId added in v1.3.0

func (a *TypeCast) SetId(id int)

id

func (*TypeCast) SetName added in v1.3.0

func (a *TypeCast) SetName(v string)

variable

func (*TypeCast) SetRange added in v1.3.0

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

func (*TypeCast) SetScope added in v1.3.0

func (a *TypeCast) SetScope(s *Scope)

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

basic type

const (
	Number TypeKind = iota
	String
	Bytes
	Boolean
	UndefinedType // undefined is nil in golang
	Null          //
	Any           // any type
	ChanTypeKind
	ErrorType

	ObjectTypeKind
	SliceTypeKind
	MapTypeKind
	StructTypeKind

	InterfaceTypeKind
	FunctionTypeKind
)

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) 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) GetAllVariables added in v1.3.0

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

func (*TypeValue) GetBlock added in v1.2.8

func (a *TypeValue) GetBlock() *BasicBlock

func (*TypeValue) GetFunc added in v1.2.8

func (a *TypeValue) GetFunc() *Function

func (*TypeValue) GetId added in v1.3.0

func (a *TypeValue) GetId() int

func (*TypeValue) GetMask added in v1.3.0

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

func (*TypeValue) GetName added in v1.3.0

func (a *TypeValue) GetName() string

func (*TypeValue) GetOpcode added in v1.2.8

func (i *TypeValue) GetOpcode() Opcode

func (*TypeValue) GetOperand added in v1.2.8

func (a *TypeValue) GetOperand(i int) Value

func (*TypeValue) GetOperandNum added in v1.2.8

func (a *TypeValue) GetOperandNum() int

func (*TypeValue) GetOperands added in v1.2.8

func (a *TypeValue) GetOperands() Values

func (*TypeValue) GetProgram added in v1.3.0

func (a *TypeValue) GetProgram() *Program

func (*TypeValue) GetRange added in v1.3.0

func (c *TypeValue) GetRange() *Range

source code position

func (*TypeValue) GetScope added in v1.3.0

func (a *TypeValue) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *TypeValue) IsExtern() bool

func (*TypeValue) LineDisasm added in v1.2.8

func (a *TypeValue) LineDisasm() string

func (*TypeValue) Masked added in v1.3.0

func (i *TypeValue) Masked() bool

func (*TypeValue) NewError added in v1.2.8

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

error logger

func (*TypeValue) RemoveUser added in v1.2.8

func (n *TypeValue) RemoveUser(u User)

func (*TypeValue) SetBlock added in v1.2.8

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

func (*TypeValue) SetExtern added in v1.2.8

func (c *TypeValue) SetExtern(b bool)

func (*TypeValue) SetFunc added in v1.2.8

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

ssa function and block

func (*TypeValue) SetId added in v1.3.0

func (a *TypeValue) SetId(id int)

id

func (*TypeValue) SetName added in v1.3.0

func (a *TypeValue) SetName(v string)

variable

func (*TypeValue) SetRange added in v1.3.0

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

func (*TypeValue) SetScope added in v1.3.0

func (a *TypeValue) SetScope(s *Scope)

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 TypedNode added in v1.2.8

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

type Types

type Types []Type // each value can have multiple type possible

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 NewUnOpOnly added in v1.2.8

func NewUnOpOnly(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) 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) GetAllVariables added in v1.3.0

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

func (*UnOp) GetBlock

func (a *UnOp) GetBlock() *BasicBlock

func (*UnOp) GetFunc added in v1.2.8

func (a *UnOp) GetFunc() *Function

func (*UnOp) GetId added in v1.3.0

func (a *UnOp) GetId() int

func (*UnOp) GetMask added in v1.3.0

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

func (*UnOp) GetName added in v1.3.0

func (a *UnOp) GetName() string

func (*UnOp) GetOpcode added in v1.2.8

func (i *UnOp) GetOpcode() Opcode

func (*UnOp) GetOperand added in v1.2.8

func (a *UnOp) GetOperand(i int) Value

func (*UnOp) GetOperandNum added in v1.2.8

func (a *UnOp) GetOperandNum() int

func (*UnOp) GetOperands added in v1.2.8

func (a *UnOp) GetOperands() Values

func (*UnOp) GetProgram added in v1.3.0

func (a *UnOp) GetProgram() *Program

func (*UnOp) GetRange added in v1.3.0

func (c *UnOp) GetRange() *Range

source code position

func (*UnOp) GetScope added in v1.3.0

func (a *UnOp) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *UnOp) IsExtern() bool

func (*UnOp) LineDisasm added in v1.2.8

func (a *UnOp) LineDisasm() string

func (*UnOp) Masked added in v1.3.0

func (i *UnOp) Masked() bool

func (*UnOp) NewError

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

error logger

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) SetBlock added in v1.2.8

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

func (*UnOp) SetExtern added in v1.2.8

func (c *UnOp) SetExtern(b bool)

func (*UnOp) SetFunc added in v1.2.8

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

ssa function and block

func (*UnOp) SetId added in v1.3.0

func (a *UnOp) SetId(id int)

id

func (*UnOp) SetName added in v1.3.0

func (a *UnOp) SetName(v string)

variable

func (*UnOp) SetRange added in v1.3.0

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

func (*UnOp) SetScope added in v1.3.0

func (a *UnOp) SetScope(s *Scope)

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 int
const (
	OpNone       UnaryOpcode = iota
	OpNot                    // !
	OpPlus                   // +
	OpNeg                    // -
	OpChan                   // <-
	OpBitwiseNot             // ^
)

type Undefined added in v1.2.8

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

----------- Undefined

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) 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) GetAllVariables added in v1.3.0

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

func (*Undefined) GetBlock added in v1.2.8

func (a *Undefined) GetBlock() *BasicBlock

func (*Undefined) GetFunc added in v1.2.8

func (a *Undefined) GetFunc() *Function

func (*Undefined) GetId added in v1.3.0

func (a *Undefined) GetId() int

func (*Undefined) GetMask added in v1.3.0

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

func (*Undefined) GetName added in v1.3.0

func (a *Undefined) GetName() string

func (*Undefined) GetOpcode added in v1.2.8

func (i *Undefined) GetOpcode() Opcode

func (*Undefined) GetOperand added in v1.2.8

func (a *Undefined) GetOperand(i int) Value

func (*Undefined) GetOperandNum added in v1.2.8

func (a *Undefined) GetOperandNum() int

func (*Undefined) GetOperands added in v1.2.8

func (a *Undefined) GetOperands() Values

func (*Undefined) GetProgram added in v1.3.0

func (a *Undefined) GetProgram() *Program

func (*Undefined) GetRange added in v1.3.0

func (c *Undefined) GetRange() *Range

source code position

func (*Undefined) GetScope added in v1.3.0

func (a *Undefined) GetScope() *Scope

symbol-table

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) IsExtern added in v1.2.8

func (c *Undefined) IsExtern() bool

func (*Undefined) LineDisasm added in v1.2.8

func (a *Undefined) LineDisasm() string

func (*Undefined) Masked added in v1.3.0

func (i *Undefined) Masked() bool

func (*Undefined) NewError added in v1.2.8

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

error logger

func (*Undefined) RemoveUser added in v1.2.8

func (n *Undefined) RemoveUser(u User)

func (*Undefined) SetBlock added in v1.2.8

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

func (*Undefined) SetExtern added in v1.2.8

func (c *Undefined) SetExtern(b bool)

func (*Undefined) SetFunc added in v1.2.8

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

ssa function and block

func (*Undefined) SetId added in v1.3.0

func (a *Undefined) SetId(id int)

id

func (*Undefined) SetName added in v1.3.0

func (a *Undefined) SetName(v string)

variable

func (*Undefined) SetRange added in v1.3.0

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

func (*Undefined) SetScope added in v1.3.0

func (a *Undefined) SetScope(s *Scope)

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 Update

type Update struct {
	Value   Value
	Address Value // this point to field
	// contains filtered or unexported fields
}

----------- Update

func NewUpdate added in v1.2.8

func NewUpdate(address, v Value) *Update

func ToUpdate added in v1.2.8

func ToUpdate(v Instruction) (*Update, bool)

func (*Update) AddMask added in v1.3.0

func (i *Update) AddMask(v Value)

func (*Update) AddVariable added in v1.3.0

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

func (*Update) GetAllVariables added in v1.3.0

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

func (*Update) GetBlock

func (a *Update) GetBlock() *BasicBlock

func (*Update) GetFunc added in v1.2.8

func (a *Update) GetFunc() *Function

func (*Update) GetId added in v1.3.0

func (a *Update) GetId() int

func (*Update) GetMask added in v1.3.0

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

func (*Update) GetName added in v1.3.0

func (a *Update) GetName() string

func (*Update) GetOpcode added in v1.2.8

func (i *Update) GetOpcode() Opcode

func (*Update) GetOperand added in v1.2.8

func (a *Update) GetOperand(i int) Value

func (*Update) GetOperandNum added in v1.2.8

func (a *Update) GetOperandNum() int

func (*Update) GetOperands added in v1.2.8

func (a *Update) GetOperands() Values

func (*Update) GetProgram added in v1.3.0

func (a *Update) GetProgram() *Program

func (*Update) GetRange added in v1.3.0

func (c *Update) GetRange() *Range

source code position

func (*Update) GetScope added in v1.3.0

func (a *Update) GetScope() *Scope

symbol-table

func (*Update) GetUsers

func (r *Update) GetUsers() Users

func (*Update) GetValues

func (s *Update) GetValues() Values

func (*Update) GetVariable added in v1.2.8

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

func (*Update) HasUsers added in v1.2.8

func (r *Update) HasUsers() bool

node

func (*Update) HasValues added in v1.2.8

func (s *Update) HasValues() bool

----------- Update

func (*Update) IsExtern added in v1.2.8

func (c *Update) IsExtern() bool

func (*Update) LineDisasm added in v1.2.8

func (a *Update) LineDisasm() string

func (*Update) Masked added in v1.3.0

func (i *Update) Masked() bool

func (*Update) NewError

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

error logger

func (*Update) ReplaceValue

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

func (*Update) SetBlock added in v1.2.8

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

func (*Update) SetExtern added in v1.2.8

func (c *Update) SetExtern(b bool)

func (*Update) SetFunc added in v1.2.8

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

ssa function and block

func (*Update) SetId added in v1.3.0

func (a *Update) SetId(id int)

id

func (*Update) SetName added in v1.3.0

func (a *Update) SetName(v string)

variable

func (*Update) SetRange added in v1.3.0

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

func (*Update) SetScope added in v1.3.0

func (a *Update) SetScope(s *Scope)

func (*Update) String

func (s *Update) String() string

----------- Update

type User

type User interface {
	InstructionNode
	ReplaceValue(Value, Value)
}

func ToUser added in v1.2.8

func ToUser(n any) (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))

func (Users) RunOnField added in v1.2.8

func (u Users) RunOnField(f func(*Field))

func (Users) RunOnFieldOr added in v1.2.8

func (u Users) RunOnFieldOr(f func(*Field), or func(User))

func (Users) RunOnUpdate added in v1.2.8

func (u Users) RunOnUpdate(f func(*Update))

func (Users) RunOnUpdateOr added in v1.2.8

func (u Users) RunOnUpdateOr(f func(*Update), or func(User))

type Value

type Value interface {
	InstructionNode
	TypedNode
	Maskable
	AddUser(User)
	RemoveUser(User)
}

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 NewBinOp added in v1.2.8

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

func NewUnOp added in v1.2.8

func NewUnOp(op UnaryOpcode, x Value) Value

func ToValue added in v1.2.8

func ToValue(n any) (Value, bool)

type Values added in v1.2.8

type Values []Value

func GetValues added in v1.2.8

func GetValues(n Node) Values

type Variable added in v1.3.0

type Variable struct {
	Name  string
	Range map[*Range]struct{}
	V     Value
}

func NewVariable added in v1.3.0

func NewVariable(name string, i Value) *Variable

func (*Variable) AddRange added in v1.3.0

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

func (*Variable) NewError added in v1.3.0

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

func (*Variable) String added in v1.3.0

func (v *Variable) String() string

Jump to

Keyboard shortcuts

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