/** @since 0.17 or earlier */ public final void addIndirectTransition(Transition transition, ShapeImpl next) { assert !isShared(); assert next.getParent() != this && !transition.isDirect(); addTransitionInternal(transition, next); }
/** @since 0.17 or earlier */ public final void addIndirectTransition(Transition transition, ShapeImpl next) { assert !isShared(); assert next.getParent() != this && !transition.isDirect(); addTransitionInternal(transition, next); }
/** @since 0.17 or earlier */ protected ShapeImpl removeProperty(ShapeImpl shape, Property property) { assert !shape.isShared(); RemovePropertyTransition transition = new RemovePropertyTransition(property); ShapeImpl cachedShape = shape.queryTransition(transition); if (cachedShape != null) { return ensureValid(cachedShape); } ShapeImpl owningShape = getShapeFromProperty(shape, property.getKey()); if (owningShape != null) { List<Transition> transitionList = new ArrayList<>(); ShapeImpl current = shape; while (current != owningShape) { if (!(current.getTransitionFromParent() instanceof Transition.DirectReplacePropertyTransition) || !((Transition.DirectReplacePropertyTransition) current.getTransitionFromParent()).getPropertyBefore().getKey().equals(property.getKey())) { transitionList.add(current.getTransitionFromParent()); } current = current.parent; } ShapeImpl newShape = owningShape.parent; for (ListIterator<Transition> iterator = transitionList.listIterator(transitionList.size()); iterator.hasPrevious();) { Transition previous = iterator.previous(); newShape = applyTransition(newShape, previous, true); } shape.addIndirectTransition(transition, newShape); return newShape; } else { return null; } }
/** @since 0.17 or earlier */ protected ShapeImpl removeProperty(ShapeImpl shape, Property property) { assert !shape.isShared(); RemovePropertyTransition transition = new RemovePropertyTransition(property); ShapeImpl cachedShape = shape.queryTransition(transition); if (cachedShape != null) { return ensureValid(cachedShape); } ShapeImpl owningShape = getShapeFromProperty(shape, property.getKey()); if (owningShape != null) { List<Transition> transitionList = new ArrayList<>(); ShapeImpl current = shape; while (current != owningShape) { if (!(current.getTransitionFromParent() instanceof Transition.DirectReplacePropertyTransition) || !((Transition.DirectReplacePropertyTransition) current.getTransitionFromParent()).getPropertyBefore().getKey().equals(property.getKey())) { transitionList.add(current.getTransitionFromParent()); } current = current.parent; } ShapeImpl newShape = owningShape.parent; for (ListIterator<Transition> iterator = transitionList.listIterator(transitionList.size()); iterator.hasPrevious();) { Transition previous = iterator.previous(); newShape = applyTransition(newShape, previous, true); } shape.addIndirectTransition(transition, newShape); return newShape; } else { return null; } }
public void visit(Object node, com.oracle.truffle.api.nodes.GraphPrintVisitor.GraphPrintAdapter printer) { if (!printer.visited(node)) { ShapeImpl s = (ShapeImpl) node; printer.createElementForNode(s); String name; if (isRootShape(s)) { name = ("ROOT(" + s.getObjectType() + ")"); } else { name = s.getTransitionFromParent().toString(); if (!s.isValid()) { name = INVALID + name; } } printer.setNodeProperty(s, "name", name); printer.setNodeProperty(s, "valid", s.isValid()); printer.setNodeProperty(s, "leaf", s.isLeaf()); printer.setNodeProperty(s, "identityHashCode", Integer.toHexString(System.identityHashCode(s))); printer.setNodeProperty(s, "objectType", s.getObjectType()); printer.setNodeProperty(s, "shared", s.isShared()); for (Entry<? extends Transition, ? extends ShapeImpl> entry : transitions.entrySet()) { ShapeImpl dst = entry.getValue(); IGVShapeVisitor.this.visitShape((dst)); assert printer.visited(dst); printer.connectNodes(s, dst, entry.getKey().toString()); } } } });
public void visit(Object node, com.oracle.truffle.api.nodes.GraphPrintVisitor.GraphPrintAdapter printer) { if (!printer.visited(node)) { ShapeImpl s = (ShapeImpl) node; printer.createElementForNode(s); String name; if (isRootShape(s)) { name = ("ROOT(" + s.getObjectType() + ")"); } else { name = s.getTransitionFromParent().toString(); if (!s.isValid()) { name = INVALID + name; } } printer.setNodeProperty(s, "name", name); printer.setNodeProperty(s, "valid", s.isValid()); printer.setNodeProperty(s, "leaf", s.isLeaf()); printer.setNodeProperty(s, "identityHashCode", Integer.toHexString(System.identityHashCode(s))); printer.setNodeProperty(s, "objectType", s.getObjectType()); printer.setNodeProperty(s, "shared", s.isShared()); for (Entry<? extends Transition, ? extends ShapeImpl> entry : transitions.entrySet()) { ShapeImpl dst = entry.getValue(); IGVShapeVisitor.this.visitShape((dst)); assert printer.visited(dst); printer.connectNodes(s, dst, entry.getKey().toString()); } } } });
private void copyProperties(DynamicObject fromObject) { ShapeImpl fromShape = (ShapeImpl) fromObject.getShape(); ShapeImpl toShape = getShape(); assert toShape.isRelated(fromShape); assert toShape.isValid(); assert !fromShape.isShared(); PropertyMap fromMap = fromShape.getPropertyMap(); for (Iterator<Property> toMapIt = toShape.getPropertyMap().reverseOrderedValueIterator(); toMapIt.hasNext();) { Property toProperty = toMapIt.next(); Property fromProperty = fromMap.get(toProperty.getKey()); // copy only if property has a location and it's not the same as the source location if (!toProperty.getLocation().isValue() && !toProperty.getLocation().equals(fromProperty.getLocation())) { toProperty.setInternal(this, fromProperty.get(fromObject, false)); assert toShape.isValid(); } } }
private void copyProperties(DynamicObject fromObject) { ShapeImpl fromShape = (ShapeImpl) fromObject.getShape(); ShapeImpl toShape = getShapeImpl(); assert toShape.isRelated(fromShape); assert toShape.isValid(); assert !fromShape.isShared(); PropertyMap fromMap = fromShape.getPropertyMap(); for (Iterator<Property> toMapIt = toShape.getPropertyMap().reverseOrderedValueIterator(); toMapIt.hasNext();) { Property toProperty = toMapIt.next(); Property fromProperty = fromMap.get(toProperty.getKey()); // copy only if property has a location and it's not the same as the source location if (!toProperty.getLocation().isValue() && !toProperty.getLocation().equals(fromProperty.getLocation())) { toProperty.setInternal(this, fromProperty.get(fromObject, false)); assert toShape.isValid(); } } }