glados-0.1.0.0
Stabilitystable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Compiler.CompilerState

Description

 
Synopsis

Documentation

data CompilerState Source #

Compiler state holding code buffers and symbol information.

@details The CompilerState maintains two code buffers: csCode for the current block being compiled (e.g., main or current function body) and csFuncs for accumulating the code of defined functions and lambdas that will be appended at the end of the binary.

@return N/A (this documents the type)

Constructors

CompilerState 

Fields

Instances

Instances details
Show CompilerState Source # 
Instance details

Defined in Compiler.CompilerState

Eq CompilerState Source # 
Instance details

Defined in Compiler.CompilerState

type SymTable = Map Text (ScopeType, Int, Text) Source #

Symbol table mapping textual names to their scope and index.

@details SymTable stores the mapping required to resolve variable names to concrete memory indices. - ScopeType: Determines which LOAD instruction to use. - MemoryIndex: The integer offset in the stack/heap. - TypeName: The string representation of the variable's type.

data ScopeType Source #

Defines the memory scope of a variable.

@details This enumeration is used in the symbol table to determine which VM instruction (LOAD_GLOBAL, LOAD_LOCAL, or LOAD_CAPTURE) should be emitted when a symbol is referenced.

Constructors

ScopeGlobal

Global variable (LOAD_GLOBAL)

ScopeLocal

Local argument or variable (LOAD_LOCAL)

ScopeCapture

Variable captured by a closure (LOAD_CAPTURE)

Instances

Instances details
Show ScopeType Source # 
Instance details

Defined in Compiler.CompilerState

Eq ScopeType Source # 
Instance details

Defined in Compiler.CompilerState

createCompilerState :: CompilerState Source #

Initial, empty compiler state.

@details Provides a fresh CompilerState with no code, an empty symbol table, the next local index set to 0 and the label counter set to 0.

@return A CompilerState initialized for a new compilation unit.