Class OutputVisitor
java.lang.Object
org.ek9lang.compiler.backend.jvm.OutputVisitor
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidGenerate LocalVariableTable for the current method.voidsetMethodContext(AbstractAsmGenerator.MethodContext methodContext, org.objectweb.asm.MethodVisitor mv, boolean isConstructor) Set method context for all generators before processing a method's instructions.voidvisit()Entry point for visitors.voidvisit(BranchInstr branchInstr) Typed visit method for BranchInstr - delegates to specialized generator.voidTyped visit method for CallInstr - delegates to specialized generator.voidvisit(ControlFlowChainInstr instr) Typed visit method for ControlFlowChainInstr - delegates to specialized generator.voidvisit(ForRangePolymorphicInstr instr) Typed visit method for ForRangePolymorphicInstr - delegates to specialized generator.voidvisit(IRConstruct construct) voidDispatch IRInstr to typed visit methods.voidvisit(LabelInstr labelInstr) Typed visit method for LabelInstr - delegates to specialized generator.voidvisit(LiteralInstr literalInstr) Typed visit method for LiteralInstr - delegates to specialized generator.voidvisit(LogicalOperationInstr instr) Typed visit method for LogicalOperationInstr - delegates to specialized generator.voidvisit(MemoryInstr memoryInstr) Typed visit method for MemoryInstr - delegates to specialized generator.voidvisit(ScopeInstr scopeInstr) Typed visit method for ScopeInstr - delegates to specialized generator.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface INodeVisitor
visit, visit, visit
-
Constructor Details
-
OutputVisitor
-
-
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 mapsmv- Method visitor for this specific methodisConstructor- Whether we're processing a constructor
-
visit
public void visit()Description copied from interface:INodeVisitorEntry point for visitors.- Specified by:
visitin interfaceINodeVisitor
-
visit
- Specified by:
visitin interfaceINodeVisitor
-
visit
Dispatch IRInstr to typed visit methods. This is called by IRInstr.accept(visitor) polymorphically.- Specified by:
visitin interfaceINodeVisitor
-
visit
Typed visit method for CallInstr - delegates to specialized generator. -
visit
Typed visit method for LiteralInstr - delegates to specialized generator. -
visit
Typed visit method for MemoryInstr - delegates to specialized generator. -
visit
Typed visit method for ScopeInstr - delegates to specialized generator. -
visit
Typed visit method for BranchInstr - delegates to specialized generator. -
visit
Typed visit method for LabelInstr - delegates to specialized generator. -
visit
Typed visit method for ControlFlowChainInstr - delegates to specialized generator. Handles all EK9 control flow constructs: question operator, if/else, switch, loops, try/catch. -
visit
Typed visit method for LogicalOperationInstr - delegates to specialized generator. Handles logical AND/OR operations with short-circuit evaluation. -
visit
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).
-