Documentation ¶
Index ¶
- func CompileExp(c *ir.Compiler, e ExpNode) ir.Register
- func CompileExpInto(c *ir.Compiler, e ExpNode, dst ir.Register)
- func CompileExpList(c *ir.Compiler, exps []ExpNode, dstRegs []ir.Register)
- func EmitInstr(c *ir.Compiler, l Locator, instr ir.Instruction)
- func EmitJump(c *ir.Compiler, l Locator, lbl ir.Name)
- func EmitLoadConst(c *ir.Compiler, l Locator, k ir.Constant, reg ir.Register)
- func EmitMove(c *ir.Compiler, l Locator, dst, src ir.Register)
- func IsNumber(e ExpNode) bool
- type Assign
- type AssignStat
- type BFunctionCall
- type BinOp
- type BlockStat
- type Bool
- type BreakStat
- type CondStat
- type EmptyStat
- type EtcType
- type ExpNode
- type Float
- type ForInStat
- type ForStat
- type Function
- type FunctionCall
- type GotoStat
- type HWriter
- type IfStat
- type IndentWriter
- type IndexExp
- type Int
- type LabelStat
- type LocalFunctionStat
- type LocalStat
- type Location
- type Locator
- type Name
- type NilType
- type NoTableKey
- type Node
- type NumberOracle
- type ParList
- type RepeatStat
- type Stat
- type String
- type TableConstructor
- type TableField
- type TailExpNode
- type UnOp
- type Var
- type WhileStat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileExp ¶
CompileExp compiles the given expression into a register and returns it.
func CompileExpInto ¶
CompileExpInto compiles the given expression into the given register
func CompileExpList ¶
CompileExpList compiles the given expressions into free registers, which are recorded into dstRegs (hence exps and dstRegs must have the same length). Those registers are taken so need to be released by the caller when no longer needed.
Types ¶
type AssignStat ¶
func NewAssignStat ¶
func NewAssignStat(dst []Var, src []ExpNode) AssignStat
func NewFunctionStat ¶
func NewFunctionStat(fName Var, method Name, fx Function) AssignStat
func (AssignStat) CompileStat ¶
func (s AssignStat) CompileStat(c *ir.Compiler)
func (AssignStat) HWrite ¶
func (s AssignStat) HWrite(w HWriter)
type BFunctionCall ¶
type BFunctionCall struct { Location // contains filtered or unexported fields }
func (BFunctionCall) CompileCall ¶
func (f BFunctionCall) CompileCall(c *ir.Compiler, tail bool)
func (BFunctionCall) CompileExp ¶
func (BFunctionCall) HWrite ¶
func (f BFunctionCall) HWrite(w HWriter)
type BlockStat ¶
func NewBlockStat ¶
func (BlockStat) CompileBlock ¶
func (BlockStat) CompileBlockNoPop ¶
func (BlockStat) CompileStat ¶
type BreakStat ¶
type BreakStat struct {
Location
}
func NewBreakStat ¶
func (BreakStat) CompileStat ¶
type CondStat ¶
CondStat is a conditional statement, used in e.g. if statements and while / repeat until loops.
func (CondStat) CompileCond ¶
CompileCond compiles a conditional statement.
type EmptyStat ¶
type EmptyStat struct {
Location
}
func NewEmptyStat ¶
func (EmptyStat) CompileStat ¶
type EtcType ¶
type EtcType struct {
Location
}
func (EtcType) CompileEtcExp ¶
func (EtcType) CompileExp ¶
func (EtcType) CompileTailExp ¶
type FunctionCall ¶
type FunctionCall struct {
*BFunctionCall
}
func NewFunctionCall ¶
func NewFunctionCall(target ExpNode, method Name, args []ExpNode) FunctionCall
func (FunctionCall) CompileEtcExp ¶
func (FunctionCall) CompileStat ¶
func (f FunctionCall) CompileStat(c *ir.Compiler)
func (FunctionCall) CompileTailExp ¶
func (f FunctionCall) CompileTailExp(c *ir.Compiler, dstRegs []ir.Register)
func (FunctionCall) InBrackets ¶
func (f FunctionCall) InBrackets() *BFunctionCall
type GotoStat ¶
func (GotoStat) CompileStat ¶
type HWriter ¶
type HWriter interface { Writef(string, ...interface{}) Indent() Dedent() Next() }
HWriter is an interface for printing nodes
type IndentWriter ¶
type IndentWriter struct {
// contains filtered or unexported fields
}
func NewIndentWriter ¶
func NewIndentWriter(w io.Writer) *IndentWriter
func (*IndentWriter) Dedent ¶
func (w *IndentWriter) Dedent()
func (*IndentWriter) Indent ¶
func (w *IndentWriter) Indent()
func (*IndentWriter) Next ¶
func (w *IndentWriter) Next()
func (*IndentWriter) Writef ¶
func (w *IndentWriter) Writef(f string, args ...interface{})
type LocalFunctionStat ¶
func NewLocalFunctionStat ¶
func NewLocalFunctionStat(name Name, fx Function) LocalFunctionStat
func (LocalFunctionStat) CompileStat ¶
func (s LocalFunctionStat) CompileStat(c *ir.Compiler)
func (LocalFunctionStat) HWrite ¶
func (s LocalFunctionStat) HWrite(w HWriter)
type Location ¶
type Location struct {
// contains filtered or unexported fields
}
func LocFromToken ¶
func LocFromTokens ¶
func MergeLocations ¶
type Name ¶
func (Name) FunctionName ¶
type NoTableKey ¶
type NoTableKey struct {
Location
}
func (NoTableKey) CompileExp ¶
func (NoTableKey) HWrite ¶
func (k NoTableKey) HWrite(w HWriter)
type NumberOracle ¶
type NumberOracle interface {
IsNumber() bool
}
type ParList ¶
func NewParList ¶
type RepeatStat ¶
RepeatStat represents a repeat / until statement.
func NewRepeatStat ¶
func NewRepeatStat(repTok *token.Token, body BlockStat, cond ExpNode) RepeatStat
func (RepeatStat) CompileStat ¶
func (s RepeatStat) CompileStat(c *ir.Compiler)
CompileStat implements Stat.CompileStat.
func (RepeatStat) HWrite ¶
func (s RepeatStat) HWrite(w HWriter)
type String ¶
String is a string literal.
func NewLongString ¶
type TableConstructor ¶
type TableConstructor struct { Location Fields []TableField }
func NewTableConstructor ¶
func NewTableConstructor(opTok, clTok *token.Token, fields []TableField) TableConstructor
func (TableConstructor) CompileExp ¶
func (TableConstructor) HWrite ¶
func (c TableConstructor) HWrite(w HWriter)
type TableField ¶
func NewTableField ¶
func NewTableField(key ExpNode, value ExpNode) TableField
type TailExpNode ¶
type TailExpNode interface { Node CompileTailExp(*ir.Compiler, []ir.Register) CompileEtcExp(*ir.Compiler, ir.Register) ir.Register }
TailExpNode is an expression which can be the tail of an exp list
type WhileStat ¶
WhileStat represents a while / end statement
func NewWhileStat ¶
func (WhileStat) CompileStat ¶
CompileStat implements Stat.CompileStat.
Source Files ¶
- assignstat.go
- binopexp.go
- blockstat.go
- bool.go
- breakstat.go
- condstat.go
- emptystat.go
- etc.go
- expnode.go
- forinstat.go
- forstat.go
- function.go
- functioncall.go
- functionstat.go
- gotostat.go
- ifstat.go
- indentwriter.go
- indexexp.go
- labelstat.go
- localfunctionstat.go
- localstat.go
- name.go
- nil.go
- node.go
- number.go
- repeatstat.go
- string.go
- tableconstructor.go
- unopexp.go
- whilestat.go