# HG changeset patch # User Thomas Wuerthinger # Date 1366722467 -7200 # Node ID 9640bb93032789174e0c97d38d66de447570d0ad # Parent cdf10fb2002290b4aaa80a4724b9b010774fc294 Preserve the source section during node rewrites. diff -r cdf10fb20022 -r 9640bb930327 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 Apr 23 15:02:16 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Tue Apr 23 15:07:47 2013 +0200 @@ -135,7 +135,8 @@ } /** - * Replaces this node with another node. + * Replaces this node with another node. If there is a source section (see + * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. * * @param newNode the new node that is the replacement * @param reason a description of the reason for the replacement @@ -144,6 +145,10 @@ @SuppressWarnings({"unchecked"}) public final T replace(T newNode, String reason) { assert this.getParent() != null; + if (sourceSection != null) { + // Pass on the source section to the new node. + newNode.assignSourceSection(sourceSection); + } return (T) this.getParent().replaceChild(this, newNode); } @@ -154,7 +159,8 @@ } /** - * Replaces this node with another node. + * Replaces this node with another node. If there is a source section (see + * {@link #getSourceSection()}) associated with this node, it is transferred to the new node. * * @param newNode the new node that is the replacement * @return the new node