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

Unified Diff: lib/compiler/implementation/emitter.dart

Issue 10579019: First shot at source maps generation in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: lib/compiler/implementation/emitter.dart
diff --git a/lib/compiler/implementation/emitter.dart b/lib/compiler/implementation/emitter.dart
index 3121e1fec87ce642397f0941394cb56826f79d59..9cd1a50fcea4deb5a43b9d21577859343019c6de 100644
--- a/lib/compiler/implementation/emitter.dart
+++ b/lib/compiler/implementation/emitter.dart
@@ -38,6 +38,7 @@ class CodeEmitterTask extends CompilerTask {
boundClosureBuffer = new StringBuffer(),
mainBuffer = new StringBuffer(),
boundClosureCache = new Map<int, String>(),
+ sourceMappings = new List<SourceMappingEntry>(),
super(compiler) {
nativeEmitter = new NativeEmitter(this);
}
@@ -597,7 +598,12 @@ function() {
generatedCode.forEach((Element element, String codeBlock) {
if (!element.isInstanceMember()) {
String functionName = functionNamer(element);
- buffer.add('$isolateProperties.$functionName = $codeBlock;\n\n');
+ buffer.add('$isolateProperties.$functionName = ');
+ int beginPosition = buffer.length;
+ buffer.add(codeBlock);
+ int endPosition = buffer.length;
+ buffer.add(';\n\n');
+ addSourceMapping(element, beginPosition, endPosition);
}
});
}
@@ -1006,4 +1012,13 @@ if (typeof window != 'undefined' && typeof document != 'undefined' &&
});
return compiler.assembledCode;
}
+
+ void addSourceMapping(FunctionElement element, int emittedBeginPosition, int emittedEndPosition) {
podivilov 2012/06/19 16:37:54 This should probably be a method of SourceMapListe
ahe 2012/06/19 17:00:41 Long lines.
podivilov 2012/06/20 09:37:14 Done.
+ SourceFile sourceFile = element.getCompilationUnit().script.file;
+ FunctionExpression expression = element.cachedNode;
+ sourceMappings.add(new SourceMappingEntry(sourceFile, expression.getBeginToken().charOffset, emittedBeginPosition));
+ sourceMappings.add(new SourceMappingEntry(sourceFile, expression.getEndToken().charOffset, emittedEndPosition));
+ }
+
+ final List<SourceMappingEntry> sourceMappings;
}

Powered by Google App Engine
This is Rietveld 408576698