nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java
changeset 18869 b8ddb7296bae
parent 18867 bc91e3fcc5ba
child 20928 3ff39d5c8c08
--- a/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java	Thu Jul 11 22:58:37 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java	Thu Jul 11 22:01:55 2013 +0200
@@ -131,6 +131,22 @@
 
     @Override
     public void toString(final StringBuilder sb) {
+        toString(sb, new Runnable() {
+            @Override
+            public void run() {
+                sb.append(rhs().toString());
+            }
+        });
+    }
+
+    /**
+     * Creates the string representation of this unary node, delegating the creation of the string representation of its
+     * operand to a specified runnable.
+     * @param sb the string builder to use
+     * @param rhsStringBuilder the runnable that appends the string representation of the operand to the string builder
+     * when invoked.
+     */
+    public void toString(final StringBuilder sb, final Runnable rhsStringBuilder) {
         final TokenType type      = tokenType();
         final String    name      = type.getName();
         final boolean   isPostfix = type == DECPOSTFIX || type == INCPOSTFIX;
@@ -162,7 +178,7 @@
         if (rhsParen) {
             sb.append('(');
         }
-        rhs().toString(sb);
+        rhsStringBuilder.run();
         if (rhsParen) {
             sb.append(')');
         }