Added comments, small bugfix post the long emulation merge in response to review comments. Suggested by: spoon Review by: spoon git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2173 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java index c14e418..c3ce727 100644 --- a/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java +++ b/dev/core/src/com/google/gwt/dev/jjs/impl/DeadCodeElimination.java
@@ -82,7 +82,17 @@ private JClassType currentClass; /** - * Expressions whose result does not matter. + * Expressions whose result does not matter. A parent node should add any + * children whose result does not matter to this set during the parent's + * <code>visit()</code> method. It should then remove those children + * during its own <code>endVisit()</code>. + * + * TODO: there's a latent bug here: some immutable nodes (such as literals) + * can be multiply referenced in the AST. In theory, one reference to that + * node could be put into this set while another reference actually contains + * a result that is needed. In practice this is okay at the moment since the + * existing uses of <code>ignoringExpressionOutput</code> are with mutable + * nodes. */ private Set<JExpression> ignoringExpressionOutput = new HashSet<JExpression>(); @@ -378,6 +388,7 @@ public void endVisit(JMultiExpression x, Context ctx) { List<JExpression> exprs = x.exprs; if (exprs.size() > 1) { + // Remove the non-final children we previously added. List<JExpression> nonFinalChildren = exprs.subList(0, exprs.size() - 1); ignoringExpressionOutput.removeAll(nonFinalChildren); } @@ -425,7 +436,7 @@ if (x.getOp().isModifying()) { lvalues.remove(x.getArg()); } - if (x == ignoringExpressionOutput) { + if (ignoringExpressionOutput.contains(x)) { JPrefixOperation newOp = new JPrefixOperation(program, x.getSourceInfo(), x.getOp(), x.getArg()); ctx.replaceMe(newOp);
diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/LongEmulationNormalizer.java b/dev/core/src/com/google/gwt/dev/jjs/impl/LongEmulationNormalizer.java index bdc3eb8..0127090 100644 --- a/dev/core/src/com/google/gwt/dev/jjs/impl/LongEmulationNormalizer.java +++ b/dev/core/src/com/google/gwt/dev/jjs/impl/LongEmulationNormalizer.java
@@ -149,7 +149,7 @@ case AND: case OR: throw new InternalCompilerException( - "AND and OR sould not have long operands"); + "AND and OR should not have long operands"); case ASG: // Nothing to do. @@ -183,7 +183,7 @@ return "neg"; case NOT: throw new InternalCompilerException( - "NOT sould not have a long operand"); + "NOT should not have a long operand"); case BIT_NOT: return "not"; default: