@Override public void dump(Node newNode, Node newChild, CharSequence reason) { if (reason != null) { dumpReplaceChild(newNode, newChild, reason); } else { if (newChild != null) { dumpNewChild(newNode, newChild); } else { dumpNewNode(newNode); } } } };
/** @since 0.8 or earlier */ public static void dumpReplaceChild(Node oldNode, Node newNode, CharSequence reason) { if (AstJsonDumpBuilder != null) { AstJsonDumpBuilder.append("{ \"action\": \"replaceNode\", \"oldId\": \"" + getID(oldNode) + "\", \"newId\": \"" + getID(newNode) + "\", \"reason\": " + quote(reason) + " },\n"); } }
public static void dumpNewNode(Node newNode) { if (AstJsonDumpBuilder != null) { AstJsonDumpBuilder.append("{ \"action\": \"createNode\", \"newId\": \"" + getID(newNode) + "\", \"type\": \"" + getType(newNode) + "\", \"description\": \"" + newNode.getDescription() + "\", \"language\": \"" + newNode.getLanguage() + "\"" + getSourceSectionInfo(newNode) + " },\n"); } }
/** @since 0.8 or earlier */ public static void dumpNewNode(Node newNode) { if (AstJsonDumpBuilder != null) { String language = ""; RootNode root = newNode.getRootNode(); if (root != null) { TruffleLanguage<?> clazz = root.getLanguage(TruffleLanguage.class); if (clazz != null) { language = clazz.getClass().getName(); } } AstJsonDumpBuilder.append("{ \"action\": \"createNode\", \"newId\": \"" + getID(newNode) + "\", \"type\": \"" + getType(newNode) + "\", \"description\": \"" + newNode.getDescription() + "\", \"language\": \"" + language + "\"" + " },\n"); } }
private void adoptHelper(final Node newChild) { assert newChild != null; if (newChild == this) { throw new IllegalStateException("The parent of a node can never be the node itself."); } newChild.parent = this; if (TruffleOptions.TraceASTJSON) { JSONHelper.dumpNewChild(this, newChild); } newChild.adoptHelper(); }
protected Node(SourceSection sourceSection) { CompilerAsserts.neverPartOfCompilation(); this.sourceSection = sourceSection; this.nodeClass = NodeClass.get(getClass()); if (TruffleOptions.TraceASTJSON) { JSONHelper.dumpNewNode(this); } }
private void reportReplace(Node oldNode, Node newNode, CharSequence reason) { Node node = this; while (node != null) { if (node instanceof ReplaceObserver) { ((ReplaceObserver) node).nodeReplaced(oldNode, newNode, reason); } else if (node instanceof RootNode) { CallTarget target = ((RootNode) node).getCallTarget(); if (target instanceof ReplaceObserver) { ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason); } } node = node.getParent(); } if (TruffleOptions.TraceRewrites) { NodeUtil.traceRewrite(this, newNode, reason); } if (TruffleOptions.TraceASTJSON) { JSONHelper.dumpReplaceChild(this, newNode, reason); } }
@Override public JSONObjectBuilder visitShape(Shape shape, Map<? extends Transition, ? extends Shape> transitions) { JSONObjectBuilder sb = JSONHelper.object(); JSONArrayBuilder transitionarray = JSONHelper.array(); for (Entry<? extends Transition, ? extends Shape> entry : transitions.entrySet()) { transitionarray.add(JSONHelper.object().add("transition", dumpTransition(entry.getKey())).add("successor", getId(entry.getValue()))); } JSONArrayBuilder propertiesarray = JSONHelper.array(); for (Property p : shape.getPropertyList()) { propertiesarray.add(dumpProperty(p)); } sb.add("id", getId(shape)); sb.add("properties", propertiesarray); sb.add("transitions", transitionarray); sb.add("predecessor", shape.getParent() != null ? getId(shape.getParent()) : null); sb.add("valid", shape.isValid()); return sb; }
public JSONObjectBuilder dumpLocation(Location location) { JSONObjectBuilder obj = JSONHelper.object(); obj.add("type", (location instanceof TypedLocation ? ((TypedLocation) location).getType() : Object.class).getName()); // if (location instanceof Locations.FieldLocation) { // obj.add("offset", ((Locations.FieldLocation) location).getOffset()); // } // if (location instanceof Locations.ArrayLocation) { // obj.add("index", ((Locations.ArrayLocation) location).getIndex()); // } if (location instanceof Locations.ValueLocation) { obj.add("value", String.valueOf(((Locations.ValueLocation) location).get(null, false))); } return obj; } }
/** @since 0.8 or earlier */ @Deprecated public static void dumpNewNode(Node newNode) { if (AstJsonDumpBuilder != null) { String language = ""; RootNode root = newNode.getRootNode(); if (root != null) { TruffleLanguage<?> clazz = root.getLanguage(TruffleLanguage.class); if (clazz != null) { language = clazz.getClass().getName(); } } AstJsonDumpBuilder.append("{ \"action\": \"createNode\", \"newId\": \"" + getID(newNode) + "\", \"type\": \"" + getType(newNode) + "\", \"description\": \"" + newNode.getDescription() + "\", \"language\": \"" + language + "\"" + " },\n"); } }
public JSONObjectBuilder dumpTransition(Transition transition) { JSONObjectBuilder sb = JSONHelper.object().add("type", transition.getShortName()); if (transition instanceof PropertyTransition) { sb.add("property", dumpProperty(((PropertyTransition) transition).getProperty())); } return sb; }
@Override public void dump(Node newNode, Node newChild, CharSequence reason) { if (reason != null) { dumpReplaceChild(newNode, newChild, reason); } else { if (newChild != null) { dumpNewChild(newNode, newChild); } else { dumpNewNode(newNode); } } } };
public static void dumpReplaceChild(Node oldNode, Node newNode, CharSequence reason) { if (AstJsonDumpBuilder != null) { AstJsonDumpBuilder.append("{ \"action\": \"replaceNode\", \"oldId\": \"" + getID(oldNode) + "\", \"newId\": \"" + getID(newNode) + "\", \"reason\": " + quote(reason) + " },\n"); } }
public JSONObjectBuilder dumpProperty(Property property) { return JSONHelper.object().add("id", property.getKey().toString()).add("location", dumpLocation(property.getLocation())).add("flags", property.getFlags()); }
/** @since 0.8 or earlier */ @Deprecated public static void dumpReplaceChild(Node oldNode, Node newNode, CharSequence reason) { if (AstJsonDumpBuilder != null) { AstJsonDumpBuilder.append("{ \"action\": \"replaceNode\", \"oldId\": \"" + getID(oldNode) + "\", \"newId\": \"" + getID(newNode) + "\", \"reason\": " + quote(reason) + " },\n"); } }