code

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Make

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

Returns the resulting bytecode from parsing the instruction.

func ReadOperands

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

Decodes the operands of a bytecode instruction.

func ReadUint16

func ReadUint16(ins Instructions) uint16

func ReadUint32

func ReadUint32(ins Instructions) uint32

func ReadUint64

func ReadUint64(ins Instructions) uint64

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 (
	OpHalt Opcode = iota
	OpPop

	OpConstant
	OpTrue
	OpFalse
	OpNull
	OpList
	OpMap
	OpClosure
	OpCurrentClosure

	OpAdd
	OpSub
	OpMul
	OpDiv
	OpMod

	OpBwAnd
	OpBwOr
	OpBwXor
	OpBwNot
	OpBwLShift
	OpBwRShift

	OpAnd
	OpOr
	OpEqual
	OpNotEqual
	OpGreaterThan
	OpGreaterThanEqual

	OpMinus
	OpBang
	OpIndex

	OpCall
	OpConcurrentCall
	OpReturn
	OpReturnValue

	OpJump
	OpJumpNotTruthy

	OpDot
	OpDefine
	OpGetGlobal
	OpSetGlobal
	OpGetLocal
	OpSetLocal
	OpGetBuiltin
	OpGetFree
	OpLoadModule
	OpInterpolate
)

func (Opcode) String added in v1.2.0

func (i Opcode) String() string

Jump to

Keyboard shortcuts

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