Class VariableAccessGenerator
java.lang.Object
org.ek9lang.compiler.backend.jvm.support.VariableAccessGenerator
Generates JVM bytecode for variable load and store operations.
Handles:
- Local variable access (ALOAD/ASTORE)
- Field access on 'this' (GETFIELD/PUTFIELD)
- Field access on other variables
- Variable slot allocation
- Label management
-
Constructor Summary
ConstructorsConstructorDescriptionVariableAccessGenerator(MethodContext methodContext, Function<String, String> jvmNameConverter, Supplier<String> ownerClassNameSupplier) -
Method Summary
Modifier and TypeMethodDescriptionextractFieldName(String variableName) Extract field name from variable name (with or without "this." prefix).voidgenerateLoadVariable(org.objectweb.asm.MethodVisitor mv, String variableName) Generate JVM instructions for loading a variable.voidgenerateStoreVariable(org.objectweb.asm.MethodVisitor mv, String variableName) Generate JVM instructions for storing to a variable.getFieldDescriptor(String variableName) Get field type descriptor for putfield/getfield instructions.org.objectweb.asm.LabelgetOrCreateLabel(String labelName) Get or create JVM Label for IR label name.Get owner class name for field access.intgetVariableIndex(String variableName) Get or assign local variable slot for a variable name.booleanisFieldAccess(String variableName) Check if variable name represents field access on 'this'.booleanisVariableAllocated(String variableName) Check if a variable has already been allocated a local variable slot.booleanisVariableFieldAccess(String variableName) Check if variable name represents field access on another variable.voidtrackTempVariableFromLiteral(String tempVar, String literalValue, String literalType) Track that a temp variable was created from a literal value.voidtrackTempVariableFromLoad(String tempVar, String sourceVar) Track that a temp variable was created from loading another variable.
-
Constructor Details
-
VariableAccessGenerator
-
-
Method Details
-
generateLoadVariable
Generate JVM instructions for loading a variable. Uses the appropriate load opcode based on variable type (ALOAD for objects, ILOAD for primitives). -
generateStoreVariable
Generate JVM instructions for storing to a variable. -
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
-