Documentation ¶
Index ¶
- func RunVM(opcodes []byte, console VMConsole) int64
- type AddExp
- type AstNode
- type AstNodeType
- type BoolLiteral
- type DefExp
- type DivExp
- type EqExp
- type FloatLiteral
- type GtExp
- type GteExp
- type IdentExp
- type IfExp
- type IntLiteral
- type LambdaExp
- type LtExp
- type LteExp
- type MulExp
- type Program
- type SExp
- type StringLiteral
- type SubExp
- type Token
- type TokenType
- type VMConsole
- type VMHeap
- func (h *VMHeap) Allocate(numBytes uint64) uint64
- func (h *VMHeap) AllocateRootBlock(heapSize uint64)
- func (h *VMHeap) CreateBlock(order uint8)
- func (h *VMHeap) Free(address uint64)
- func (h *VMHeap) GetBuddyAddress(address uint64, order uint8) uint64
- func (h *VMHeap) GetFreeBlock(order uint8) uint64
- func (h *VMHeap) GetUnusedBlockIndex(address uint64, order uint8) int
- func (h *VMHeap) HasBuddy(address uint64, order uint8) bool
- func (h *VMHeap) MergeWithBuddy(address uint64, order uint8)
- func (h *VMHeap) NoFreeBlocksFor(order uint8) bool
- func (h *VMHeap) OrderFor(requestedBytes uint64) uint8
- func (h *VMHeap) Read(numBytes uint64, address uint64) *bytes.Buffer
- func (h *VMHeap) ReadString(address uint64) []byte
- func (h *VMHeap) RemoveBlockFromUnused(index int, order uint8)
- func (h *VMHeap) SplitBlock(address uint64, order uint8)
- func (h *VMHeap) Write(data *bytes.Buffer, address uint64)
- type VMStack
- func (s *VMStack) Dup()
- func (s VMStack) Length() uint64
- func (s *VMStack) PopByte() byte
- func (s *VMStack) PopCell() []uint64
- func (s *VMStack) PopDouble() float64
- func (s *VMStack) PopInt() int64
- func (s *VMStack) PopString() []byte
- func (s *VMStack) PushByte(newValue byte)
- func (s *VMStack) PushCell(cell []byte)
- func (s *VMStack) PushDouble(doubleBytes []byte)
- func (s *VMStack) PushEmptyCell()
- func (s *VMStack) PushInt(intBytes []byte)
- func (s *VMStack) PushString(runeBytes []byte)
- type VMState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddExp ¶
type AddExp struct {
SExp
}
func (AddExp) DebugString ¶
func (AddExp) GetType ¶
func (a AddExp) GetType() AstNodeType
type AstNode ¶
type AstNode interface { GetSubNodes() []AstNode AddSubNode(AstNode) GetType() AstNodeType DebugString() string }
base interface for functions needing to accept any kind of AST node
type AstNodeType ¶
type AstNodeType int
const ( ProgramNode AstNodeType = iota AddNode SubNode MulNode DivNode GtNode LtNode GteNode LteNode EqNode IfNode DefNode LambdaNode IdentNode IntNode FloatNode StringNode BoolNode )
type BoolLiteral ¶
func NewBoolLiteral ¶
func NewBoolLiteral(value bool) *BoolLiteral
func (BoolLiteral) DebugString ¶
func (b BoolLiteral) DebugString() string
func (BoolLiteral) GetType ¶
func (b BoolLiteral) GetType() AstNodeType
type DefExp ¶
func (DefExp) DebugString ¶
func (DefExp) GetType ¶
func (d DefExp) GetType() AstNodeType
type DivExp ¶
type DivExp struct {
SExp
}
func (DivExp) DebugString ¶
func (DivExp) GetType ¶
func (d DivExp) GetType() AstNodeType
type EqExp ¶
type EqExp struct {
SExp
}
func (EqExp) DebugString ¶
func (EqExp) GetType ¶
func (e EqExp) GetType() AstNodeType
type FloatLiteral ¶
func NewFloatLiteral ¶
func NewFloatLiteral(value float64) *FloatLiteral
func (FloatLiteral) DebugString ¶
func (f FloatLiteral) DebugString() string
func (FloatLiteral) GetType ¶
func (f FloatLiteral) GetType() AstNodeType
type GtExp ¶
type GtExp struct {
SExp
}
func (GtExp) DebugString ¶
func (GtExp) GetType ¶
func (g GtExp) GetType() AstNodeType
type GteExp ¶
type GteExp struct {
SExp
}
func (GteExp) DebugString ¶
func (GteExp) GetType ¶
func (g GteExp) GetType() AstNodeType
type IdentExp ¶
func NewIdentExp ¶
func (IdentExp) DebugString ¶
func (IdentExp) GetType ¶
func (i IdentExp) GetType() AstNodeType
type IfExp ¶
type IfExp struct {
SExp
}
func (IfExp) DebugString ¶
func (IfExp) GetType ¶
func (i IfExp) GetType() AstNodeType
type IntLiteral ¶
func NewIntLiteral ¶
func NewIntLiteral(value int64) *IntLiteral
func (IntLiteral) DebugString ¶
func (i IntLiteral) DebugString() string
func (IntLiteral) GetType ¶
func (i IntLiteral) GetType() AstNodeType
type LambdaExp ¶
func NewLambdaExp ¶
func (LambdaExp) DebugString ¶
func (LambdaExp) GetType ¶
func (l LambdaExp) GetType() AstNodeType
type LtExp ¶
type LtExp struct {
SExp
}
func (LtExp) DebugString ¶
func (LtExp) GetType ¶
func (l LtExp) GetType() AstNodeType
type LteExp ¶
type LteExp struct {
SExp
}
func (LteExp) DebugString ¶
func (LteExp) GetType ¶
func (l LteExp) GetType() AstNodeType
type MulExp ¶
type MulExp struct {
SExp
}
func (MulExp) DebugString ¶
func (MulExp) GetType ¶
func (m MulExp) GetType() AstNodeType
type Program ¶
type Program struct {
SExp
}
func NewProgram ¶
func ParseTokens ¶
ParseTokens takes tokens and returns an AST (Abstract Syntax Tree) representation
func (Program) GetType ¶
func (p Program) GetType() AstNodeType
type SExp ¶
type SExp struct {
// contains filtered or unexported fields
}
base struct that all AST node implementations build off of
func (*SExp) AddSubNode ¶
func (*SExp) GetSubNodes ¶
type StringLiteral ¶
func NewStringLiteral ¶
func NewStringLiteral(value string) *StringLiteral
func (StringLiteral) DebugString ¶
func (s StringLiteral) DebugString() string
func (StringLiteral) GetType ¶
func (s StringLiteral) GetType() AstNodeType
type SubExp ¶
type SubExp struct {
SExp
}
func (SubExp) DebugString ¶
func (SubExp) GetType ¶
func (s SubExp) GetType() AstNodeType
type Token ¶
func LexExp ¶
LexExp lexes an input string into Token objects. There are no possible user-facing errors from this process.
func NewTokenRaw ¶
NewTokenRaw creates a new token from a raw Buffer.
func NewTokenString ¶
NewTokenString is a convenience function that returns a token with a given string value.
type VMConsole ¶
type VMConsole interface {
Write(string)
}
interface to write a null-terminated string to stdout
type VMHeap ¶
type VMHeap struct {
// contains filtered or unexported fields
}
func (*VMHeap) AllocateRootBlock ¶
func (*VMHeap) CreateBlock ¶
func (*VMHeap) GetBuddyAddress ¶
func (*VMHeap) GetFreeBlock ¶
func (*VMHeap) GetUnusedBlockIndex ¶
func (*VMHeap) MergeWithBuddy ¶
func (*VMHeap) NoFreeBlocksFor ¶
func (*VMHeap) ReadString ¶
func (*VMHeap) RemoveBlockFromUnused ¶
func (*VMHeap) SplitBlock ¶
type VMStack ¶
type VMStack struct {
// contains filtered or unexported fields
}
data structure to contain the stack for a single VM instance
func (*VMStack) PushDouble ¶
func (*VMStack) PushEmptyCell ¶
func (s *VMStack) PushEmptyCell()
func (*VMStack) PushString ¶
Click to show internal directories.
Click to hide internal directories.