vm

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package vm provides virtual machine implementation

Index

Constants

View Source
const (
	// ErrBadInstruction is raised when the VM encounters an Opcode that has
	// not been properly mapped
	ErrBadInstruction = "unknown instruction encountered: %s"

	// ErrEmptyArgStack is raised when the VM encounters an instruction to pop
	// the argument stack, but the head of the stack is empty
	ErrEmptyArgStack = "attempt to pop empty argument stack"

	// ErrUnexpectedLabel is raised when the VM encounters a label that should
	// have otherwise been stripped when the instructions were made Runnable
	ErrUnexpectedLabel = "unexpected label encountered: %d"

	// ErrUnexpectedNoOp is raised when the VM encounters a NoOp instruction
	// that should have been stripped when the instructions were made Runnable
	ErrUnexpectedNoOp = "unexpected no-op encountered"
)

Error messages

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocator

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

func NewAllocator

func NewAllocator() *Allocator

func (*Allocator) Free

func (a *Allocator) Free(vals data.Vector)

func (*Allocator) Malloc

func (a *Allocator) Malloc(size int) data.Vector

type Closure

type Closure struct {
	*Procedure
	// contains filtered or unexported fields
}

func (*Closure) Call

func (c *Closure) Call(args ...ale.Value) ale.Value

Call turns Closure into a Procedure, and serves as the virtual machine

func (*Closure) Captured

func (c *Closure) Captured() data.Vector

Captured returns the captured values of a Closure

func (*Closure) CheckArity

func (c *Closure) CheckArity(i int) error

CheckArity performs a compile-time arity check for the Closure

func (*Closure) Equal

func (c *Closure) Equal(other ale.Value) bool

func (*Closure) HashCode

func (c *Closure) HashCode() uint64

type Procedure

type Procedure struct {
	ArityChecker data.ArityChecker
	isa.Runnable
	// contains filtered or unexported fields
}

Procedure encapsulates the initial environment of an abstract machine

func MakeProcedure

func MakeProcedure(run *isa.Runnable, arity data.ArityChecker) *Procedure

func (*Procedure) Call

func (p *Procedure) Call(values ...ale.Value) ale.Value

Call allows an abstract machine Procedure to be called to instantiate a Closure. Only the compiler invokes this calling interface.

func (*Procedure) CheckArity

func (p *Procedure) CheckArity(int) error

CheckArity performs a compile-time arity check for the Procedure

func (*Procedure) Equal

func (p *Procedure) Equal(other ale.Value) bool

Equal compares this Procedure to another for equality

func (*Procedure) Get

func (p *Procedure) Get(key ale.Value) (ale.Value, bool)

func (*Procedure) HashCode

func (p *Procedure) HashCode() uint64

func (*Procedure) Type

func (p *Procedure) Type() ale.Type

Type makes Procedure a typed value

type Ref

type Ref struct {
	ale.Value
}

Ref encapsulates a reference to a Value

func (*Ref) Equal

func (r *Ref) Equal(other ale.Value) bool

Jump to

Keyboard shortcuts

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