Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bytecode ¶
type Bytecode struct { Instructions code.Instructions Constants []object.Object SymbolTable *SymbolTable }
type CompilationScope ¶
type CompilationScope struct {
// contains filtered or unexported fields
}
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler wraps the bytecode instructions and constants pool.
func New ¶
func New(symbolTable *SymbolTable, constants []object.Object) *Compiler
New returns a new instance of the Compiler
func NewCompilerWithBuiltins ¶
NewCompilerWithBuiltins returns a new instance of the Compiler, with builtin functions defined.
type EmittedInstruction ¶
type Symbol ¶
type Symbol struct { Name string Scope SymbolScope Index int }
type SymbolScope ¶
type SymbolScope string
const ( // BuiltinScope is used for builtins functions BuiltinScope SymbolScope = "BUILTIN" // GlobalScope is used to for global variables GlobalScope SymbolScope = "GLOBAL" // LocalScope is used to for local variables LocalScope SymbolScope = "LOCAL" // FreeScope is used to for free variables(used in closures) FreeScope SymbolScope = "FREE" // FunctionScope is used to for function names FunctionScope SymbolScope = "FUNCTION" )
type SymbolTable ¶
type SymbolTable struct { FreeSymbols []Symbol // contains filtered or unexported fields }
func NewEnclosedSymbolTable ¶
func NewEnclosedSymbolTable(parent *SymbolTable) *SymbolTable
func NewSymbolTable ¶
func NewSymbolTable() *SymbolTable
func (*SymbolTable) Define ¶
func (st *SymbolTable) Define(ident string) Symbol
func (*SymbolTable) DefineBuiltin ¶
func (st *SymbolTable) DefineBuiltin(index int, name string) Symbol
func (*SymbolTable) DefineFunctionName ¶
func (st *SymbolTable) DefineFunctionName(name string) Symbol
Click to show internal directories.
Click to hide internal directories.