Class ControlFlowChainAsmGenerator
java.lang.Object
org.ek9lang.compiler.backend.jvm.AbstractAsmGenerator
org.ek9lang.compiler.backend.jvm.ControlFlowChainAsmGenerator
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
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractAsmGenerator
AbstractAsmGenerator.LocalVariableInfo, AbstractAsmGenerator.MethodContext, AbstractAsmGenerator.ScopeInfo, AbstractAsmGenerator.TempVariableSource
-
Field Summary
Fields inherited from class AbstractAsmGenerator
classWriter, constructTargetTuple
-
Constructor Summary
ConstructorsConstructorDescriptionControlFlowChainAsmGenerator
(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
generate
(ControlFlowChainInstr instr) Dispatch to appropriate generator based on chain type.void
setCurrentMethodVisitor
(org.objectweb.asm.MethodVisitor mv) Update method visitor for all generators.void
Update method context for all generators.Methods inherited from class AbstractAsmGenerator
convertBooleanToInt, convertToJvmDescriptor, convertToJvmName, generateBooleanLiteral, generateCharacterLiteral, generateDebugInfo, generateFloatLiteral, generateIntegerLiteral, generateLoadVariable, generateLocalVariableTable, generateMethodDescriptor, generateObjectLiteral, generateStackOperation, generateStoreVariable, generateStringLiteral, getCurrentMethodVisitor, getMethodContext, getOrCreateLabel, getVariableIndex, isVariableAllocated, trackTempVariableFromLiteral, trackTempVariableFromLoad
-
Constructor Details
-
ControlFlowChainAsmGenerator
ControlFlowChainAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter)
-
-
Method Details
-
generate
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
-
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 classAbstractAsmGenerator
- Parameters:
mv
- ASM MethodVisitor for current method being generated
-