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.Instruction ObjectPool []object.Object }
representa el bytecode para la vm
type CompiledFrame ¶
type CompiledFrame struct {
// contains filtered or unexported fields
}
Para gestionar los ámbitos de compilación
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler se encarga de recorrer el AST y emitir el bytecode
func NewWithState ¶
func NewWithState(s *SymbolTable, objectPool []object.Object) *Compiler
Crea un nuevo Compiler pero con SymbolTable
func (*Compiler) GetByteCode ¶
Genera y devuelve el objeto Bytecode final.
func (*Compiler) GetInstructions ¶
func (c *Compiler) GetInstructions() []code.Instruction
Delvuelve el conjunto de instrucciones
func (*Compiler) PrintInstructions ¶
func (c *Compiler) PrintInstructions(instructions []code.Instruction) string
*************************INICIO DEBUG***********************
type Symbol ¶
type Symbol struct { Name string Scope SymbolScope Index int }
contiene la información necesaria acerca del símbolo que el compilador se encuentre.
type SymbolScope ¶
type SymbolScope string
Alias para el tipo de alcance el valor no es muy importante siempre y cuando sea único porque necesitaremos diferenciar entre distintos ámbitos. es mejor usar int pero string nos ayuda para el debug.
const ( LocalScope SymbolScope = "LOCAL" GlobalScope SymbolScope = "GLOBAL" BuiltinScope SymbolScope = "BUILTIN" FreeScope SymbolScope = "FREE" )
Lista de ámbitos
type SymbolTable ¶
type SymbolTable struct { Outer *SymbolTable FreeSymbols []Symbol // contains filtered or unexported fields }
asocia keys con símbolos y mantiene rastro de su definición numérica. Las keys son realmente los nombres literales del identificador.
func NewEnclosedSymbolTable ¶
func NewEnclosedSymbolTable(outer *SymbolTable) *SymbolTable
func (*SymbolTable) DefineBuiltin ¶
func (s *SymbolTable) DefineBuiltin(index int, name string) Symbol
define un builtin