ir

package
v0.0.0-...-9dcd13a Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrTakeNothing inputMode = iota
	AttrTake1
	AttrTake2
	AttrTake3
	AttrTakeN
	AttrTakeNplus1
	AttrReplaceNth
)
View Source
const (
	AttrPushNothing outputMode = iota
	AttrDupNth
	AttrPushTmp
	AttrPushConst
	AttrPushAndDiscard
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoding

type Encoding struct {
	Name   []byte
	HasArg bool
	Input  inputMode
	Output outputMode
}

func EncodingOf

func EncodingOf(kind InstrKind) *Encoding

type Instr

type Instr struct {
	Kind InstrKind // Determines the instruction kind
	Data int32     // Instruction direct argument (optional)
	Meta string    // Additional instruction data (optional)
	Prev *Instr    // Previous instruction
	Next *Instr    // Next instruction
}

Instr is a single IR instruction.

func (*Instr) InsertLeft

func (ins *Instr) InsertLeft(span []*Instr)

InsertLeft calls InsertPrev consequentially for each passed instruction. E.g.: [prev ins next].InsertLeft([a b]) => [prev a b ins next].

func (*Instr) InsertNext

func (ins *Instr) InsertNext(newNext *Instr)

InsertNext adds instruction after current position.

func (*Instr) InsertPrev

func (ins *Instr) InsertPrev(newPrev *Instr)

InsertPrev adds instruction before current position.

func (*Instr) InsertRight

func (ins *Instr) InsertRight(span []*Instr)

InsertRight calls InsertNext consequentially for each passed instruction. E.g.: [prev ins next].InsertRight([a b]) => [prev ins a b next].

func (*Instr) Remove

func (ins *Instr) Remove()

Remove destroys instruction object by removing it from instruction list.

type InstrKind

type InstrKind int32
const (
	Empty InstrKind = iota

	XvarRef
	XvarSet
	XlocalRef
	XlocalSet
	Xbind
	XscopeEnter
	XscopeLeave
	Xgoto
	XlambdaEnter
	XlambdaRetLabel
	XlambdaRet

	Label
	Jmp              // "goto"
	JmpNil           // "gotoifnil"
	JmpNotNil        // "gotoifnonnil"
	JmpNilElsePop    // "gotoifnilelsepop"
	JmpNotNilElsePop // "gotoifnonnilelsepop"

	Return
	Call

	Eq
	Equal
	Substring // "substring"
	Length

	NumEq  // "eqlsign"
	NumLt  // "lss"
	NumGt  // "gtr"
	NumLte // "leq"
	NumGte // "geq"
	Add    // "plus"
	Sub    // "diff"
	Mul    // "mult"
	Quo
	Add1
	Sub1
	Min
	Neg // "negate"

	StrEq // "stringeqlsign"
	StrLt // "stringlss"
	Concat

	Aref
	Aset

	Car
	Cdr
	SetCar
	SetCdr
	Cons
	List
	Memq
	Member

	Stringp
	Integerp
	Symbolp
	Not

	ConstRef
	StackRef
	StackSet
	Discard
	VarRef
	VarSet
)

type InstrPusher

type InstrPusher Unit

func (*InstrPusher) Add

func (p *InstrPusher) Add()

func (*InstrPusher) Add1

func (p *InstrPusher) Add1()

func (*InstrPusher) Aref

func (p *InstrPusher) Aref()

func (*InstrPusher) Aset

func (p *InstrPusher) Aset()

func (*InstrPusher) Call

func (p *InstrPusher) Call(argc int, name string)

func (*InstrPusher) Car

func (p *InstrPusher) Car()

func (*InstrPusher) Cdr

func (p *InstrPusher) Cdr()

func (*InstrPusher) Concat

func (p *InstrPusher) Concat(argc int)

func (*InstrPusher) Cons

func (p *InstrPusher) Cons()

func (*InstrPusher) ConstRef

func (p *InstrPusher) ConstRef(cvIndex int)

func (*InstrPusher) Discard

func (p *InstrPusher) Discard(n int)

func (*InstrPusher) Empty

func (p *InstrPusher) Empty()

func (*InstrPusher) Eq

func (p *InstrPusher) Eq()

func (*InstrPusher) Equal

func (p *InstrPusher) Equal()

func (*InstrPusher) Integerp

func (p *InstrPusher) Integerp()

func (*InstrPusher) Jmp

func (p *InstrPusher) Jmp(label Instr)

func (*InstrPusher) JmpNil

func (p *InstrPusher) JmpNil(label Instr)

func (*InstrPusher) JmpNilElsePop

func (p *InstrPusher) JmpNilElsePop(label Instr)

func (*InstrPusher) JmpNotNil

func (p *InstrPusher) JmpNotNil(label Instr)

func (*InstrPusher) JmpNotNilElsePop

func (p *InstrPusher) JmpNotNilElsePop(label Instr)

func (*InstrPusher) Label

func (p *InstrPusher) Label(label Instr)

func (*InstrPusher) Length

func (p *InstrPusher) Length()

func (*InstrPusher) List

func (p *InstrPusher) List(n int)

func (*InstrPusher) Member

func (p *InstrPusher) Member()

func (*InstrPusher) Memq

func (p *InstrPusher) Memq()

func (*InstrPusher) Min

func (p *InstrPusher) Min()

func (*InstrPusher) Mul

func (p *InstrPusher) Mul()

func (*InstrPusher) Neg

func (p *InstrPusher) Neg()

func (*InstrPusher) Not

func (p *InstrPusher) Not()

func (*InstrPusher) NumEq

func (p *InstrPusher) NumEq()

func (*InstrPusher) NumGt

func (p *InstrPusher) NumGt()

func (*InstrPusher) NumGte

func (p *InstrPusher) NumGte()

func (*InstrPusher) NumLt

func (p *InstrPusher) NumLt()

func (*InstrPusher) NumLte

func (p *InstrPusher) NumLte()

func (*InstrPusher) PushInstr

func (p *InstrPusher) PushInstr(ins Instr)

func (*InstrPusher) Quo

func (p *InstrPusher) Quo()

func (*InstrPusher) Return

func (p *InstrPusher) Return()

func (*InstrPusher) SetCar

func (p *InstrPusher) SetCar()

func (*InstrPusher) SetCdr

func (p *InstrPusher) SetCdr()

func (*InstrPusher) StackRef

func (p *InstrPusher) StackRef(stIndex int)

func (*InstrPusher) StackSet

func (p *InstrPusher) StackSet(stIndex int)

func (*InstrPusher) StrEq

func (p *InstrPusher) StrEq()

func (*InstrPusher) StrLt

func (p *InstrPusher) StrLt()

func (*InstrPusher) Stringp

func (p *InstrPusher) Stringp()

func (*InstrPusher) Sub

func (p *InstrPusher) Sub()

func (*InstrPusher) Sub1

func (p *InstrPusher) Sub1()

func (*InstrPusher) Substring

func (p *InstrPusher) Substring()

func (*InstrPusher) Symbolp

func (p *InstrPusher) Symbolp()

func (*InstrPusher) VarRef

func (p *InstrPusher) VarRef(cvIndex int)

func (*InstrPusher) VarSet

func (p *InstrPusher) VarSet(cvIndex int)

func (*InstrPusher) Xbind

func (p *InstrPusher) Xbind(name string)

func (*InstrPusher) Xgoto

func (p *InstrPusher) Xgoto(label Instr)

func (*InstrPusher) XlambdaEnter

func (p *InstrPusher) XlambdaEnter()

func (*InstrPusher) XlambdaRet

func (p *InstrPusher) XlambdaRet(label Instr)

func (*InstrPusher) XlocalRef

func (p *InstrPusher) XlocalRef(name string)

func (*InstrPusher) XlocalSet

func (p *InstrPusher) XlocalSet(name string)

func (*InstrPusher) XscopeEnter

func (p *InstrPusher) XscopeEnter()

func (*InstrPusher) XscopeLeave

func (p *InstrPusher) XscopeLeave()

func (*InstrPusher) XvarRef

func (p *InstrPusher) XvarRef(name string)

func (*InstrPusher) XvarSet

func (p *InstrPusher) XvarSet(name string)

type Unit

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

func NewUnit

func NewUnit() *Unit

func (*Unit) Init

func (u *Unit) Init()

func (*Unit) InstrPusher

func (u *Unit) InstrPusher() *InstrPusher

func (*Unit) NewLabel

func (u *Unit) NewLabel(name string) Instr

func (*Unit) NewLambdaRetLabel

func (u *Unit) NewLambdaRetLabel() Instr

func (*Unit) NewUserLabel

func (u *Unit) NewUserLabel(name string) Instr

func (*Unit) Result

func (u *Unit) Result() *Instr

Jump to

Keyboard shortcuts

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