Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: compiler/java/com/google/dart/compiler/ast/DartToSourceVisitor.java

Issue 8222016: Hashcodes were being improperly calculated for public API of libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More cleanup Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/ast/DartUnit.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+
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) {
+ 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) {
« no previous file with comments | « no previous file | compiler/java/com/google/dart/compiler/ast/DartUnit.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698