| Stability | stable |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Compiler.CompilerState
Description
Synopsis
- data CompilerState = CompilerState {
- csCode :: Seq PsInstruction
- csFuncs :: Seq PsInstruction
- csSymbols :: SymTable
- csStructs :: Map Text [(Text, Text)]
- csNextIndex :: Int
- csLabelCnt :: Int
- csScopeContext :: ScopeType
- csCurrentArgCount :: Int
- csLoopExits :: [Text]
- type SymTable = Map Text (ScopeType, Int, Text)
- data ScopeType
- createCompilerState :: CompilerState
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
| Show CompilerState Source # | |
Defined in Compiler.CompilerState Methods showsPrec :: Int -> CompilerState -> ShowS # show :: CompilerState -> String # showList :: [CompilerState] -> ShowS # | |
| Eq CompilerState Source # | |
Defined in Compiler.CompilerState Methods (==) :: CompilerState -> CompilerState -> Bool # (/=) :: CompilerState -> CompilerState -> Bool # | |
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.
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) |
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.