Class TryCatchAsmGenerator
java.lang.Object
org.ek9lang.compiler.backend.jvm.AbstractAsmGenerator
org.ek9lang.compiler.backend.jvm.AbstractControlFlowAsmGenerator
org.ek9lang.compiler.backend.jvm.TryCatchAsmGenerator
Specialized generator for EK9 try/catch/finally statements.
Handles CONTROL_FLOW_CHAIN with chain_type: "TRY_CATCH_FINALLY".
JVM Bytecode Pattern:
try_start: [try block instructions] goto after_handlers ; Normal exit try_end: catch_start_1: [catch block 1 instructions] goto after_handlers catch_end_1: catch_start_2: [catch block 2 instructions] goto after_handlers catch_end_2: after_handlers: [finally block if present] Exception Table: from to target type try_start try_end catch_start_1 ExceptionType1 try_start try_end catch_start_2 ExceptionType2
Stack Frame Invariant: Stack is empty before try, after each handler, and after the entire statement.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractAsmGenerator
AbstractAsmGenerator.LocalVariableInfo, AbstractAsmGenerator.MethodContext, AbstractAsmGenerator.ScopeInfo, AbstractAsmGenerator.TempVariableSource -
Field Summary
Fields inherited from class AbstractControlFlowAsmGenerator
contextFields inherited from class AbstractAsmGenerator
classWriter, constructTargetTuple, outputVisitor -
Constructor Summary
ConstructorsConstructorDescriptionTryCatchAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter, BytecodeGenerationContext context) -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate(ControlFlowChainInstr instr) Generate bytecode for try/catch/finally.Methods inherited from class AbstractControlFlowAsmGenerator
branchIfFalse, branchIfTrue, copyResultVariable, createControlFlowLabel, jumpTo, placeLabel, processBodyEvaluation, processConditionCase, processConditionCaseWithoutLabelPlacement, processConditionEvaluation, processInstructionsMethods inherited from class AbstractAsmGenerator
convertBooleanToInt, convertToJvmDescriptor, convertToJvmName, generateBooleanLiteral, generateCharacterLiteral, generateDebugInfo, generateFloatLiteral, generateIntegerLiteral, generateLoadVariable, generateLocalVariableTable, generateMethodDescriptor, generateObjectLiteral, generateStackOperation, generateStoreVariable, generateStringLiteral, getCurrentMethodVisitor, getMethodContext, getOrCreateLabel, getVariableIndex, isVariableAllocated, setCurrentMethodVisitor, setSharedMethodContext, trackTempVariableFromLiteral, trackTempVariableFromLoad
-
Constructor Details
-
TryCatchAsmGenerator
TryCatchAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter, BytecodeGenerationContext context)
-
-
Method Details
-
generate
Generate bytecode for try/catch/finally.Control Flow:
- Create labels for exception handlers
- Register exception handlers with JVM (visitTryCatchBlock)
- Execute try block
- Jump to after handlers (normal path)
- Execute each catch handler
- Execute finally block (if present)
Stack Frame Invariant: Pre-condition: stack is empty Post-condition: stack is empty
- Parameters:
instr- CONTROL_FLOW_CHAIN instruction with TRY_CATCH_FINALLY type
-