Class VariableAccessGenerator

java.lang.Object
org.ek9lang.compiler.backend.jvm.support.VariableAccessGenerator

public final class VariableAccessGenerator extends Object
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 Details

  • Method Details

    • generateLoadVariable

      public void generateLoadVariable(org.objectweb.asm.MethodVisitor mv, String variableName)
      Generate JVM instructions for loading a variable. Uses the appropriate load opcode based on variable type (ALOAD for objects, ILOAD for primitives).
    • generateStoreVariable

      public void generateStoreVariable(org.objectweb.asm.MethodVisitor mv, String variableName)
      Generate JVM instructions for storing to a variable.
    • isFieldAccess

      public boolean isFieldAccess(String variableName)
      Check if variable name represents field access on 'this'.
    • isVariableFieldAccess

      public boolean isVariableFieldAccess(String variableName)
      Check if variable name represents field access on another variable.
    • extractFieldName

      public String extractFieldName(String variableName)
      Extract field name from variable name (with or without "this." prefix).
    • getFieldDescriptor

      public String getFieldDescriptor(String variableName)
      Get field type descriptor for putfield/getfield instructions.
    • getOwnerClassName

      public String getOwnerClassName()
      Get owner class name for field access.
    • getVariableIndex

      public int getVariableIndex(String variableName)
      Get or assign local variable slot for a variable name.
    • isVariableAllocated

      public boolean isVariableAllocated(String variableName)
      Check if a variable has already been allocated a local variable slot.
    • getOrCreateLabel

      public org.objectweb.asm.Label getOrCreateLabel(String labelName)
      Get or create JVM Label for IR label name.
    • trackTempVariableFromLoad

      public void trackTempVariableFromLoad(String tempVar, String sourceVar)
      Track that a temp variable was created from loading another variable.
    • trackTempVariableFromLiteral

      public void trackTempVariableFromLiteral(String tempVar, String literalValue, String literalType)
      Track that a temp variable was created from a literal value.