ir

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitConstant

func EmitConstant(c *Compiler, k Constant, reg Register, line int)

func EmitMove

func EmitMove(c *Compiler, dst Register, src Register, line int)

func EmitMoveNoLine

func EmitMoveNoLine(c *Compiler, dst Register, src Register)

Types

type Bool

type Bool bool

func (Bool) Compile

func (b Bool) Compile(kc *ConstantCompiler) code.Constant

type Call

type Call struct {
	Cont Register
}

func (Call) Compile

func (c Call) Compile(kc InstrCompiler)

func (Call) String

func (c Call) String() string

type ClearReg

type ClearReg struct {
	Dst Register
}

func (ClearReg) Compile

func (i ClearReg) Compile(kc InstrCompiler)

func (ClearReg) String

func (i ClearReg) String() string

type Code

type Code struct {
	Instructions []Instruction
	Lines        []int
	Constants    []Constant
	RegCount     int16
	UpvalueCount int16
	UpNames      []string
	LabelPos     map[int][]Label
	Name         string
}

func (*Code) Compile

func (c *Code) Compile(kc *ConstantCompiler) code.Constant

type Combine

type Combine struct {
	Op   ops.Op
	Dst  Register
	Lsrc Register
	Rsrc Register
}

func (Combine) Compile

func (c Combine) Compile(kc InstrCompiler)

func (Combine) String

func (c Combine) String() string

type Compiler

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

func NewCompiler

func NewCompiler(source string) *Compiler

func (*Compiler) DeclareGotoLabel

func (c *Compiler) DeclareGotoLabel(name Name) Label

func (*Compiler) DeclareLocal

func (c *Compiler) DeclareLocal(name Name, reg Register)

func (*Compiler) Dump

func (c *Compiler) Dump()

func (*Compiler) Emit

func (c *Compiler) Emit(instr Instruction, line int)

func (*Compiler) EmitGotoLabel

func (c *Compiler) EmitGotoLabel(name Name)

func (*Compiler) EmitJump

func (c *Compiler) EmitJump(lblName Name, line int)

func (*Compiler) EmitLabel

func (c *Compiler) EmitLabel(lbl Label)

func (*Compiler) EmitNoLine

func (c *Compiler) EmitNoLine(instr Instruction)

func (*Compiler) GetCode

func (c *Compiler) GetCode(name string) *Code

func (*Compiler) GetConstant

func (c *Compiler) GetConstant(k Constant) uint

func (*Compiler) GetFreeRegister

func (c *Compiler) GetFreeRegister() Register

func (*Compiler) GetGotoLabel

func (c *Compiler) GetGotoLabel(name Name) (Label, bool)

func (*Compiler) GetNewLabel

func (c *Compiler) GetNewLabel() Label

func (*Compiler) GetRegister

func (c *Compiler) GetRegister(name Name) (Register, bool)

func (*Compiler) NewChild

func (c *Compiler) NewChild() *Compiler

func (*Compiler) NewConstantCompiler

func (c *Compiler) NewConstantCompiler() *ConstantCompiler

func (*Compiler) PopContext

func (c *Compiler) PopContext()

func (*Compiler) PushContext

func (c *Compiler) PushContext()

func (*Compiler) ReleaseRegister

func (c *Compiler) ReleaseRegister(reg Register)

func (*Compiler) TakeRegister

func (c *Compiler) TakeRegister(reg Register)

func (*Compiler) Upvalues

func (c *Compiler) Upvalues() []Register

type Constant

type Constant interface {
	Compile(*ConstantCompiler) code.Constant
}

type ConstantCompiler

type ConstantCompiler struct {
	*code.Compiler
	// contains filtered or unexported fields
}

func (*ConstantCompiler) CompileQueue

func (kc *ConstantCompiler) CompileQueue() *code.Unit

func (*ConstantCompiler) GetConstant

func (kc *ConstantCompiler) GetConstant(ki uint) Constant

func (*ConstantCompiler) QueueConstant

func (kc *ConstantCompiler) QueueConstant(ki uint) int

type ConstantPool

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

func (*ConstantPool) Constants

func (c *ConstantPool) Constants() []Constant

func (*ConstantPool) GetConstant

func (c *ConstantPool) GetConstant(k Constant) uint

type EtcLookup

type EtcLookup struct {
	Etc Register
	Dst Register
	Idx int
}

func (EtcLookup) Compile

func (l EtcLookup) Compile(kc InstrCompiler)

func (EtcLookup) String

func (l EtcLookup) String() string

type FillTable

type FillTable struct {
	Etc Register
	Dst Register
	Idx int
}

func (FillTable) Compile

func (f FillTable) Compile(kc InstrCompiler)

func (FillTable) String

func (f FillTable) String() string

type Float

type Float float64

func (Float) Compile

func (f Float) Compile(kc *ConstantCompiler) code.Constant

type InstrCompiler

type InstrCompiler struct {
	*ConstantCompiler
	// contains filtered or unexported fields
}

func (InstrCompiler) Emit

func (ic InstrCompiler) Emit(opcode code.Opcode)

