# HG changeset patch # User Christian Humer # Date 1369158233 -7200 # Node ID ba02d19dd3cc325809c45efa498f1f830751366a # Parent c15fd053efb6576b4b13a904440e033dce43d4a7 Added an onReplace method to Node to provide a way for a guest language implementation to use replace tracing. diff -r c15fd053efb6 -r ba02d19dd3cc graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Tue May 21 19:22:29 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Tue May 21 19:43:53 2013 +0200 @@ -149,6 +149,7 @@ // Pass on the source section to the new node. newNode.assignSourceSection(sourceSection); } + onReplace(newNode, reason); return (T) this.getParent().replaceChild(this, newNode); } @@ -170,6 +171,16 @@ } /** + * Intended to be implemented by subclasses of {@link Node} to receive a notification when the + * node is rewritten. This method is invoked before the actual replace has happened. + * + * @param newNode the replacement node + * @param reason the reason the replace supplied + */ + protected void onReplace(Node newNode, String reason) { + } + + /** * Invokes the {@link NodeVisitor#visit(Node)} method for this node and recursively also for all * child nodes. *