protected Location getLocation(DynamicObject object, Object value) {
    object.updateShape();
    final Shape oldShape = object.getShape();
    final Property property = oldShape.getProperty(name);

    if (property != null && property.getLocation().canSet(object, value)) {
      return property.getLocation();
    } else {
      return null;
    }
  }
 protected static List<Property> getObjectProperties(Shape shape) {
   final List<Property> objectProperties = new ArrayList<>();
   // User properties only, ShareInternalFieldsNode do the rest
   for (Property property : shape.getProperties()) {
     if (property.getLocation().canStore(SOME_OBJECT)) {
       objectProperties.add(property);
     }
   }
   return objectProperties;
 }
 protected Shape transitionWithNewField(Shape oldShape, Object value) {
   // This duplicates quite a bit of DynamicObject.define(), but should be fixed in Truffle soon.
   final Property oldProperty = oldShape.getProperty(name);
   if (oldProperty != null) {
     if (oldProperty.getFlags() == 0 && oldProperty.getLocation().canSet(null, value)) {
       return oldShape; // already the right shape
     } else {
       DynamicObject copy = oldShape.getLayout().newInstance(oldShape);
       copy.define(name, value, 0);
       return copy.getShape();
     }
   } else {
     final Location location =
         oldShape
             .allocator()
             .locationForValue(
                 value, EnumSet.of(LocationModifier.Final, LocationModifier.NonNull));
     final Property newProperty = Property.create(name, location, 0);
     return oldShape.addProperty(newProperty);
   }
 }