Documentation
¶
Index ¶
- func WriteFunction(b *strings.Builder, f *Function)
- type Arithmetic
- type Assign
- type AttrGet
- type BasicBlock
- type Call
- type CompoundAssign
- type Concat
- type False
- type Field
- type Function
- func (f *Function) Chunk() (chunk ast.Chunk)
- func (f *Function) DomPreorder() []*BasicBlock
- func (f *Function) EmitAssign(lhs Value, rhs Value)
- func (f *Function) NewBasicBlock(comment string) *BasicBlock
- func (v *Function) Operands(rands []*Value) []*Value
- func (v *Function) Parent() *Function
- func (v *Function) Referrers() *[]Instruction
- func (f *Function) StartBody()
- func (f *Function) String() string
- func (f *Function) Syntax() *ast.FunctionExpr
- type GenericFor
- type Global
- type If
- type Instruction
- type Jump
- type Local
- type Logic
- type Nil
- type Node
- type Number
- type NumberFor
- type Phi
- type Relation
- type Return
- type Scope
- type String
- type Table
- type True
- type Unary
- type Value
- type VarArg
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteFunction ¶
Types ¶
type Arithmetic ¶
func (Arithmetic) String ¶
func (s Arithmetic) String() string
type Assign ¶
func (*Assign) Block ¶
func (v *Assign) Block() *BasicBlock
func (*Assign) Referrers ¶
func (v *Assign) Referrers() *[]Instruction
type BasicBlock ¶
type BasicBlock struct {
Index int // index of this block within Parent().Blocks
Comment string // optional label; no semantic significance
Instrs []Instruction // instructions in order
Preds, Succs []*BasicBlock // predecessors and successors
// contains filtered or unexported fields
}
func (*BasicBlock) Dominates ¶
func (b *BasicBlock) Dominates(c *BasicBlock) bool
Dominates reports whether b dominates c.
func (*BasicBlock) Dominees ¶
func (b *BasicBlock) Dominees() []*BasicBlock
Dominees returns the list of blocks that b immediately dominates: its children in the dominator tree.
func (*BasicBlock) Idom ¶
func (b *BasicBlock) Idom() *BasicBlock
Idom returns the block that immediately dominates b: its parent in the dominator tree, if any. Neither the entry node (b.Index==0) nor recover node (b==b.Parent().Recover()) have a parent.
func (*BasicBlock) Parent ¶
func (b *BasicBlock) Parent() *Function
Parent returns the function that contains block b.
func (*BasicBlock) String ¶
func (b *BasicBlock) String() string
String returns a human-readable label of this block. It is not guaranteed unique within the function.
func (*BasicBlock) ToAst ¶
func (b *BasicBlock) ToAst(dom domFrontier) (chunk ast.Chunk)
type Call ¶
type Call struct {
Args []Value
Func Value
Method string
Recv Value
// contains filtered or unexported fields
}
func (*Call) Block ¶
func (v *Call) Block() *BasicBlock
func (*Call) Referrers ¶
func (v *Call) Referrers() *[]Instruction
type CompoundAssign ¶
type CompoundAssign struct {
Op string
Lhs Value
Rhs Value
// contains filtered or unexported fields
}
func (*CompoundAssign) Block ¶
func (v *CompoundAssign) Block() *BasicBlock
func (*CompoundAssign) Referrers ¶
func (v *CompoundAssign) Referrers() *[]Instruction
func (*CompoundAssign) String ¶
func (v *CompoundAssign) String() string
type Function ¶
type Function struct {
Name string
Params []*Local // function parameters; for methods, includes receiver
Locals []*Local
UpValues []*Local
Functions []*Function // nested functions defined inside this one
Blocks []*BasicBlock // basic blocks of the function; nil => external
VarArg bool
// contains filtered or unexported fields
}
func (*Function) DomPreorder ¶
func (f *Function) DomPreorder() []*BasicBlock
DomPreorder returns a new slice containing the blocks of f in dominator tree preorder.
func (*Function) EmitAssign ¶
func (*Function) NewBasicBlock ¶
func (f *Function) NewBasicBlock(comment string) *BasicBlock
NewBasicBlock adds to f a new basic block and returns it. It does not automatically become the current block for subsequent calls to emit. comment is an optional string for more readable debugging output.
func (*Function) Operands ¶
Non-Instruction Values: func (v *Const) Operands(rands []*Value) []*Value { return rands }
func (*Function) Referrers ¶
func (v *Function) Referrers() *[]Instruction
func (*Function) StartBody ¶
func (f *Function) StartBody()
StartBody initializes the function prior to generating SSA code for its body. Precondition: f.Type() already set.
func (*Function) Syntax ¶
func (f *Function) Syntax() *ast.FunctionExpr
type GenericFor ¶
func (*GenericFor) Block ¶
func (v *GenericFor) Block() *BasicBlock
func (*GenericFor) Referrers ¶
func (v *GenericFor) Referrers() *[]Instruction
func (*GenericFor) String ¶
func (v *GenericFor) String() string
type If ¶
type If struct {
Cond Value
// contains filtered or unexported fields
}
func (*If) Block ¶
func (v *If) Block() *BasicBlock
func (*If) Referrers ¶
func (v *If) Referrers() *[]Instruction
type Instruction ¶
type Instruction interface {
String() string
Parent() *Function
Block() *BasicBlock
// contains filtered or unexported methods
}
type Jump ¶
type Jump struct {
// contains filtered or unexported fields
}
func (*Jump) Block ¶
func (v *Jump) Block() *BasicBlock
func (*Jump) Referrers ¶
func (v *Jump) Referrers() *[]Instruction
type Local ¶
type Node ¶
type Node interface {
// Common methods:
String() string
Parent() *Function
// Partial methods:
Operands(rands []*Value) []*Value // nil for non-Instructions
Referrers() *[]Instruction // nil for non-Values
}
type NumberFor ¶
type NumberFor struct {
Local Value
Init Value
Limit Value
Step Value
// contains filtered or unexported fields
}
func (*NumberFor) Block ¶
func (v *NumberFor) Block() *BasicBlock
func (*NumberFor) Referrers ¶
func (v *NumberFor) Referrers() *[]Instruction
type Phi ¶
type Phi struct {
Comment string // a hint as to its purpose
Edges []Value // Edges[i] is value for Block().Preds[i]
// contains filtered or unexported fields
}
func (*Phi) Block ¶
func (v *Phi) Block() *BasicBlock
func (*Phi) Referrers ¶
func (v *Phi) Referrers() *[]Instruction
type Return ¶
type Return struct {
// contains filtered or unexported fields
}
func (*Return) Block ¶
func (v *Return) Block() *BasicBlock
func (*Return) Referrers ¶
func (v *Return) Referrers() *[]Instruction