instr

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
)
View Source
const (
	AttrEnc0 encoding = iota
	AttrEnc1
)

Variables

View Source
var (
	Jmp              = []byte("goto")
	JmpNil           = []byte("goto-if-nil")
	JmpNotNil        = []byte("goto-if-not-nil")
	JmpNilElsePop    = []byte("goto-if-nil-else-pop")
	JmpNotNilElsePop = []byte("goto-if-not-nil-else-pop")
	Label            = []byte("label")
)

Jump instruction names.

View Source
var (
	Eq    = binOp("eq")
	Equal = binOp("equal")

	NumEq    = binOp("num=")
	NumGt    = binOp("num>")
	NumLt    = binOp("num<")
	NumLte   = binOp("num<=")
	NumGte   = binOp("num>=")
	NumSub   = binOp("sub")
	NumAdd   = binOp("add")
	NumMul   = binOp("mul")
	NumQuo   = binOp("quo")
	NumMin   = binOp("min")
	StrEq    = binOp("str=")
	StrLt    = binOp("str<")
	ArrayRef = binOp("array-ref")

	Cons   = binOp("cons")
	Memq   = binOp("memq")
	Member = binOp("member")

	Concat2 = Concat(2)
)

Binary ops.

View Source
var (
	IsStr    = unaryOp("str?")
	IsInt    = unaryOp("int?")
	IsSymbol = unaryOp("symbol?")

	Add1 = unaryOp("add1")
	Sub1 = unaryOp("sub1")

	Not = unaryOp("not")
	Neg = unaryOp("neg")

	Car = unaryOp("car")
	Cdr = unaryOp("cdr")

	Length = unaryOp("length")
)

Unary ops.

View Source
var (
	ArraySet = Instr{
		Name:     []byte("array-set"),
		Encoding: AttrEnc0,
		Input:    AttrTake3,
		Output:   AttrPushAndDiscard,
	}

	Return = Instr{
		Name:     []byte("return"),
		Encoding: AttrEnc0,
		Input:    AttrTake1,
	}

	Substr = Instr{
		Name:     []byte("substr"),
		Encoding: AttrEnc0,
		Input:    AttrTake3,
		Output:   AttrPushTmp,
	}
	SetCar = Instr{
		Name:     []byte("setcar"),
		Encoding: AttrEnc0,
		Input:    AttrTake2,
		Output:   AttrPushAndDiscard,
	}
	SetCdr = Instr{
		Name:     []byte("setcdr"),
		Encoding: AttrEnc0,
		Input:    AttrTake2,
		Output:   AttrPushAndDiscard,
	}
)

Other ops without explicit parameter.

Functions

This section is empty.

Types

type Instr

type Instr struct {
	Name     []byte
	Encoding encoding
	Input    inputMode
	Output   outputMode
	Data     uint16
}

Instr is a single IR instruction.

func Call

func Call(argc int) Instr

func Concat

func Concat(argc int) Instr

func ConstRef

func ConstRef(cvIndex int) Instr

func Discard

func Discard(n int) Instr

func List

func List(argc int) Instr

func StackRef

func StackRef(stIndex int) Instr

func StackSet

func StackSet(stIndex int) Instr

func VarRef

func VarRef(cvIndex int) Instr

func VarSet

func VarSet(cvIndex int) Instr

Jump to

Keyboard shortcuts

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