code

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpCodeToOperatorMap = map[Opcode]string{
	OpAdd:            token.Plus,
	OpSub:            token.Minus,
	OpMul:            token.Asterisk,
	OpDiv:            token.Slash,
	OpMod:            token.Percent,
	OpGreaterThan:    token.GreaterThan,
	OpGreaterOrEqual: token.GreaterOrEqual,
	OpEqual:          token.Equal,
	OpNotEqual:       token.NotEqual,
}

Functions

func Make

func Make(op Opcode, operands ...int) []byte

func ReadOperands

func ReadOperands(def *Definition, ins Instructions) ([]int, int)

func ReadUint16

func ReadUint16(ins Instructions) uint16

func ReadUint8

func ReadUint8(ins Instructions) uint8

Types

type Definition

type Definition struct {
	Name          string
	OperandWidths []int
}

func Lookup

func Lookup(op byte) (*Definition, error)

type Instructions

type Instructions []byte

func (Instructions) String

func (ins Instructions) String() string

type Opcode

type Opcode byte
const (
	OpConstant Opcode = iota

	OpPop

	OpAdd
	OpSub
	OpMul
	OpDiv
	OpMod

	OpTrue
	OpFalse

	OpEqual
	OpNotEqual
	OpGreaterThan
	OpGreaterOrEqual

	OpMinus
	OpBang

	OpJumpNotTruthy
	OpJump

	OpNull

	OpGetGlobal
	OpSetGlobal
	OpGetLocal
	OpSetLocal
	OpGetFree
	OpSetFree

	OpArray
	OpHash

	OpIndex
	OpIndexSet

	OpCall
	OpReturnValue
	OpReturn

	OpGetBuiltin
	OpClosure
	OpMember
	OpMemberSet

	OpExport
	OpScope
	OpScopeResolve
)

Jump to

Keyboard shortcuts

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