Class ControlFlowChainAsmGenerator

java.lang.Object
org.ek9lang.compiler.backend.jvm.AbstractAsmGenerator
org.ek9lang.compiler.backend.jvm.ControlFlowChainAsmGenerator

final class ControlFlowChainAsmGenerator extends AbstractAsmGenerator
Main dispatcher for CONTROL_FLOW_CHAIN bytecode generation. Delegates to specialized generators based on chain_type. Follows strategy pattern with lazy instantiation.

Supported Control Flow Types:

  • QUESTION_OPERATOR - EK9 question operator (?) for null/set checking
  • GUARDED_ASSIGNMENT - EK9 guarded assignment (:=?) for conditional initialization
  • TODO: IF_ELSE, SWITCH, WHILE, FOR, TRY_CATCH

Architecture Benefits:

  • Single responsibility: Each control flow type has dedicated generator
  • Lazy initialization: Generators created only when needed
  • Shared logic: Common patterns in AbstractControlFlowAsmGenerator
  • Extensibility: Easy to add new control flow types
  • Constructor Details

    • ControlFlowChainAsmGenerator

      ControlFlowChainAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter)
  • Method Details

    • generate

      public void generate(ControlFlowChainInstr instr)
      Dispatch to appropriate generator based on chain type. This is the main entry point called by OutputVisitor.
      Parameters:
      instr - CONTROL_FLOW_CHAIN instruction to generate bytecode for
      Throws:
      CompilerException - if chain type is not supported
    • setSharedMethodContext

      public void setSharedMethodContext(AbstractAsmGenerator.MethodContext context)
      Update method context for all generators. Called when OutputVisitor.setMethodContext() is invoked. Propagates context to already-instantiated generators.
      Overrides:
      setSharedMethodContext in class AbstractAsmGenerator
      Parameters:
      context - Shared method context with variable/label maps
    • setCurrentMethodVisitor

      public void setCurrentMethodVisitor(org.objectweb.asm.MethodVisitor mv)
      Update method visitor for all generators. Called when OutputVisitor.setMethodContext() is invoked. Propagates method visitor to already-instantiated generators.
      Overrides:
      setCurrentMethodVisitor in class AbstractAsmGenerator
      Parameters:
      mv - ASM MethodVisitor for current method being generated