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: lib/compiler/implementation/dart2js.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: Fix the tests. 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
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart2js.dart
diff --git a/lib/compiler/implementation/dart2js.dart b/lib/compiler/implementation/dart2js.dart
index 2bfd2c0c79d3edf4381cc603809b7203e3c86ca3..a4ce8c0ad021f619be40926d78c1adb932a2968a 100644
--- a/lib/compiler/implementation/dart2js.dart
+++ b/lib/compiler/implementation/dart2js.dart
@@ -71,6 +71,7 @@ void compile(List<String> argv) {
bool verbose = false;
Uri libraryRoot = cwd;
Uri out = cwd.resolve('out.js');
+ Uri sourceMapOut = cwd.resolve('out.js.map');
Uri packageRoot = null;
List<String> options = new List<String>();
bool explicitOut = false;
@@ -90,6 +91,7 @@ void compile(List<String> argv) {
setOutput(String argument) {
explicitOut = true;
out = cwd.resolve(nativeToUriPath(extractParameter(argument)));
+ sourceMapOut = new Uri.fromString('$out.map');
}
handleShortOptions(String argument) {
@@ -181,6 +183,13 @@ void compile(List<String> argv) {
void handler(Uri uri, int begin, int end, String message,
api.Diagnostic kind) {
+ if (kind.name === 'source map') {
+ // TODO(podivilov): We should find a better way to return source maps from
+ // emitter. Using diagnostic handler for that purpose is a temporary hack.
+ writeString(sourceMapOut, message);
+ return;
+ }
+
if (isAborting) return;
isAborting = kind === api.Diagnostic.CRASH;
bool fatal = (kind.ordinal & FATAL) != 0;
@@ -233,6 +242,7 @@ void compile(List<String> argv) {
if (code === null) {
fail('Error: Compilation failed.');
}
+ code = '$code\n//@ sourceMappingURL=${relativize(out, sourceMapOut)}';
writeString(out, code);
int jsBytesWritten = code.length;
info('compiled $dartBytesRead bytes Dart -> $jsBytesWritten bytes JS '
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | lib/compiler/implementation/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698