Record Class IRStackFrame

java.lang.Object
java.lang.Record
org.ek9lang.compiler.phase7.generation.IRStackFrame
Record Components:
scopeId - The unique identifier for this scope
debugInfo - Debug information for this scope (could be null if debug disabled)
frameType - The type of frame (method, function, block, etc.)
hasLeftHandSide - Whether this scope has a left-hand side for result variables
contextData - Additional context data specific to this frame type

public record IRStackFrame(String scopeId, DebugInfo debugInfo, IRFrameType frameType, boolean hasLeftHandSide, Object contextData) extends Record
Represents a single frame on the IR generation stack.

Each frame captures the essential context information needed for IR generation at a specific scope level (method, function, block, expression, etc.).

This eliminates the need for parameter threading by providing all contextual information through the stack frame.

  • Constructor Details

    • IRStackFrame

      public IRStackFrame(String scopeId, DebugInfo debugInfo, IRFrameType frameType, boolean hasLeftHandSide, Object contextData)
      Creates an instance of a IRStackFrame record class.
      Parameters:
      scopeId - the value for the scopeId record component
      debugInfo - the value for the debugInfo record component
      frameType - the value for the frameType record component
      hasLeftHandSide - the value for the hasLeftHandSide record component
      contextData - the value for the contextData record component
  • Method Details

    • basic

      public static IRStackFrame basic(String scopeId, DebugInfo debugInfo, IRFrameType frameType)
      Create a basic frame with just scope and debug info.
    • withLeftHandSide

      public static IRStackFrame withLeftHandSide(String scopeId, DebugInfo debugInfo, IRFrameType frameType, boolean hasLeftHandSide)
      Create a frame with left-hand side indication.
    • withContext

      public static IRStackFrame withContext(String scopeId, DebugInfo debugInfo, IRFrameType frameType, Object contextData)
      Create a frame with additional context data.
    • full

      public static IRStackFrame full(String scopeId, DebugInfo debugInfo, IRFrameType frameType, boolean hasLeftHandSide, Object contextData)
      Create a full frame with all parameters.
    • getContextData

      public <T> T getContextData(Class<T> expectedType)
      Get typed context data if available and of expected type.
    • hasContextData

      public boolean hasContextData(Class<?> expectedType)
      Check if this frame has context data of the specified type.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • scopeId

      public String scopeId()
      Returns the value of the scopeId record component.
      Returns:
      the value of the scopeId record component
    • debugInfo

      public DebugInfo debugInfo()
      Returns the value of the debugInfo record component.
      Returns:
      the value of the debugInfo record component
    • frameType

      public IRFrameType frameType()
      Returns the value of the frameType record component.
      Returns:
      the value of the frameType record component
    • hasLeftHandSide

      public boolean hasLeftHandSide()
      Returns the value of the hasLeftHandSide record component.
      Returns:
      the value of the hasLeftHandSide record component
    • contextData

      public Object contextData()
      Returns the value of the contextData record component.
      Returns:
      the value of the contextData record component