Class OutputVisitor

java.lang.Object
org.ek9lang.compiler.backend.jvm.OutputVisitor
All Implemented Interfaces:
INodeVisitor

public final class OutputVisitor extends Object implements INodeVisitor
Enhanced visitor that uses specialized ASM generators to produce JVM bytecode for IR constructs. Implements visitor pattern with typed visit methods for each IR instruction type. Uses single responsibility principle with separate generators for each instruction type.
  • Constructor Details

  • Method Details

    • setMethodContext

      public void setMethodContext(AbstractAsmGenerator.MethodContext methodContext, org.objectweb.asm.MethodVisitor mv, boolean isConstructor)
      Set method context for all generators before processing a method's instructions. Must be called before processing each method to ensure proper variable/label management.
      Parameters:
      methodContext - Shared context for variable and label maps
      mv - Method visitor for this specific method
      isConstructor - Whether we're processing a constructor
    • visit

      public void visit()
      Description copied from interface: INodeVisitor
      Entry point for visitors.
      Specified by:
      visit in interface INodeVisitor
    • visit

      public void visit(IRConstruct construct)
      Specified by:
      visit in interface INodeVisitor
    • visit

      public void visit(IRInstr irInstr)
      Dispatch IRInstr to typed visit methods. This is called by IRInstr.accept(visitor) polymorphically.
      Specified by:
      visit in interface INodeVisitor
    • visit

      public void visit(CallInstr callInstr)
      Typed visit method for CallInstr - delegates to specialized generator.
    • visit

      public void visit(LiteralInstr literalInstr)
      Typed visit method for LiteralInstr - delegates to specialized generator.
    • visit

      public void visit(MemoryInstr memoryInstr)
      Typed visit method for MemoryInstr - delegates to specialized generator.
    • visit

      public void visit(ScopeInstr scopeInstr)
      Typed visit method for ScopeInstr - delegates to specialized generator.
    • visit

      public void visit(BranchInstr branchInstr)
      Typed visit method for BranchInstr - delegates to specialized generator.
    • visit

      public void visit(LabelInstr labelInstr)
      Typed visit method for LabelInstr - delegates to specialized generator.
    • visit

      public void visit(ControlFlowChainInstr instr)
      Typed visit method for ControlFlowChainInstr - delegates to specialized generator. Handles all EK9 control flow constructs: question operator, if/else, switch, loops, try/catch.
    • visit

      public void visit(LogicalOperationInstr instr)
      Typed visit method for LogicalOperationInstr - delegates to specialized generator. Handles logical AND/OR operations with short-circuit evaluation.
    • visit

      public void visit(ForRangePolymorphicInstr instr)
      Typed visit method for ForRangePolymorphicInstr - delegates to specialized generator. Handles polymorphic FOR_RANGE loops with runtime direction detection.
    • generateLocalVariableTable

      public void generateLocalVariableTable()
      Generate LocalVariableTable for the current method. Must be called after processing all instructions but before visitMaxs(). Delegates to any generator (they all share the same AbstractAsmGenerator base).