compiler

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: 8 Imported by: 0

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
}

type Compiler

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

func New

func New() *Compiler

func NewWithState

func NewWithState(symbolTable *SymbolTable, constants []object.Object) *Compiler

func (*Compiler) Bytecode

func (c *Compiler) Bytecode() *Bytecode

func (*Compiler) Compile

func (c *Compiler) Compile(node ast.Node) error

type EmittedInstruction

type EmittedInstruction struct {
	Opcode   code.Opcode
	Position int
}

type Scope

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

type Symbol

type Symbol struct {
	Name  string
	Scope SymbolScope
	Index int
}

type SymbolScope

type SymbolScope string
const (
	BuiltinScope SymbolScope = "BUILTIN"
	GlobalScope  SymbolScope = "GLOBAL"
	LocalScope   SymbolScope = "LOCAL"
	FreeScope    SymbolScope = "FREE"
)

type SymbolTable

type SymbolTable struct {
	Outer *SymbolTable

	Store map[string]Symbol

	FreeSymbols []Symbol
	// contains filtered or unexported fields
}

func NewEnclosedSymbolTable

func NewEnclosedSymbolTable(outer *SymbolTable) *SymbolTable

func NewSymbolTable

func NewSymbolTable() *SymbolTable

func (*SymbolTable) Define

func (s *SymbolTable) Define(name string) Symbol

func (*SymbolTable) DefineBuiltin

func (s *SymbolTable) DefineBuiltin(index int, name string) Symbol

func (*SymbolTable) DefineFree

func (s *SymbolTable) DefineFree(original Symbol) Symbol

func (*SymbolTable) Resolve

func (s *SymbolTable) Resolve(name string) (Symbol, bool)

Jump to

Keyboard shortcuts

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