Class IRGenerationStack
java.lang.Object
org.ek9lang.compiler.phase7.generation.IRGenerationStack
Stack-based scope, debug, and context management for IR generation.
This stack provides the transient context management that eliminates parameter threading throughout the IR generation process. Modeled after the successful ScopeStack pattern used in phases 1-6.
Each frame on the stack represents a scope context (method, function, block, expression) with its associated scope ID, debug information, and other contextual information needed for IR generation.
The stack automatically handles nested scope management and provides navigation capabilities to find containing scopes of specific types.
-
Constructor Summary
ConstructorsConstructorDescriptionIRGenerationStack
(IRStackFrame baseFrame) Create a new IR generation stack with a base frame. -
Method Summary
Modifier and TypeMethodDescriptionGet current debug info from the top frame.Get current frame type from the top frame.Get current scope ID from the top frame.int
depth()
Get the depth of the stack (for debugging/testing).Get the very base frame of the stack (usually module level).boolean
Check if current scope has a left-hand side (for result variable decisions).boolean
isEmpty()
Check if the stack is empty.boolean
isInAnyFrameType
(IRFrameType... frameTypes) Check if we're currently in any of the specified frame types.boolean
isInFrameType
(IRFrameType frameType) Check if we're currently in a specific frame type.peek()
Look at the top frame without removing it.pop()
Pop a frame off the stack.push
(IRStackFrame frame) Push a new frame onto the stack.Navigate back up the stack to find the containing aggregate (class/record/trait).<T> Optional
<T> traverseBackToContextData
(Class<T> contextType) Navigate back up the stack to find the first frame with context data of the specified type.traverseBackToFrameType
(IRFrameType frameType) Navigate back up the stack to find the first frame of the specified type.Navigate back up the stack to find the first method or function frame.
-
Constructor Details
-
IRGenerationStack
Create a new IR generation stack with a base frame.
-
-
Method Details
-
getVeryBaseFrame
Get the very base frame of the stack (usually module level). -
push
Push a new frame onto the stack. -
peek
Look at the top frame without removing it. -
pop
Pop a frame off the stack. -
isEmpty
public boolean isEmpty()Check if the stack is empty. -
currentScopeId
Get current scope ID from the top frame. -
currentDebugInfo
-
hasLeftHandSide
public boolean hasLeftHandSide()Check if current scope has a left-hand side (for result variable decisions). -
currentFrameType
Get current frame type from the top frame. -
traverseBackToFrameType
Navigate back up the stack to find the first frame of the specified type. Useful for finding containing method/function contexts from nested blocks. -
traverseBackToMethodOrFunction
Navigate back up the stack to find the first method or function frame. Used for capturing context information in nested expressions. -
traverseBackToAggregate
Navigate back up the stack to find the containing aggregate (class/record/trait). Used for synthesis operations that need access to the containing type. -
depth
public int depth()Get the depth of the stack (for debugging/testing). -
traverseBackToContextData
-
isInFrameType
Check if we're currently in a specific frame type. -
isInAnyFrameType
Check if we're currently in any of the specified frame types.
-