vm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

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"
)

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 ...data.Value) data.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 data.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 ...data.Value) data.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 data.Value) bool

Equal compares this Procedure to another for equality

func (*Procedure) Get

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

func (*Procedure) HashCode

func (p *Procedure) HashCode() uint64

func (*Procedure) Type

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

Type makes Procedure a typed value

type Ref

type Ref struct {
	data.Value
}

Ref encapsulates a reference to a Value

func (*Ref) Equal

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

Jump to

Keyboard shortcuts

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