1.1 --- a/src/jdk/nashorn/internal/ir/UnaryNode.java Tue Mar 19 11:03:24 2013 -0300 1.2 +++ b/src/jdk/nashorn/internal/ir/UnaryNode.java Sat Mar 23 00:58:39 2013 +0100 1.3 @@ -41,7 +41,7 @@ 1.4 */ 1.5 public class UnaryNode extends Node implements Assignment<Node> { 1.6 /** Right hand side argument. */ 1.7 - protected Node rhs; 1.8 + private Node rhs; 1.9 1.10 /** 1.11 * Constructor 1.12 @@ -104,6 +104,11 @@ 1.13 } 1.14 1.15 @Override 1.16 + public Node setAssignmentDest(Node n) { 1.17 + return setRHS(n); 1.18 + } 1.19 + 1.20 + @Override 1.21 public Node getAssignmentSource() { 1.22 return getAssignmentDest(); 1.23 } 1.24 @@ -132,9 +137,8 @@ 1.25 */ 1.26 @Override 1.27 public Node accept(final NodeVisitor visitor) { 1.28 - if (visitor.enter(this) != null) { 1.29 - rhs = rhs.accept(visitor); 1.30 - return visitor.leave(this); 1.31 + if (visitor.enterUnaryNode(this) != null) { 1.32 + return visitor.leaveUnaryNode(setRHS(rhs.accept(visitor))); 1.33 } 1.34 1.35 return this; 1.36 @@ -212,10 +216,12 @@ 1.37 * @see BinaryNode 1.38 * 1.39 * @param rhs right hand side or expression node 1.40 + * @return a node equivalent to this one except for the requested change. 1.41 */ 1.42 - public void setRHS(final Node rhs) { 1.43 - this.rhs = rhs; 1.44 + public UnaryNode setRHS(final Node rhs) { 1.45 + if(this.rhs == rhs) return this; 1.46 + final UnaryNode n = (UnaryNode)clone(); 1.47 + n.rhs = rhs; 1.48 + return n; 1.49 } 1.50 - 1.51 - 1.52 }