Chromium Code Reviews| Index: compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java |
| diff --git a/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java b/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java |
| index 4fc2d0a9116a58d8cba378356a11bcaba844e1bf..ed1cf2c56688994c97fdfee3d1b7bc4b756fed81 100644 |
| --- a/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java |
| +++ b/compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java |
| @@ -12,6 +12,7 @@ import com.google.dart.compiler.util.TextOutput; |
| import com.google.debugging.sourcemap.FilePosition; |
| import java.io.IOException; |
| +import java.util.ArrayList; |
| import java.util.Iterator; |
| import java.util.List; |
| @@ -25,6 +26,8 @@ public class DartToSourceVisitor extends DartVisitor { |
| private List<SourceMapping> mappings = Lists.newArrayList(); |
| private final boolean isDiet; |
| + private final boolean calculateHash; |
|
jbrosenberg
2011/10/11 14:58:44
Much cleaner!
|
| + |
| public DartToSourceVisitor(TextOutput out) { |
| this(out, false); |
| } |
| @@ -32,8 +35,15 @@ public class DartToSourceVisitor extends DartVisitor { |
| public DartToSourceVisitor(TextOutput out, boolean isDiet) { |
| this.out = out; |
| this.isDiet = isDiet; |
| + this.calculateHash = false; |
| } |
| - |
| + |
| + public DartToSourceVisitor(TextOutput out, boolean isDiet, boolean calculateHash) { |
| + this.out = out; |
| + this.isDiet = isDiet; |
| + this.calculateHash = calculateHash; |
| + } |
| + |
| public void generateSourceMap(boolean generate) { |
| this.buildMappings = generate; |
| } |
| @@ -105,8 +115,6 @@ public class DartToSourceVisitor extends DartVisitor { |
| if (x.getReturnTypeNode() != null) { |
| accept(x.getReturnTypeNode()); |
| - } else { |
| - p("function "); |
| } |
| p(" "); |
| @@ -125,6 +133,11 @@ public class DartToSourceVisitor extends DartVisitor { |
| @Override |
| public boolean visit(DartClass x, DartContext ctx) { |
| + int start = 0; |
| + if (calculateHash == true) { |
| + start = out.getPosition(); |
| + } |
| + |
| if (x.isInterface()) { |
| p("interface "); |
| } else { |
| @@ -173,6 +186,9 @@ public class DartToSourceVisitor extends DartVisitor { |
| outdent(); |
| p("}"); |
| + if (calculateHash == true) { |
|
jbrosenberg
2011/10/11 14:58:44
Should this appear after the 2 nl(); calls? Just
codefu
2011/10/11 18:43:55
This emulates the work of older code that called t
jbrosenberg
2011/10/11 21:40:13
But I think we still have calls coming into this m
codefu
2011/10/11 22:07:18
DartNode.java:
return out.toString().trim().hash
|
| + x.setHash(out.toString().substring(start, out.getPosition()).hashCode()); |
| + } |
| nl(); |
| nl(); |
| return false; |
| @@ -764,13 +780,6 @@ public class DartToSourceVisitor extends DartVisitor { |
| p(" "); |
| } |
| DartIdentifier name = x.getName(); |
| - if (name != null) { |
| - if (func.getReturnTypeNode() == null) { |
| - p("function "); |
| - } |
| - } else { |
| - p("function"); |
| - } |
| pFunctionDeclaration(name, x.getFunction()); |
| p(" "); |
| if (x.getFunction().getBody() != null) { |