code

package
v5.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT 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

func ReadOperands

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

func ReadUint8

func ReadUint8(ins Instructions) uint8

func ReadUint16

func ReadUint16(ins Instructions) uint16

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

	OpAdd

	OpPop

	OpSub
	OpMul
	OpDiv

	OpTrue
	OpFalse

	OpEqual
	OpNotEqual
	OpGreaterThan

	OpMinus
	OpBang

	OpJumpNotTruthy
	OpJump

	OpNull

	OpGetGlobal
	OpSetGlobal

	OpArray
	OpHash
	OpIndex

	OpCall

	OpReturnValue
	OpReturn

	OpGetLocal
	OpSetLocal

	OpGetBuiltin

	OpClosure

	OpGetFree

	OpCurrentClosure

	// Plush extensions. These are appended after the core VM opcodes so their
	// numeric values remain stable.
	OpGreaterEqual
	OpMatches
	OpAnd
	OpOr
	OpGetName
	OpSetName
	OpAssignName
	OpGetProperty
	OpSetIndex
	OpWrite
	OpFor
	OpBreak
	OpContinue
	OpCallBlock
	OpRenderTemplate
	OpGetNameOrNull
	OpHole

	// Direct write opcodes are Plush fast paths. They fuse common
	// "load or call, then OpWrite" instruction pairs so rendering can write to
	// the frame output without unnecessary stack traffic. See vm/FAST_PATHS.md.
	OpWriteConstant
	OpWriteName
	OpWriteNameOrNull
	OpWriteLocal
	OpWriteGlobal
	OpWriteString
	OpWriteHTML
	OpWriteLocalProperty
	OpWriteGlobalProperty
	OpWriteNameProperty
	OpWriteCall
	OpWriteNameCall
)

Jump to

Keyboard shortcuts

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