vm

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StackSize  = 2048
	MaxFrames  = 1024
	MaxGlobals = 65536
)

Variables

View Source
var (
	True  = &object.Boolean{Value: true}
	False = &object.Boolean{Value: false}
	Null  = &object.Null{}
)

Functions

func ExecModule added in v1.3.0

func ExecModule(name string, state *VMState) (object.Object, error)

ExecModule compiles the named module and returns a *object.Module object

Types

type Frame

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

func NewFrame

func NewFrame(cl *object.Closure, basePointer int) *Frame

func (*Frame) Instructions

func (f *Frame) Instructions() code.Instructions

func (*Frame) NextOp

func (f *Frame) NextOp() code.Opcode

NextOp ...

type VM

type VM struct {
	Debug bool
	// contains filtered or unexported fields
}

func New

func New(bytecode *compiler.Bytecode) *VM

func NewWithState added in v1.3.0

func NewWithState(bytecode *compiler.Bytecode, state *VMState) *VM

func (*VM) LastPopped

func (vm *VM) LastPopped() object.Object

func (*VM) Run

func (vm *VM) Run() error

type VMState added in v1.3.0

type VMState struct {
	Constants []object.Object
	Globals   []object.Object
	Symbols   *compiler.SymbolTable
}

func NewVMState added in v1.3.0

func NewVMState() *VMState

func (*VMState) ExportedHash added in v1.3.0

func (s *VMState) ExportedHash() *object.Hash

ExportedHash returns a new Hash with the names and values of every publically exported binding in the vm state. That is every binding that starts with a capital letter. This is used by the module import system to wrap up the compiled and evaulated module into an object.

Jump to

Keyboard shortcuts

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