Class LocationImpl

java.lang.Object
com.oracle.truffle.api.object.Location
com.oracle.truffle.object.LocationImpl
All Implemented Interfaces:
BaseLocation
Direct Known Subclasses:
BasicLocations.ArrayLocation, BasicLocations.FieldLocation, BasicLocations.PrimitiveLocationDecorator, Locations.DualLocation, Locations.ValueLocation

public abstract class LocationImpl extends Location
  • Constructor Details

    • LocationImpl

      public LocationImpl()
  • Method Details

    • set

      public void set(DynamicObject store, Object value, Shape shape) throws IncompatibleLocationException, FinalLocationException
      Description copied from interface: BaseLocation
      Set object value at this location in store.
      Specified by:
      set in interface BaseLocation
      Overrides:
      set in class Location
      shape - the current shape of the storage object
      Throws:
      IncompatibleLocationException - for storage type invalidations
      FinalLocationException - for effectively final fields
    • getInternal

      protected final Object getInternal(DynamicObject store)
      Specified by:
      getInternal in class Location
    • setInternal

      protected abstract void setInternal(DynamicObject store, Object value) throws IncompatibleLocationException
      Description copied from class: Location
      Like Location.set(DynamicObject, Object, Shape), but does not invalidate final locations. For internal use only and subject to change, use DynamicObjectFactory to create objects with predefined properties.
      Specified by:
      setInternal in class Location
      Throws:
      IncompatibleLocationException - if value is of non-assignable type
    • canSet

      public final boolean canSet(DynamicObject store, Object value)
      Description copied from class: Location
      Returns true if the location can be set to the value.
      Overrides:
      canSet in class Location
      Parameters:
      store - the receiver object
      value - the value in question
    • canStore

      public boolean canStore(Object value)
      Description copied from class: Location
      Returns true if the location is compatible with the value. The value may still be rejected if Location.canSet(DynamicObject, Object) returns false.
      Overrides:
      canStore in class Location
      Parameters:
      value - the value in question
    • canStoreFinal

      protected boolean canStoreFinal(DynamicObject store, Object value)
    • isFinal

      public boolean isFinal()
      Description copied from class: Location
      Returns true if this is a final location, i.e. readonly once set.
      Overrides:
      isFinal in class Location
    • isConstant

      public boolean isConstant()
      Description copied from class: Location
      Returns true if this is an immutable constant location.
      Overrides:
      isConstant in class Location
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in class Location
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in class Location
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getWhereString

      protected String getWhereString()
    • objectArrayCount

      public int objectArrayCount()
      Get the number of object array elements this location requires.
    • objectFieldCount

      public int objectFieldCount()
      Get the number of in-object Object fields this location requires.
    • primitiveFieldCount

      public int primitiveFieldCount()
      Get the number of in-object primitive fields this location requires.
    • primitiveArrayCount

      public int primitiveArrayCount()
      Get the number of primitive array elements this location requires.
    • valueEquals

      public static boolean valueEquals(Object val1, Object val2)
      Boxed values need to be compared by value not by reference. The first parameter should be the one with the more precise type information. For sets to final locations, otherValue.equals(thisValue) seems more beneficial, since we usually know more about the value to be set.