private void setSlowCase(DynamicObject store, Object value) { Shape oldShape = store.getShape(); Shape newShape = oldShape.defineProperty(getKey(), value, getFlags()); if (store.updateShape()) { oldShape = store.getShape(); } assert newShape.isValid() && oldShape.isValid(); Property newProperty = newShape.getProperty(getKey()); newProperty.setSafe(store, value, oldShape, newShape); }
@Override public final void set(DynamicObject store, Object value, Shape oldShape, Shape newShape) throws IncompatibleLocationException { assert store.getShape() == oldShape : "wrong shape"; assert newShape.isValid(); assert getLocation() != null; getLocation().set(store, value, oldShape, newShape); }
private void setWithShapeSlowCase( DynamicObject store, Object value, Shape currentShape, Shape nextShape) { Shape oldShape = currentShape; if (store.updateShape()) { oldShape = store.getShape(); } LayoutStrategy strategy = ((LayoutImpl) currentShape.getLayout()).getStrategy(); LayoutStrategy.ShapeAndProperty newShapeAndProperty = strategy.generalizeProperty(this, value, (ShapeImpl) oldShape, (ShapeImpl) nextShape); if (store.updateShape()) { oldShape = store.getShape(); } Shape newNextShape = newShapeAndProperty.getShape(); Property newProperty = newShapeAndProperty.getProperty(); assert newNextShape.isValid() && oldShape.isValid(); newProperty.setSafe(store, value, oldShape, newNextShape); }
@Override public final void setGeneric(DynamicObject store, Object value, Shape oldShape, Shape newShape) { assert store.getShape() == oldShape : "wrong old shape"; assert newShape.isValid(); assert getLocation() != null; try { getLocation().set(store, value, oldShape, newShape); } catch (IncompatibleLocationException ex) { setWithShapeSlowCase(store, value, oldShape, newShape); } }
@Override public final void setSafe(DynamicObject store, Object value, Shape oldShape, Shape newShape) { assert store.getShape() == oldShape : "wrong old shape"; assert newShape.isValid(); assert getLocation() != null; try { getLocation().set(store, value, oldShape, newShape); } catch (IncompatibleLocationException ex) { throw new IllegalStateException(); } }