comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java @ 21953:633eb3ec30ce

Truffle: fix delete/removeProperty regression
author Andreas Woess <andreas.woess@oracle.com>
date Fri, 12 Jun 2015 14:46:18 +0200
parents c76742cc2c6f
children
comparison
equal deleted inserted replaced
21952:f929f601bdca 21953:633eb3ec30ce
163 ShapeImpl fromShape = (ShapeImpl) fromObject.getShape(); 163 ShapeImpl fromShape = (ShapeImpl) fromObject.getShape();
164 ShapeImpl toShape = getShape(); 164 ShapeImpl toShape = getShape();
165 assert toShape.isRelated(ancestor); 165 assert toShape.isRelated(ancestor);
166 assert toShape.isValid(); 166 assert toShape.isValid();
167 assert ancestor.isValid(); 167 assert ancestor.isValid();
168 for (; toShape != ancestor; toShape = toShape.getParent()) { 168 PropertyMap ancestorMap = ((ShapeImpl) ancestor).getPropertyMap();
169 Transition transitionFromParent = toShape.getTransitionFromParent(); 169 PropertyMap fromMap = fromShape.getPropertyMap();
170 if (transitionFromParent instanceof Transition.AddPropertyTransition) { 170 for (PropertyMap toMap = toShape.getPropertyMap(); !toMap.isEmpty() && toMap != ancestorMap; toMap = toMap.getParentMap()) {
171 Property toProperty = ((Transition.AddPropertyTransition) transitionFromParent).getProperty(); 171 Property toProperty = toMap.getLastProperty();
172 Property fromProperty = fromShape.getProperty(toProperty.getKey()); 172 Property fromProperty = fromMap.get(toProperty.getKey());
173 173
174 // copy only if property has a location and it's not the same as the source location 174 // copy only if property has a location and it's not the same as the source location
175 if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) { 175 if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) {
176 toProperty.setInternal(this, fromProperty.get(fromObject, false)); 176 toProperty.setInternal(this, fromProperty.get(fromObject, false));
177 assert toShape.isValid(); 177 assert toShape.isValid();
178 } 178 }
179 179
180 if (fromShape.getTransitionFromParent() instanceof Transition.AddPropertyTransition && 180 if (fromProperty == fromMap.getLastProperty()) {
181 ((Transition.AddPropertyTransition) fromShape.getTransitionFromParent()).getProperty() == fromProperty) { 181 // no property is looked up twice, so we can skip over to parent
182 // no property is looked up twice, so we can skip over to parent 182 fromMap = fromMap.getParentMap();
183 fromShape = fromShape.getParent();
184 }
185 } 183 }
186 } 184 }
187 } 185 }
188 186
189 @Override 187 @Override