Index: pkg/compiler/lib/src/js/js.dart |
diff --git a/pkg/compiler/lib/src/js/js.dart b/pkg/compiler/lib/src/js/js.dart |
index ec8766a836457af3dfe0b7432ac499c3292616d6..c6a1a2b70203a705cab831e9200ce900f3556065 100644 |
--- a/pkg/compiler/lib/src/js/js.dart |
+++ b/pkg/compiler/lib/src/js/js.dart |
@@ -33,6 +33,7 @@ class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext { |
final leg.Compiler compiler; |
final DumpInfoTask monitor; |
final CodeBuffer outBuffer = new CodeBuffer(); |
+ Node rootNode; |
Dart2JSJavaScriptPrintingContext(leg.Compiler this.compiler, |
DumpInfoTask this.monitor); |
@@ -45,19 +46,35 @@ class Dart2JSJavaScriptPrintingContext implements JavaScriptPrintingContext { |
outBuffer.add(string); |
} |
- void enterNode(Node node) { |
+ void enterNode(Node node, int startPosition) { |
SourceInformation sourceInformation = node.sourceInformation; |
if (sourceInformation != null) { |
- sourceInformation.beginMapping(outBuffer); |
+ if (rootNode == null) { |
+ rootNode = node; |
+ } |
+ if (sourceInformation.startPosition != null) { |
+ outBuffer.addSourceLocation( |
+ startPosition, sourceInformation.startPosition); |
+ } |
} |
- if (monitor != null) monitor.enteringAst(node, outBuffer.length); |
} |
- void exitNode(Node node) { |
- if (monitor != null) monitor.exitingAst(node, outBuffer.length); |
+ void exitNode(Node node, |
+ int startPosition, |
+ int endPosition, |
+ int closingPosition) { |
SourceInformation sourceInformation = node.sourceInformation; |
if (sourceInformation != null) { |
- sourceInformation.endMapping(outBuffer); |
+ if (sourceInformation.endPosition != null) { |
+ outBuffer.addSourceLocation(endPosition, sourceInformation.endPosition); |
+ } |
+ if (rootNode == node) { |
+ outBuffer.addSourceLocation(endPosition, null); |
+ rootNode = null; |
+ } |
+ } |
+ if (monitor != null) { |
+ monitor.recordAstSize(node, endPosition - startPosition); |
} |
} |
} |