Record Class BytecodeStackFrame

java.lang.Object
java.lang.Record
org.ek9lang.compiler.backend.jvm.BytecodeStackFrame

public record BytecodeStackFrame(String scopeId, BytecodeFrameType frameType, Object contextData) extends Record
Single frame on bytecode generation context stack. Mirrors IRStackFrame pattern from IR generation phase.

Each frame represents a control flow construct (loop, switch, try-catch, if-chain) and carries type-specific context data accessed via generic getContextData().

  • Constructor Details

    • BytecodeStackFrame

      public BytecodeStackFrame(String scopeId, BytecodeFrameType frameType, Object contextData)
      Creates an instance of a BytecodeStackFrame record class.
      Parameters:
      scopeId - the value for the scopeId record component
      frameType - the value for the frameType record component
      contextData - the value for the contextData record component
  • Method Details

    • basic

      public static BytecodeStackFrame basic(String scopeId, BytecodeFrameType frameType)
      Create frame with no context data.
    • withContext

      public static BytecodeStackFrame withContext(String scopeId, BytecodeFrameType frameType, Object contextData)
      Create frame with type-specific context data.
    • getContextData

      public <T> T getContextData(Class<T> expectedType)
      Type-safe context data retrieval.
      Parameters:
      expectedType - Class of expected context data type
      Returns:
      Context data cast to expected type, or null if not assignable
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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
    • frameType

      public BytecodeFrameType frameType()
      Returns the value of the frameType record component.
      Returns:
      the value of the frameType record component
    • contextData

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