gc

package
v0.0.0-...-209b98f Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OBJ_INT = iota
	OBJ_PAIR
)
View Source
const (
	// INITIAL_GC_THRESHOLD determines the number of objects required
	// initially to trigger the GC (it is currently chosen arbitrarily).
	// This threshold is modified at the end of each GC cycle to be twice
	// the number of live objects. This ensures that the GC is not triggered
	// frequently or infrequently.
	INITIAL_GC_THRESHOLD = 36
	// STACK_MAX determines the maximum number of live objects at any given
	// instant, preventing stack overflow.
	// TODO: adjust this to a nice value.
	STACK_MAX = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ObjInt

type ObjInt int

type ObjPair

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

type Object

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

type ObjectType

type ObjectType uint8

type VM

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

VM represents a minimal stack-based virtual machine structure. It's sole purpose at the moment is to keep track of all the live objects.

func NewVM

func NewVM() *VM

NewVM creates a new VM object.

func (*VM) FreeVM

func (vm *VM) FreeVM()

FreeVM collects all the live objects in the VM.

func (*VM) MarkAll

func (vm *VM) MarkAll()

MarkAll marks all the objects as live.

func (*VM) NewObject

func (vm *VM) NewObject(typ ObjectType) *Object

NewObject creates a new Object.

func (*VM) Pop

func (vm *VM) Pop() *Object

Pop removes a live object, effectively marking it as dead.

func (*VM) Push

func (vm *VM) Push(value *Object)

Push inserts a new live object into the VM stack.

func (*VM) PushInt

func (vm *VM) PushInt(intval int)

PushInt pushes an object into the stack.

func (*VM) PushPair

func (vm *VM) PushPair() *Object

PushPair pushes a pair of objects (references) into the stack.

Jump to

Keyboard shortcuts

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