ir

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzedPackage

type AnalyzedPackage struct {
	Path           string
	Name           string
	VarConsts      []*PackageVarConst
	Funcs          []*Func
	HasInitFunc    bool
	StringLiterals []*SLiteral
	Fset           *token.FileSet
	FileNoMap      map[string]int // for .loc
}

type Const

type Const struct {
	Name         string
	IsGlobal     bool
	GlobalSymbol string // "pkg.Foo"
	Literal      *MetaBasicLit
	Type         *types.Type
}

type EvalContext

type EvalContext struct {
	MaybeOK bool
	Type    *types.Type
}

type ForeignFunc

type ForeignFunc struct {
	Symbol      string
	FuncType    *ast.FuncType
	ReturnTypes []*types.Type
	ParamTypes  []*types.Type
}

type Func

type Func struct {
	Name      string
	Stmts     []MetaStmt
	Localarea int
	Argsarea  int
	LocalVars []*Variable
	Params    []*Variable
	Retvars   []*Variable
	FuncType  *ast.FuncType
	Method    *Method
}

type FuncValue

type FuncValue struct {
	IsDirect bool     // direct or indirect
	Symbol   string   // for direct call
	Expr     MetaExpr // for indirect call
}

type MetaArg

type MetaArg struct {
	Meta      MetaExpr
	ParamType *types.Type // expected type
}

type MetaBasicLit

type MetaBasicLit struct {
	Pos      token.Pos
	Type     *types.Type
	Kind     string
	RawValue string // for emitting .data data
	CharVal  int
	IntVal   int
	StrVal   *SLiteral
}

type MetaBinaryExpr

type MetaBinaryExpr struct {
	Pos  token.Pos
	Type *types.Type
	Op   string
	X    MetaExpr
	Y    MetaExpr
}

type MetaBlockStmt

type MetaBlockStmt struct {
	Pos  token.Pos
	List []MetaStmt
}

type MetaBranchStmt

type MetaBranchStmt struct {
	Pos              token.Pos
	ContainerForStmt *MetaForContainer
	ContinueOrBreak  int // 1: continue, 2:break
}

type MetaCallAppend

type MetaCallAppend struct {
	Pos  token.Pos
	Type *types.Type // result type
	Arg0 MetaExpr
	Arg1 MetaExpr
}

type MetaCallCap

type MetaCallCap struct {
	Pos  token.Pos
	Type *types.Type // result type
	Arg0 MetaExpr
}

type MetaCallDelete

type MetaCallDelete struct {
	Pos  token.Pos
	Type *types.Type // result type
	Arg0 MetaExpr
	Arg1 MetaExpr
}

type MetaCallExpr

type MetaCallExpr struct {
	Pos   token.Pos
	Type  *types.Type   // result type
	Types []*types.Type // result types when tuple

	HasEllipsis bool

	FuncVal *FuncValue

	MetaArgs []*MetaArg
}

general funcall

type MetaCallLen

type MetaCallLen struct {
	Pos  token.Pos
	Type *types.Type // result type
	Arg0 MetaExpr
}

type MetaCallMake

type MetaCallMake struct {
	Pos      token.Pos
	Type     *types.Type // result type
	TypeArg0 *types.Type
	Arg1     MetaExpr
	Arg2     MetaExpr
}

type MetaCallNew

type MetaCallNew struct {
	Pos      token.Pos
	Type     *types.Type // result type
	TypeArg0 *types.Type
}

type MetaCallPanic

type MetaCallPanic struct {
	Pos  token.Pos
	Type *types.Type // result type
	Arg0 MetaExpr
}

type MetaCaseClause

type MetaCaseClause struct {
	Pos      token.Pos
	ListMeta []MetaExpr
	Body     []MetaStmt
}

type MetaCompositLit

type MetaCompositLit struct {
	Pos  token.Pos
	Type *types.Type // type of the composite
	Kind string      // "struct", "array", "slice" // @TODO "map"

	// for struct
	StructElements []*MetaStructLiteralElement // for "struct"

	// for array or slice
	Len      int
	ElmType  *types.Type
	MetaElms []MetaExpr
}

type MetaConversionExpr

type MetaConversionExpr struct {
	Pos  token.Pos
	Type *types.Type // To type
	Arg0 MetaExpr
}

type MetaExpr

type MetaExpr interface{}

type MetaExprStmt

type MetaExprStmt struct {
	Pos token.Pos
	X   MetaExpr
}

type MetaForContainer

type MetaForContainer struct {
	Pos       token.Pos
	LabelPost string // for continue
	LabelExit string // for break
	Outer     *MetaForContainer
	Body      *MetaBlockStmt

	ForRangeStmt *MetaForRangeStmt
	ForStmt      *MetaForForStmt
}

type MetaForForStmt

type MetaForForStmt struct {
	Pos  token.Pos
	Init MetaStmt
	Cond MetaExpr
	Post MetaStmt
}

type MetaForRangeStmt

type MetaForRangeStmt struct {
	Pos      token.Pos
	IsMap    bool
	LenVar   *Variable
	Indexvar *Variable
	MapVar   *Variable // map
	ItemVar  *Variable // map element
	X        MetaExpr
	Key      MetaExpr
	Value    MetaExpr
}

