ssaapi

package
v1.2.9-sp7 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSA_BOTTOM_USES_targetActualParam      = "targetActualParam"
	SSA_BOTTOM_USES_targetActualParamIndex = "targetActualParam_Index"
)

Variables

View Source
var Exports = map[string]any{
	"Parse": Parse,

	"withLanguage":    WithLanguage,
	"withExternLib":   WithExternLib,
	"withExternValue": WithExternValue,

	"Javascript": JS,
	"Yak":        Yak,
}
View Source
var (
	LanguageParsers = map[Language]LanguageParser{
		Yak: yak2ssa.NewParser(),
		JS:  js2ssa.NewParser(),
	}
)

Functions

func GetBareNode added in v1.2.9

func GetBareNode(v *Value) ssa.InstructionNode

func GetBareType added in v1.2.9

func GetBareType(typ *Type) ssa.Type

func TypeCompare added in v1.2.9

func TypeCompare(t1, t2 *Type) bool

func ValueCompare added in v1.2.9

func ValueCompare(v1, v2 *Value) bool

Types

type AnalyzeContext added in v1.3.0

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

func NewAnalyzeContext added in v1.3.0

func NewAnalyzeContext() *AnalyzeContext

func (*AnalyzeContext) GetCurrentCall added in v1.3.0

func (g *AnalyzeContext) GetCurrentCall() *Value

func (*AnalyzeContext) IsExistedInCallStack added in v1.3.0

func (a *AnalyzeContext) IsExistedInCallStack(i *Value) bool

func (*AnalyzeContext) PopCall added in v1.3.0

func (a *AnalyzeContext) PopCall() *Value

func (*AnalyzeContext) PushCall added in v1.3.0

func (a *AnalyzeContext) PushCall(i *Value) error

func (*AnalyzeContext) TheCallShouldBeVisited added in v1.3.0

func (a *AnalyzeContext) TheCallShouldBeVisited(i *Value) bool

func (*AnalyzeContext) ThePhiShouldBeVisited added in v1.3.0

func (a *AnalyzeContext) ThePhiShouldBeVisited(i *Value) bool

ThePhiShouldBeVisited is used to check whether the phi should be visited

func (*AnalyzeContext) VisitPhi added in v1.3.0

func (a *AnalyzeContext) VisitPhi(i *Value)

type Language

type Language string
const (
	JS  Language = "js"
	Yak Language = "yak"
)

type LanguageParser added in v1.3.0

type LanguageParser interface {
	Parse(string, bool, func(*ssa.FunctionBuilder)) *ssa.Program
}

type Option

type Option func(*config)

func WithExternInfo added in v1.3.0

func WithExternInfo(info string) Option

func WithExternLib

func WithExternLib(name string, table map[string]any) Option

func WithExternMethod added in v1.2.9

func WithExternMethod(b ssa.MethodBuilder) Option

func WithExternValue

func WithExternValue(table map[string]any) Option

func WithIgnoreSyntaxError added in v1.3.0

func WithIgnoreSyntaxError(b ...bool) Option

func WithLanguage

func WithLanguage(language Language) Option

type Program

type Program struct {
	Program *ssa.Program
}

func NewProgram

func NewProgram(prog *ssa.Program) *Program

func Parse

func Parse(code string, opts ...Option) *Program

func (*Program) GetAllSymbols added in v1.3.0

func (p *Program) GetAllSymbols() map[string]Values

func (*Program) GetErrors added in v1.3.0

func (p *Program) GetErrors() ssa.SSAErrors

func (*Program) GetInstructionById added in v1.3.0

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

func (*Program) GetValueById added in v1.3.0

func (p *Program) GetValueById(id int) (*Value, error)

func (*Program) GetValueByIdMust added in v1.3.0

func (p *Program) GetValueByIdMust(id int) *Value

func (*Program) IsNil added in v1.2.9

func (p *Program) IsNil() bool

func (*Program) Ref

func (p *Program) Ref(name string) Values

func (*Program) Show added in v1.3.0

func (p *Program) Show() *Program

type Type added in v1.2.9

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

func FuncOf added in v1.2.9

func FuncOf(name string, args, ret []*Type, isVariadic bool) *Type

