Class Scenario2WrapperHelper

java.lang.Object
org.ek9lang.compiler.phase7.Scenario2WrapperHelper

final class Scenario2WrapperHelper extends Object
Shared utilities for Scenario 2 wrapper IR generation.

Provides common operations needed by all Scenario 2 specialist generators:

  • Temporary variable and scope ID generation
  • Type name resolution from Ek9Types
  • Operator name mapping (symbol to method name)
  • Type erasure for delegation (finding base method parameter/return types)
  • Basic block creation
  • Delegate field load pattern
  • Field Details

  • Constructor Details

    • Scenario2WrapperHelper

      Scenario2WrapperHelper(Ek9Types ek9Types)
  • Method Details

    • generateTempName

      String generateTempName()
    • generateScopeId

      String generateScopeId(String prefix)
    • currentScopeCounter

      int currentScopeCounter()
    • toMethodName

      String toMethodName(String operatorOrMethodName)
      Convert operator symbols to their mapped method names for use in IR.
    • createDebugInfo

      DebugInfo createDebugInfo()
    • createBasicBlock

      BasicBlockInstr createBasicBlock(List<IRInstr> instructions)
    • getBooleanTypeName

      String getBooleanTypeName()
    • getVoidTypeName

      String getVoidTypeName()
    • getStringTypeName

      String getStringTypeName()
    • getIntegerTypeName

      String getIntegerTypeName()
    • getAnyTypeName

      String getAnyTypeName()
    • loadDelegate

      String loadDelegate(List<IRInstr> instructions, String scopeId, DebugInfo debugInfo)
      Generate delegate field load with memory management.

      Common pattern used across all generators:

        delegateVar = LOAD_FIELD this.delegate (wrapperType -> delegateType)
        RETAIN delegateVar
        SCOPE_REGISTER delegateVar, scopeId
      
    • generateConstructorCallInstructions

      String generateConstructorCallInstructions(List<IRInstr> instructions, String typeName, List<String> paramTypes, List<String> argNames, String scopeId, DebugInfo debugInfo)
      Generate a constructor call on a type and manage memory.
    • generateVirtualCall

      String generateVirtualCall(List<IRInstr> instructions, String targetVar, String targetType, String methodName, List<String> paramTypes, String returnType, List<String> argNames, String scopeId, DebugInfo debugInfo)
      Generate a virtual method call on a target and manage memory.
    • extractPrimitiveBoolean

      String extractPrimitiveBoolean(List<IRInstr> instructions, String booleanVar, DebugInfo debugInfo)
      Extract primitive boolean from Boolean object via _true() method.
    • storeReturnValue

      void storeReturnValue(List<IRInstr> instructions, String valueVar, DebugInfo debugInfo)
      Store a value into the return variable and retain for ownership transfer.
    • generateUnsetBoolean

      String generateUnsetBoolean(List<IRInstr> instructions, String scopeId, DebugInfo debugInfo)
      Generate an unset Boolean constructor call.
    • containedTypeHasOperator

      boolean containedTypeHasOperator(ISymbol type, String operatorMethodName)
      Check if a type has a specific operator method.
    • isCollectionType

      boolean isCollectionType(String baseTypeName)
      Check if the base type is a collection type.
    • getBaseMethodParameterTypes

      List<String> getBaseMethodParameterTypes(MethodSymbol method)
      Get the parameter types from the BASE generic type's method, not the substituted version.
    • getBaseMethodReturnType

      String getBaseMethodReturnType(MethodSymbol method)
      Get the return type from the BASE generic type's method, not the substituted version.