type MetaForeignFuncWrapper

type MetaForeignFuncWrapper struct {
	Pos token.Pos
	QI  QualifiedIdent
	FF  *ForeignFunc
}

type MetaGoStmt

type MetaGoStmt struct {
	Pos token.Pos
	Fun MetaExpr
}

type MetaIdent

type MetaIdent struct {
	Pos  token.Pos
	Type *types.Type
	Kind string // "blank|nil|true|false|var|con|fun|typ"
	Name string

	Variable *Variable // for "var"

	Const *Const // for "con"
}

type MetaIfStmt

type MetaIfStmt struct {
	Pos  token.Pos
	Init MetaStmt
	Cond MetaExpr
	Body *MetaBlockStmt
	Else MetaStmt
}

type MetaIndexExpr

type MetaIndexExpr struct {
	Pos     token.Pos
	IsMap   bool // mp[k]
	NeedsOK bool // when map, is it ok syntax ?
	Index   MetaExpr
	X       MetaExpr
	Type    *types.Type
}

type MetaReturnStmt

type MetaReturnStmt struct {
	Pos     token.Pos
	Fnc     *Func
	Results []MetaExpr
}

type MetaSelectorExpr

type MetaSelectorExpr struct {
	Pos            token.Pos
	IsQI           bool
	QI             QualifiedIdent
	Type           *types.Type
	X              MetaExpr
	SelName        string
	ForeignObjKind string // "var|con|fun"
	ForeignValue   MetaExpr

	// for struct field
	Field     *ast.Field
	Offset    int
	NeedDeref bool
}

type MetaSingleAssign

type MetaSingleAssign struct {
	Pos token.Pos
	Lhs MetaExpr
	Rhs MetaExpr // can be nil
}

type MetaSliceExpr

type MetaSliceExpr struct {
	Pos  token.Pos
	Type *types.Type
	Low  MetaExpr
	High MetaExpr
	Max  MetaExpr
	X    MetaExpr
}

type MetaStarExpr

type MetaStarExpr struct {
	Pos  token.Pos
	Type *types.Type
	X    MetaExpr
}

type MetaStmt

type MetaStmt interface{}

type MetaStructLiteralElement

type MetaStructLiteralElement struct {
	Pos       token.Pos
	Field     *ast.Field
	FieldType *types.Type
	ValueMeta MetaExpr
}

type MetaSwitchStmt

type MetaSwitchStmt struct {
	Pos   token.Pos
	Init  MetaStmt
	Cases []*MetaCaseClause
	Tag   MetaExpr
}

type MetaTupleAssign

type MetaTupleAssign struct {
	Pos      token.Pos
	IsOK     bool // OK or funcall
	Lhss     []MetaExpr
	Rhs      MetaExpr
	RhsTypes []*types.Type
}

type MetaTypeAssertExpr

type MetaTypeAssertExpr struct {
	Pos     token.Pos
	NeedsOK bool
	X       MetaExpr
	Type    *types.Type
}

type MetaTypeSwitchCaseClose

type MetaTypeSwitchCaseClose struct {
	Pos      token.Pos
	Variable *Variable
	//VariableType *Type
	Types []*types.Type
	Body  []MetaStmt
}

type MetaTypeSwitchStmt

type MetaTypeSwitchStmt struct {
	Pos             token.Pos
	Subject         MetaExpr
	SubjectVariable *Variable
	AssignObj       *ast.Object
	Cases           []*MetaTypeSwitchCaseClose
}

type MetaUnaryExpr

type MetaUnaryExpr struct {
	Pos  token.Pos
	X    MetaExpr
	Type *types.Type
	Op   string
}

type MetaVarDecl

type MetaVarDecl struct {
	Pos     token.Pos
	Single  *MetaSingleAssign
	LhsType *types.Type
}

type Method

type Method struct {
	PkgName      string
	RcvNamedType *ast.Ident
	IsPtrMethod  bool
	Name         string
	FuncType     *ast.FuncType
}

type NamedType

type NamedType struct {
	MethodSet map[string]*Method
}

type PackageVarConst

type PackageVarConst struct {
	Spec    *ast.ValueSpec
	Name    *ast.Ident
	Val     ast.Expr    // can be nil
	MetaVal MetaExpr    // can be nil
	Type    *types.Type // cannot be nil
	MetaVar *MetaIdent  // only for var
}

Package vars or consts

type PkgContainer

type PkgContainer struct {
	Path           string
	Name           string
	AstFiles       []*ast.File
	StringLiterals []*SLiteral
	StringIndex    int
	Decls          []ast.Decl
	Fset           *token.FileSet
	FileNoMap      map[string]int // for .loc
}

type QualifiedIdent

type QualifiedIdent string

type SLiteral

type SLiteral struct {
	Label  string
	Strlen int
	Value  string // raw value
}

--- walk ---

type Variable

type Variable struct {
	Name         string
	IsGlobal     bool
	GlobalSymbol string
	LocalOffset  int
	Typ          *types.Type
}

Jump to

Keyboard shortcuts

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