func MapOf added in v1.2.9

func MapOf(key, value *Type) *Type

func NewType added in v1.2.9

func NewType(t ssa.Type) *Type

func SliceOf added in v1.2.9

func SliceOf(t *Type) *Type

func (*Type) Compare added in v1.2.9

func (t *Type) Compare(t2 *Type) bool

func (*Type) String added in v1.2.9

func (t *Type) String() string

type Value

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

func NewValue

func NewValue(n ssa.InstructionNode) *Value

func (*Value) Compare added in v1.2.9

func (v *Value) Compare(other *Value) bool

func (*Value) FixUpdateValue added in v1.2.9

func (v *Value) FixUpdateValue() Values

func (*Value) GetBlock

func (v *Value) GetBlock() *Value

func (*Value) GetBottomUses added in v1.3.0

func (v *Value) GetBottomUses() Values

func (*Value) GetCallArgs added in v1.3.0

func (v *Value) GetCallArgs() Values

func (*Value) GetCallReturns added in v1.3.0

func (v *Value) GetCallReturns() Values

func (*Value) GetCalledBy added in v1.3.0

func (v *Value) GetCalledBy() Values

GetCalledBy desc all of 'Users' is Call or Make

func (*Value) GetCallee added in v1.3.0

func (v *Value) GetCallee() *Value

GetCallee desc any of 'Users' is Call

func (*Value) GetConst added in v1.2.9

func (v *Value) GetConst() *ssa.Const

func (*Value) GetConstValue added in v1.2.9

func (v *Value) GetConstValue() any

for const instruction

func (*Value) GetContextValue added in v1.3.0

func (v *Value) GetContextValue(i string) (*Value, bool)

GetContextValue can handle context

func (*Value) GetDefs added in v1.3.0

func (i *Value) GetDefs() Values

func (*Value) GetFieldName added in v1.3.0

func (i *Value) GetFieldName() *Value

func (*Value) GetFieldValues added in v1.3.0

func (i *Value) GetFieldValues() Values

func (*Value) GetFirstFieldValue added in v1.3.0

func (i *Value) GetFirstFieldValue() *Value

func (*Value) GetFunction

func (v *Value) GetFunction() *Value

func (*Value) GetId added in v1.3.0

func (v *Value) GetId() int

func (*Value) GetLatestFieldValue added in v1.3.0

func (i *Value) GetLatestFieldValue() *Value

func (*Value) GetMakeObjectFields added in v1.3.0

func (v *Value) GetMakeObjectFields() Values

func (*Value) GetOpcode added in v1.2.9

func (v *Value) GetOpcode() ssa.Opcode

func (*Value) GetOperand

func (i *Value) GetOperand(index int) *Value

func (*Value) GetOperands

func (i *Value) GetOperands() Values

func (*Value) GetParameter

func (v *Value) GetParameter(i int) *Value

func (*Value) GetParameters added in v1.2.9

func (v *Value) GetParameters() Values

func (*Value) GetParent added in v1.3.0

func (v *Value) GetParent() (*Value, bool)

func (*Value) GetPosition added in v1.2.9

func (v *Value) GetPosition() *ssa.Range

func (*Value) GetReachable

func (v *Value) GetReachable() *Value

func (*Value) GetReturn

func (v *Value) GetReturn() Values

func (*Value) GetSelf added in v1.2.9

func (v *Value) GetSelf() *Value

func (*Value) GetTopDefs added in v1.3.0

func (i *Value) GetTopDefs() Values

GetTopDefs desc all of 'Defs' is not used by any other value

func (*Value) GetType added in v1.2.9

func (v *Value) GetType() *Type

func (*Value) GetTypeKind added in v1.2.9

func (v *Value) GetTypeKind() ssa.TypeKind

func (*Value) GetUser

func (i *Value) GetUser(index int) *Value

func (*Value) GetUsers

func (i *Value) GetUsers() Values

func (*Value) HasOperands

func (i *Value) HasOperands() bool

func (*Value) HasUsers

func (i *Value) HasUsers() bool

func (*Value) InMainFunction

func (v *Value) InMainFunction() bool

func (*Value) IsAssert

func (v *Value) IsAssert() bool

