Class FrameDescriptor.Builder

java.lang.Object
com.oracle.truffle.api.frame.FrameDescriptor.Builder
Enclosing class:
FrameDescriptor

public static final class FrameDescriptor.Builder extends Object
Builder API for frame descriptors with indexed slots.
Since:
22.0
  • Method Details

    • defaultValue

      public FrameDescriptor.Builder defaultValue(Object newDefaultValue)
      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

      public FrameDescriptor.Builder defaultValueIllegal()
      Sets the default value to illegal, this means that an FrameSlotTypeException is thrown if a slot is read before it is written. A frame descriptor can either have a concrete default value or an illegal default value, but not both.
      Since:
      24.2
    • addSlots

      public int addSlots(int count, FrameSlotKind kind)
      Adds the given number of consecutive indexed slots to the FrameDescriptor, and initializes them with the given kind.
      Parameters:
      count - number of slots to be added
      kind - default type of the newly added frame slots
      Returns:
      index of the first slot
      Since:
      22.0
    • useSlotKinds

      public FrameDescriptor.Builder useSlotKinds(boolean b)
      Enables the use of slot kinds like FrameDescriptor.getSlotKind(int). By default slot kinds are enabled. If they are disabled then FrameDescriptor.getSlotKind(int) always returns FrameSlotKind.Illegal and no slot with a different slot kind than FrameSlotKind.Illegal must be added.
      Since:
      24.2
    • addSlots

      public int addSlots(int count)
      Adds the given number of consecutive indexed slots to the FrameDescriptor, and initializes them without a kind. If the kind is read anyway then Illegal will be returned and setting the kind will throw an UnsupportedOperationException.
      Parameters:
      count - the number of slots to add
      Since:
      24.2
      See Also:
    • addSlot

      public int addSlot(FrameSlotKind kind, Object name, Object info)
      Adds an indexed frame slot to the FrameDescriptor. The frame descriptor's internal arrays for storing name and info are allocated only when needed, so using only null reduces memory footprint.
      Parameters:
      kind - default type of the newly added frame slot
      name - 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

      public FrameDescriptor.Builder info(Object 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 using FrameDescriptor.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

      public FrameDescriptor build()
      Uses the data provided to this builder to create a new FrameDescriptor.
      Returns:
      the newly created FrameDescriptor
      Since:
      22.0