# HG changeset patch # User attila # Date 1373572915 -7200 # Node ID b8ddb7296bae3c7ebca7db73ac8bf81b6dc48422 # Parent f5359cad148c6f3cd1c0b3402ec4e31fa121cb91 8020125: PrintVisitor wasn't printing bodies of FunctionNode within UnaryNode Reviewed-by: jlaskey, lagergren diff -r f5359cad148c -r b8ddb7296bae nashorn/src/jdk/nashorn/internal/ir/UnaryNode.java --- 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(')'); } diff -r f5359cad148c -r b8ddb7296bae nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java --- a/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java Thu Jul 11 22:58:37 2013 +0530 +++ b/nashorn/src/jdk/nashorn/internal/ir/debug/PrintVisitor.java Thu Jul 11 22:01:55 2013 +0200 @@ -41,6 +41,7 @@ import jdk.nashorn.internal.ir.Statement; import jdk.nashorn.internal.ir.SwitchNode; import jdk.nashorn.internal.ir.TryNode; +import jdk.nashorn.internal.ir.UnaryNode; import jdk.nashorn.internal.ir.VarNode; import jdk.nashorn.internal.ir.WhileNode; import jdk.nashorn.internal.ir.WithNode; @@ -205,6 +206,17 @@ } @Override + public boolean enterUnaryNode(final UnaryNode unaryNode) { + unaryNode.toString(sb, new Runnable() { + @Override + public void run() { + unaryNode.rhs().accept(PrintVisitor.this); + } + }); + return false; + } + + @Override public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { expressionStatement.getExpression().accept(this); return false;