func (*Value) IsBasicBlock

func (v *Value) IsBasicBlock() bool

func (*Value) IsBinOp

func (v *Value) IsBinOp() bool

func (*Value) IsCall

func (v *Value) IsCall() bool

func (*Value) IsCalled added in v1.3.0

func (v *Value) IsCalled() bool

IsCalled desc any of 'Users' is Call or Make

func (*Value) IsConstInst

func (v *Value) IsConstInst() bool

func (*Value) IsErrorHandler

func (v *Value) IsErrorHandler() bool

func (*Value) IsExtern added in v1.2.9

func (v *Value) IsExtern() bool

func (*Value) IsField

func (v *Value) IsField() bool

func (*Value) IsFunction

func (v *Value) IsFunction() bool

func (*Value) IsIf

func (v *Value) IsIf() bool

func (*Value) IsJump

func (v *Value) IsJump() bool

func (*Value) IsLoop

func (v *Value) IsLoop() bool

func (*Value) IsMake

func (v *Value) IsMake() bool

func (*Value) IsModifySelf added in v1.2.9

func (v *Value) IsModifySelf() bool

func (*Value) IsNext

func (v *Value) IsNext() bool

func (*Value) IsPanic

func (v *Value) IsPanic() bool

func (*Value) IsParameter added in v1.2.9

func (v *Value) IsParameter() bool

func (*Value) IsPhi

func (v *Value) IsPhi() bool

func (*Value) IsReachable

func (v *Value) IsReachable() int

if condition is true : 1 reach if condition is false : -1 unreachable if condition need calc: 0 unknown

func (*Value) IsRecover

func (v *Value) IsRecover() bool

func (*Value) IsReturn

func (v *Value) IsReturn() bool

func (*Value) IsSwitch

func (v *Value) IsSwitch() bool

func (*Value) IsTypeCast

func (v *Value) IsTypeCast() bool

func (*Value) IsTypeValue

func (v *Value) IsTypeValue() bool

func (*Value) IsUnOp

func (v *Value) IsUnOp() bool

func (*Value) IsUndefined

func (v *Value) IsUndefined() bool

func (*Value) IsUpdate

func (v *Value) IsUpdate() bool

func (*Value) NewError added in v1.2.9

func (v *Value) NewError(tag, msg string)

func (*Value) NewWarn added in v1.2.9

func (v *Value) NewWarn(tag, msg string)

func (*Value) SetContextValue added in v1.3.0

func (v *Value) SetContextValue(i string, values *Value) *Value

func (*Value) SetParent added in v1.3.0

func (v *Value) SetParent(value *Value) *Value

func (*Value) Show

func (i *Value) Show()

func (*Value) ShowUseDefChain

func (v *Value) ShowUseDefChain()

func (*Value) ShowWithSource

func (i *Value) ShowWithSource()

func (*Value) String

func (v *Value) String() string

func (*Value) StringWithSource

func (i *Value) StringWithSource() string

type Values

type Values []*Value

func (Values) Filter added in v1.2.9

func (v Values) Filter(f func(*Value) bool) Values

func (Values) Flat added in v1.3.0

func (v Values) Flat(f func(*Value) Values) Values

func (Values) ForEach

func (v Values) ForEach(f func(*Value)) Values

func (Values) Get

func (v Values) Get(i int) *Value

func (Values) GetDefs added in v1.3.0

func (v Values) GetDefs() Values

func (Values) GetTopDefs added in v1.3.0

func (v Values) GetTopDefs() Values

func (Values) GetUsers added in v1.2.9

func (v Values) GetUsers() Values

func (Values) Ref

func (value Values) Ref(name string) Values

func (Values) Show

func (v Values) Show(b ...bool) Values

func (Values) ShowWithSource

func (v Values) ShowWithSource(b ...bool) Values

func (Values) String added in v1.3.0

func (v Values) String() string

func (Values) StringEx

func (v Values) StringEx(flag int) string

func (Values) Walk added in v1.3.0

func (v Values) Walk(handler func(i *Value)) Values

func (Values) WalkDefs added in v1.3.0

func (v Values) WalkDefs(handler func(i *Value)) Values

Jump to

Keyboard shortcuts

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