Class BytecodeLocal

java.lang.Object
com.oracle.truffle.api.bytecode.BytecodeLocal

public abstract class BytecodeLocal extends Object
Abstract definition of a local variable in the interpreter.

Local variables are stored in the frame. They are typically accessed in the bytecode using StoreLocal and LoadLocal operations. For uncommon scenarios where locals need to be accessed programmatically (e.g., in a node), locals can be accessed using accessor methods on the BytecodeNode, such as BytecodeNode.getLocalValue(int, Frame, int) and BytecodeNode.setLocalValue(int, com.oracle.truffle.api.frame.Frame, int, Object).

By default a local variable is live for the extent of the block that defines it ("block scoping"). Interpreters can also be configured so that locals live for the extent of the root node ("root scoping"). See GenerateBytecode.enableBlockScoping() for details.

Refer to the user guide for more details.

Since:
24.2
  • Constructor Details

    • BytecodeLocal

      public BytecodeLocal(Object token)
      Internal constructor for generated code. Do not use.
      Since:
      24.2
  • Method Details

    • getLocalOffset

      public abstract int getLocalOffset()
      Returns the local offset to use when accessing local values with a local accessor like BytecodeNode.getLocalValue(int, Frame, int).
      Since:
      24.2
    • getLocalIndex

      public abstract int getLocalIndex()
      Returns the index when accessing into the locals table with BytecodeNode.getLocals(). The local index is guaranteed to be equal to getLocalOffset() if block scoping is set to false. Otherwise, the local index is distinct from the local offset and should not be used in places an offset is expected.
      Since:
      24.2