Class FrameDescriptor.Builder
java.lang.Object
com.oracle.truffle.api.frame.FrameDescriptor.Builder
- Enclosing class:
FrameDescriptor
Builder API for frame descriptors with indexed slots.
- Since:
- 22.0
-
Method Summary
Modifier and TypeMethodDescriptionint
addSlot
(FrameSlotKind kind, Object name, Object info) Adds an indexed frame slot to theFrameDescriptor
.int
addSlots
(int count) Adds the given number of consecutive indexed slots to theFrameDescriptor
, and initializes them without a kind.int
addSlots
(int count, FrameSlotKind kind) Adds the given number of consecutive indexed slots to theFrameDescriptor
, and initializes them with the given kind.build()
Uses the data provided to this builder to create a newFrameDescriptor
.defaultValue
(Object newDefaultValue) Sets the default value for the frame slots in this frame descriptor.Sets the default value to illegal, this means that anFrameSlotTypeException
is thrown if a slot is read before it is written.Adds a user-defined info object to the frame descriptor.useSlotKinds
(boolean b) Enables the use of slot kinds likeFrameDescriptor.getSlotKind(int)
.
-
Method Details
-
defaultValue
Sets the default value for the frame slots in this frame descriptor.- Parameters:
newDefaultValue
- the default value for the resulting frame descriptor- Since:
- 22.0
-
defaultValueIllegal
Sets the default value to illegal, this means that anFrameSlotTypeException
is thrown if a slot is read before it is written. A frame descriptor can either have a concretedefault value
or anillegal default value
, but not both.- Since:
- 24.2
-
addSlots
Adds the given number of consecutive indexed slots to theFrameDescriptor
, and initializes them with the given kind.- Parameters:
count
- number of slots to be addedkind
- default type of the newly added frame slots- Returns:
- index of the first slot
- Since:
- 22.0
-
useSlotKinds
Enables the use of slot kinds likeFrameDescriptor.getSlotKind(int)
. By default slot kinds are enabled. If they are disabled thenFrameDescriptor.getSlotKind(int)
always returnsFrameSlotKind.Illegal
and no slot with a different slot kind thanFrameSlotKind.Illegal
must be added.- Since:
- 24.2
-
addSlots
public int addSlots(int count) Adds the given number of consecutive indexed slots to theFrameDescriptor
, and initializes them without a kind. If the kind is read anyway then Illegal will be returned and setting the kind will throw anUnsupportedOperationException
.- Parameters:
count
- the number of slots to add- Since:
- 24.2
- See Also:
-
addSlot
Adds an indexed frame slot to theFrameDescriptor
. The frame descriptor's internal arrays for storingname
andinfo
are allocated only when needed, so using onlynull
reduces memory footprint.- Parameters:
kind
- default type of the newly added frame slotname
- Name of the newly added frame slot. Can (and should, if possible) be null.info
- Info object for the newly added frame slot. Can (and should, if possible) be null.- Since:
- 22.0
-
info
Adds a user-defined info object to the frame descriptor. The contents of this object are strongly referenced from the frame descriptor and can be queried usingFrameDescriptor.getInfo()
. They do not influence the semantics of the frame descriptor in any other way.- Parameters:
info
- the user-defined info object- Since:
- 22.1
-
build
Uses the data provided to this builder to create a newFrameDescriptor
.- Returns:
- the newly created
FrameDescriptor
- Since:
- 22.0
-