func (InstrCompiler) EmitJump

func (ic InstrCompiler) EmitJump(opcode code.Opcode, lbl code.Label)

type Instruction

type Instruction interface {
	fmt.Stringer
	Compile(InstrCompiler)
}

type Int

type Int int64

func (Int) Compile

func (n Int) Compile(kc *ConstantCompiler) code.Constant

type Jump

type Jump struct {
	Label Label
}

func (Jump) Compile

func (j Jump) Compile(kc InstrCompiler)

func (Jump) String

func (j Jump) String() string

type JumpIf

type JumpIf struct {
	Cond  Register
	Label Label
	Not   bool
}

func (JumpIf) Compile

func (j JumpIf) Compile(kc InstrCompiler)

func (JumpIf) String

func (j JumpIf) String() string

type JumpIfForLoopDone

type JumpIfForLoopDone struct {
	Label Label
	Var   Register
	Limit Register
	Step  Register
}

func (JumpIfForLoopDone) Compile

func (j JumpIfForLoopDone) Compile(kc InstrCompiler)

func (JumpIfForLoopDone) String

func (j JumpIfForLoopDone) String() string

type Label

type Label uint

func (Label) String

func (l Label) String() string

type LexicalContext

type LexicalContext []lexicalMap

func (LexicalContext) AddLabel

func (c LexicalContext) AddLabel(name Name, label Label) (ok bool)

func (LexicalContext) AddToRoot

func (c LexicalContext) AddToRoot(name Name, reg Register) (ok bool)

func (LexicalContext) AddToTop

func (c LexicalContext) AddToTop(name Name, reg Register) (ok bool)

func (LexicalContext) Dump

func (c LexicalContext) Dump()

func (LexicalContext) GetLabel

func (c LexicalContext) GetLabel(name Name) (label Label, ok bool)

func (LexicalContext) GetRegister

func (c LexicalContext) GetRegister(name Name, tags uint) (reg Register, ok bool)

func (LexicalContext) Pop

func (c LexicalContext) Pop() (LexicalContext, lexicalMap)

func (LexicalContext) PushNew

func (c LexicalContext) PushNew() LexicalContext

func (LexicalContext) Top

func (c LexicalContext) Top() lexicalMap

type LoadConst

type LoadConst struct {
	Dst  Register
	Kidx uint
}

func (LoadConst) Compile

func (l LoadConst) Compile(kc InstrCompiler)

func (LoadConst) String

func (l LoadConst) String() string

type Lookup

type Lookup struct {
	Dst   Register
	Table Register
	Index Register
}

func (Lookup) Compile

func (s Lookup) Compile(kc InstrCompiler)

func (Lookup) String

func (s Lookup) String() string

type MkClosure

type MkClosure struct {
	Dst      Register
	Code     uint
	Upvalues []Register
}

func (MkClosure) Compile

func (m MkClosure) Compile(kc InstrCompiler)

func (MkClosure) String

func (m MkClosure) String() string

type MkCont

type MkCont struct {
	Dst     Register
	Closure Register
	Tail    bool
}

func (MkCont) Compile

func (m MkCont) Compile(kc InstrCompiler)

func (MkCont) String

func (m MkCont) String() string

type MkTable

type MkTable struct {
	Dst Register
}

func (MkTable) Compile

func (m MkTable) Compile(kc InstrCompiler)

func (MkTable) String

func (m MkTable) String() string

type Name

type Name string

type NilType

type NilType struct{}

func (NilType) Compile

func (n NilType) Compile(kc *ConstantCompiler) code.Constant

type Push

type Push struct {
	Cont Register
	Item Register
	Etc  bool
}

func (Push) Compile

func (p Push) Compile(kc InstrCompiler)

func (Push) String

func (p Push) String() string

type PushCC

type PushCC struct {
	Cont Register
}

func (PushCC) Compile

func (p PushCC) Compile(kc InstrCompiler)

func (PushCC) String

func (p PushCC) String() string

type Receive

type Receive struct {
	Dst []Register
}

func (Receive) Compile

func (r Receive) Compile(kc InstrCompiler)

func (Receive) String

func (r Receive) String() string

type ReceiveEtc

type ReceiveEtc struct {
	Dst []Register
	Etc Register
}

func (ReceiveEtc) Compile

func (r ReceiveEtc) Compile(kc InstrCompiler)

func (ReceiveEtc) String

func (r ReceiveEtc) String() string

type Register

type Register int

func (Register) String

func (r Register) String() string

type SetIndex

type SetIndex struct {
	Table Register
	Index Register
	Src   Register
}

func (SetIndex) Compile

func (s SetIndex) Compile(kc InstrCompiler)

func (SetIndex) String

func (s SetIndex) String() string

type String

type String string

func (String) Compile

func (s String) Compile(kc *ConstantCompiler) code.Constant

type Transform

type Transform struct {
	Op  ops.Op
	Dst Register
	Src Register
}

func (Transform) Compile

func (t Transform) Compile(kc InstrCompiler)

func (Transform) String

func (t Transform) String() string

Jump to

Keyboard shortcuts

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