Class IRGenerationStack

java.lang.Object
org.ek9lang.compiler.phase7.generation.IRGenerationStack

public class IRGenerationStack extends Object
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 Details

    • IRGenerationStack

      public IRGenerationStack(IRStackFrame baseFrame)
      Create a new IR generation stack with a base frame.
  • Method Details

    • push

      public IRStackFrame push(IRStackFrame frame)
      Push a new frame onto the stack.
    • peek

      public IRStackFrame peek()
      Look at the top frame without removing it.
    • pop

      public IRStackFrame pop()
      Pop a frame off the stack.
    • currentScopeId

      public String currentScopeId()
      Get current scope ID from the top frame.
    • currentDebugInfo

      public Optional<DebugInfo> currentDebugInfo()
      Get current debug info from the top frame.
    • traverseBackToContextData

      public <T> Optional<T> traverseBackToContextData(Class<T> contextType)
      Navigate back up the stack to find the first frame with context data of the specified type. Used to find IRContext or other contextual information stored in stack frames.