Documentation ¶
Overview ¶
Package cast 实现了一个C语言的抽象语法树
Index ¶
- Variables
- func PaeserIr2(toc *Ir2ToC, f *ir2.File)
- type ASSIGNNode
- type CallNode
- type CaseNode
- type ConstNode
- type Dereference
- type ElseNode
- type ForNode
- type FuncNode
- type IfNode
- type IndexExpr
- type Ir2ToC
- type Node
- type ObjKind
- type Object
- type Objects
- type OneIr2ToC
- type OpExpr
- type OperationExpr
- type Package
- type ReturnNode
- type SelfOpStmt
- type SwitchNode
- type UtoC
- type VarNode
Constants ¶
This section is empty.
Variables ¶
View Source
var Deferfunc func() = utils.Deferfunc
View Source
var ( ObjKindSrtMap = [...]string{ NoOP: "noop (未定义的类型)", INTOBJ: "intobj (整数)", FLOATOBJ: "floatobj (浮点数)", BoolObj: "boolobj (布尔值)", StringObj: "stringobj(字符串)", SymbolObj: "symbolobj (符号)", LeaObj: "leaObj (取地址)", DerefObj: "derefObj (解引用)", StructPtr: "StructPtr (结构体指针)", NilObj: "NilObj (指针的零值)", EnumObj: "EnumObj (枚举值)", } )
Functions ¶
Types ¶
type ASSIGNNode ¶
type ASSIGNNode struct { //目的操作数,源操作数 Dest Node Src Node // contains filtered or unexported fields }
赋值节点
func UtoCASSIGN ¶
func UtoCASSIGN(a *ast.ASSIGNNode) *ASSIGNNode
UtoCASSIGN 将赋值节点转换为cast等价的 - a是被转换的,不能为nil
func (*ASSIGNNode) C ¶
func (a *ASSIGNNode) C(buf *strings.Builder)
func (*ASSIGNNode) CType ¶
func (a *ASSIGNNode) CType() cenum.NodeEnum
func (*ASSIGNNode) String ¶
func (a *ASSIGNNode) String() string
type CallNode ¶
type CallNode struct { Parame []Node //Parameter // contains filtered or unexported fields }
函数调用节点
func NewCallNode ¶
NewCallNode 创建函数调用节点
type CaseNode ¶
type CaseNode struct {
Expr Node
}
case节点
func NewCaseNode ¶
func NewCaseNode() *CaseNode
type ConstNode ¶
type ConstNode struct { Value Node Name string TYPE string IsFunc bool // contains filtered or unexported fields }
常量声明节点
type Dereference ¶
type Dereference struct {
Value Node
}
Dereference 解引用节点
func (*Dereference) C ¶
func (d *Dereference) C(buf *strings.Builder)
func (*Dereference) CType ¶
func (d *Dereference) CType() cenum.NodeEnum
func (*Dereference) String ¶
func (d *Dereference) String() string
type ElseNode ¶
type ElseNode struct {
BoolExpr Node
}
else节点
func NewElseNode ¶
func NewElseNode() *ElseNode
func UtocElseNode ¶
UtocElseNode 将else节点转换为cast等价的 - f是被转换的,不能为nil
type FuncNode ¶
type FuncNode struct { Name string Parame []astdata.Parame RetValue []astdata.RetValue TYPE cenum.NodeEnum // contains filtered or unexported fields }
函数节点
func UtoCMethod ¶
func UtoCMethod(m *ast.MethodNode) *FuncNode
UtoCCase 将方法节点转换为cast等价的 - m是被转换的,不能为nil
type Node ¶
type Node interface { // Type 返回节点类型枚举 CType() cenum.NodeEnum String() string // C 写入等效C语言代码 C(buf *strings.Builder) }
func ParserNode ¶
func UtoCExprNode ¶
UtoCExprNode 将表达式节点,转换为cast等价的 - obj是被转换的,不能为nil
type OpExpr ¶
type OpExpr = OperationExpr
运算表达式节点
func UtoCOpExpr ¶
UtoCOpExpr 将运算表达式节点转换为cast等价的 - expr是被转换的,不能为nil
type OperationExpr ¶
type OperationExpr struct { Src1 Node Src2 Node OP enum.OPSymbol IsStr bool //操作数类型是否是字符串 Inparen bool //是否在小括号内 }
运算表达式节点
type Package ¶
type Package struct { //并发 Thread bool // contains filtered or unexported fields }
func NewPackage ¶
func (*Package) AddUastSlice ¶
func (*Package) WithAutoFree ¶
type ReturnNode ¶
type ReturnNode struct {
RetValue Node
}
return节点
func UtoCReturn ¶
func UtoCReturn(r *ast.ReturnNode) *ReturnNode
UtoCReturn 将返回语句节点转换为cast等价的 - r是被转换的,不能为nil
func (*ReturnNode) C ¶
func (l *ReturnNode) C(buf *strings.Builder)
func (*ReturnNode) CType ¶
func (l *ReturnNode) CType() cenum.NodeEnum
func (*ReturnNode) String ¶
func (l *ReturnNode) String() string
type SelfOpStmt ¶
自操作语句 缩写: Self-operating statement 缩写成 SelfOpStmt
func NewSelfOpStmt ¶
func NewSelfOpStmt(OP enum.OPSymbol, Dest Node) *SelfOpStmt
func (*SelfOpStmt) C ¶
func (o *SelfOpStmt) C(buf *strings.Builder)
func (*SelfOpStmt) CType ¶
func (o *SelfOpStmt) CType() cenum.NodeEnum
func (*SelfOpStmt) String ¶
func (o *SelfOpStmt) String() string
type SwitchNode ¶
type SwitchNode struct {
Expr Node
}
switch节点
func UtoCSwitch ¶
func UtoCSwitch(s *ast.SwitchNode) *SwitchNode
UtoCSwitch 将switch节点转换为cast等价的 - s是被转换的,不能为nil
func (*SwitchNode) C ¶
func (s *SwitchNode) C(buf *strings.Builder)
func (*SwitchNode) CType ¶
func (s *SwitchNode) CType() cenum.NodeEnum
func (*SwitchNode) String ¶
func (s *SwitchNode) String() string
type UtoC ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.