compiler

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 11 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
}

func Decode

func Decode(b []byte) *Bytecode

func (Bytecode) Encode

func (b Bytecode) Encode() (data []byte, err error)

func (*Bytecode) String

func (b *Bytecode) String() string

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

func (*Compiler) SetFileInfo

func (c *Compiler) SetFileInfo(fn, input string)

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
	NumDefs int

	FreeSymbols []Symbol
}

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
JackTT - Gopher 🇻🇳