Class LocalVariableInfo

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

public final class LocalVariableInfo extends Object
Metadata for a local variable needed for LocalVariableTable generation.

Tracks the variable name, type descriptor, scope, and JVM slot for generating debug information that enables jdb's 'locals' command.

There is one instance per DECLARATION, not per name: a name declared again in a later scope (sibling blocks, sequential loops or tries) gets its own instance and so its own LocalVariableTable entry, sharing the name's slot over a range of its own (see MethodContext.declareLocal(LocalVariableInfo)).

The optional declaration label is the bytecode position immediately after the variable's null-init store (WP-B.2). Used as the LocalVariableTable range START so the range begins where the slot is verifier-defined — rather than at method entry, which made every local claim the method-wide range [0,end) and threw InconsistentDebugInfoException on a read-before-store (defect B-1).

  • Constructor Details

    • LocalVariableInfo

      public LocalVariableInfo(String name, String typeDescriptor, String scopeId)
      Create local variable info.
      Parameters:
      name - Variable name
      typeDescriptor - JVM type descriptor
      scopeId - Scope identifier (may be null for method parameters)
  • Method Details

    • getName

      public String getName()
    • getTypeDescriptor

      public String getTypeDescriptor()
    • getScopeId

      public String getScopeId()
    • setScopeId

      public void setScopeId(String scopeId)
      Associate this declaration with the scope it is registered in (SCOPE_REGISTER).
    • getSlot

      public int getSlot()
    • setSlot

      public void setSlot(int slot)
    • getDeclarationLabel

      public org.objectweb.asm.Label getDeclarationLabel()
      The bytecode position after this variable's null-init store, or null for a parameter (which is live from method entry) or an uninstrumented compile. WP-B.2 range start.
    • setDeclarationLabel

      public void setDeclarationLabel(org.objectweb.asm.Label declarationLabel)
    • getScopeEntryLabel

      public org.objectweb.asm.Label getScopeEntryLabel()
      The entry of the scope THIS declaration was registered in, as it was when registered, or null. The range start of a declaration with no declaration label (a caught exception, bound by its handler). A scope the back end emits more than once has one scope id but several entries; the scope's own start label is only the LAST, which would put an earlier copy's start after its end.
    • setScopeEntryLabel

      public void setScopeEntryLabel(org.objectweb.asm.Label scopeEntryLabel)
    • getEndLabel

      public org.objectweb.asm.Label getEndLabel()
      The bytecode position where THIS declaration's scope was last exited while it was still the current declaration of its name, or null if none was recorded (the scope's own end label is then used). A scope whose body the back end emits more than once (a for-range's direction copies) has one scope id but several exits; each copy's declaration ends at its own exit, so the ranges do not overlap.
    • setEndLabel

      public void setEndLabel(org.objectweb.asm.Label endLabel)