Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/DynamicObjectImpl.java @ 18677:8d8523ed37e3
OM: copy hidden properties, too
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Sat, 13 Dec 2014 03:23:40 +0100 |
parents | 2c3666f44855 |
children | 6db7923af642 |
comparison
equal
deleted
inserted
replaced
18676:1c12cf39281d | 18677:8d8523ed37e3 |
---|---|
154 setShapeAndResize(newShape); | 154 setShapeAndResize(newShape); |
155 copyProperties(original, deletedParentShape); | 155 copyProperties(original, deletedParentShape); |
156 } | 156 } |
157 | 157 |
158 public final void copyProperties(DynamicObject fromObject, Shape ancestor) { | 158 public final void copyProperties(DynamicObject fromObject, Shape ancestor) { |
159 Shape fromShape = fromObject.getShape(); | 159 ShapeImpl fromShape = (ShapeImpl) fromObject.getShape(); |
160 Shape toShape = getShape(); | 160 ShapeImpl toShape = getShape(); |
161 assert toShape.isRelated(ancestor); | 161 assert toShape.isRelated(ancestor); |
162 assert toShape.isValid(); | 162 assert toShape.isValid(); |
163 assert ancestor.isValid(); | 163 assert ancestor.isValid(); |
164 for (; toShape != ancestor; toShape = toShape.getParent()) { | 164 for (; toShape != ancestor; toShape = toShape.getParent()) { |
165 Property toProperty = toShape.getLastProperty(); | 165 Transition transitionFromParent = toShape.getTransitionFromParent(); |
166 // assumption: hidden properties won't change and don't need copying | 166 if (transitionFromParent instanceof Transition.AddPropertyTransition) { |
167 if (!toProperty.isHidden()) { | 167 Property toProperty = ((Transition.AddPropertyTransition) transitionFromParent).getProperty(); |
168 assert fromShape.hasProperty(toProperty.getKey()); | |
169 Property fromProperty = fromShape.getProperty(toProperty.getKey()); | 168 Property fromProperty = fromShape.getProperty(toProperty.getKey()); |
169 | |
170 // copy only if property has a location and it's not the same as the source location | 170 // copy only if property has a location and it's not the same as the source location |
171 if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) { | 171 if (toProperty.getLocation() != null && !(toProperty.getLocation() instanceof ValueLocation) && !toProperty.getLocation().equals(fromProperty.getLocation())) { |
172 toProperty.setInternal(this, fromProperty.get(fromObject, false)); | 172 toProperty.setInternal(this, fromProperty.get(fromObject, false)); |
173 assert toShape.isValid(); | 173 assert toShape.isValid(); |
174 } | 174 } |
175 | 175 |
176 if (fromShape.getLastProperty() == fromProperty) { | 176 if (fromShape.getTransitionFromParent() instanceof Transition.AddPropertyTransition && |
177 ((Transition.AddPropertyTransition) fromShape.getTransitionFromParent()).getProperty() == fromProperty) { | |
177 // no property is looked up twice, so we can skip over to parent | 178 // no property is looked up twice, so we can skip over to parent |
178 fromShape = fromShape.getParent(); | 179 fromShape = fromShape.getParent(); |
179 } | 180 } |
180 } | 181 } |
181 } | 182 } |