Class BytecodeLocal
java.lang.Object
com.oracle.truffle.api.bytecode.BytecodeLocal
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract int
Returns the index when accessing into the locals table withBytecodeNode.getLocals()
.abstract int
Returns the local offset to use when accessing local values with a local accessor likeBytecodeNode.getLocalValue(int, Frame, int)
.
-
Constructor Details
-
BytecodeLocal
-
-
Method Details
-
getLocalOffset
public abstract int getLocalOffset()Returns the local offset to use when accessing local values with a local accessor likeBytecodeNode.getLocalValue(int, Frame, int)
.- Since:
- 24.2
-
getLocalIndex
public abstract int getLocalIndex()Returns the index when accessing into the locals table withBytecodeNode.getLocals()
. The local index is guaranteed to be equal togetLocalOffset()
ifblock scoping
is set tofalse
. Otherwise, the local index is distinct from the local offset and should not be used in places an offset is expected.- Since:
- 24.2
-