Class AbstractAsmGenerator
java.lang.Object
org.ek9lang.compiler.backend.jvm.AbstractAsmGenerator
- Direct Known Subclasses:
AbstractControlFlowAsmGenerator, AssertThrowsAsmGenerator, BranchInstrAsmGenerator, CallInstrAsmGenerator, CastInstrAsmGenerator, ControlFlowChainAsmGenerator, CoverageFinalizeAsmGenerator, CoverageProbeAsmGenerator, EnumIteratorImplAsmGenerator, LabelInstrAsmGenerator, LiteralInstrAsmGenerator, MemoryInstrAsmGenerator, PrimitiveLiteralAsmGenerator, SanitizeInstrAsmGenerator, ScopeInstrAsmGenerator, StringInterpolationAsmGenerator, ThrowInstrAsmGenerator
Common abstract base class for all specialized ASM generators.
Provides shared functionality for JVM bytecode generation including:
- Access to ClassWriter and current MethodVisitor
- EK9 to JVM name conversion using existing utilities
- Debug information handling
- Common JVM instruction patterns
This class delegates to focused utility classes in the support package:
VariableAccessGenerator- Variable load/store operationsLiteralBytecodeGenerator- Literal value generationDebugInfoGenerator- Debug information and LocalVariableTableStackOperationSupport- Stack-oriented code generation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.objectweb.asm.ClassWriterprotected final ConstructTargetTupleprotected final OutputVisitor -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertToJvmDescriptor(String ek9TypeName) Convert EK9 type name to JVM descriptor format.protected StringconvertToJvmName(String ek9FullyQualifiedName) Convert EK9 fully qualified name to JVM internal name format.protected StringextractFieldName(String variableName) Extract field name from variable name.protected voidgenerateBooleanLiteral(String literalValue) Generate EK9 Boolean literal from string value.protected voidgenerateCharacterLiteral(String literalValue) Generate EK9 Character literal from string value.protected voidgenerateDebugInfo(DebugInfo debugInfo) Generate debug line number from EK9 debug info if available.protected voidgenerateFloatLiteral(String literalValue) Generate EK9 Float literal from string value.protected voidgenerateIntegerLiteral(String literalValue) Generate EK9 Integer literal from string value.protected voidgenerateLoadVariable(String variableName) Generate common JVM instructions for loading a variable.protected voidGenerate LocalVariableTable entries for all variables tracked during method processing.protected StringgenerateMethodDescriptor(List<String> parameterTypes, String returnType) Generate method descriptor from EK9 parameter and return types.protected voidgenerateObjectLiteral(String literalValue, String literalType) Generate EK9 type literal for generic/object types.protected voidgenerateStackOperation(String variableName) Generate stack operation for a variable.protected voidgenerateStoreVariable(String variableName) Generate common JVM instructions for storing to a variable.protected voidgenerateStoreVariableAsInt(String variableName) Generate JVM instructions for storing a primitive int to a variable.protected voidgenerateStringLiteral(String literalValue) Generate EK9 String literal from string value.protected org.objectweb.asm.MethodVisitorGet the current method visitor.protected StringgetFieldDescriptor(String variableName) Get field type descriptor for putfield/getfield instructions.protected MethodContextGet the shared method context.protected org.objectweb.asm.LabelgetOrCreateLabel(String labelName) Get or create JVM Label for IR label name.protected StringGet owner class name for field access.protected intgetVariableIndex(String variableName) Get or assign local variable slot for a variable name.protected booleanisFieldAccess(String variableName) Check if variable name represents field access on 'this'.protected booleanisVariableAllocated(String variableName) Check if a variable has already been allocated a local variable slot.protected booleanisVariableFieldAccess(String variableName) Check if variable name represents field access on another variable.protected voidsetCurrentMethodVisitor(org.objectweb.asm.MethodVisitor methodVisitor) Set the current method visitor for instruction generation.protected voidsetSharedMethodContext(MethodContext context) Set shared method context for coordinated variable slot allocation across generators.protected voidtrackTempVariableFromLiteral(String tempVar, String literalValue, String literalType) Track that a temp variable was created from a literal value.protected voidtrackTempVariableFromLoad(String tempVar, String sourceVar) Track that a temp variable was created from loading another variable.
-
Field Details
-
constructTargetTuple
-
outputVisitor
-
classWriter
protected final org.objectweb.asm.ClassWriter classWriter
-
-
Constructor Details
-
AbstractAsmGenerator
protected AbstractAsmGenerator(ConstructTargetTuple constructTargetTuple, OutputVisitor outputVisitor, org.objectweb.asm.ClassWriter classWriter)
-
-
Method Details
-
getMethodContext
Get the shared method context. -
setCurrentMethodVisitor
protected void setCurrentMethodVisitor(org.objectweb.asm.MethodVisitor methodVisitor) Set the current method visitor for instruction generation. -
getCurrentMethodVisitor
protected org.objectweb.asm.MethodVisitor getCurrentMethodVisitor()Get the current method visitor. -
convertToJvmName
-
convertToJvmDescriptor
-
generateDebugInfo
Generate debug line number from EK9 debug info if available. -
generateLocalVariableTable
protected void generateLocalVariableTable()Generate LocalVariableTable entries for all variables tracked during method processing. -
generateLoadVariable
Generate common JVM instructions for loading a variable. -
generateStoreVariable
Generate common JVM instructions for storing to a variable. -
generateStoreVariableAsInt
Generate JVM instructions for storing a primitive int to a variable.Used for INSTANCEOF results and other primitive operations.
-
isFieldAccess
Check if variable name represents field access on 'this'. -
isVariableFieldAccess
Check if variable name represents field access on another variable. -
extractFieldName
-
getFieldDescriptor
-
getOwnerClassName
Get owner class name for field access. -
getVariableIndex
Get or assign local variable slot for a variable name. -
isVariableAllocated
Check if a variable has already been allocated a local variable slot. -
getOrCreateLabel
Get or create JVM Label for IR label name. -
trackTempVariableFromLoad
-
trackTempVariableFromLiteral
-
generateStackOperation
Generate stack operation for a variable. -
generateStringLiteral
Generate EK9 String literal from string value. -
generateIntegerLiteral
Generate EK9 Integer literal from string value. -
generateBooleanLiteral
Generate EK9 Boolean literal from string value. -
generateFloatLiteral
Generate EK9 Float literal from string value. -
generateCharacterLiteral
Generate EK9 Character literal from string value. -
generateObjectLiteral
-
generateMethodDescriptor