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

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: Return source map via diagnostic handler. 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/dart2js.dart
diff --git a/lib/compiler/implementation/dart2js.dart b/lib/compiler/implementation/dart2js.dart
index 2bfd2c0c79d3edf4381cc603809b7203e3c86ca3..04ba44abd5e27b2adcb6853dcce3ee0f60da0b92 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 = null;
Uri packageRoot = null;
List<String> options = new List<String>();
bool explicitOut = false;
@@ -92,6 +93,11 @@ void compile(List<String> argv) {
out = cwd.resolve(nativeToUriPath(extractParameter(argument)));
}
+ setSourceMapOutput(String argument) {
+ sourceMapOut = cwd.resolve(nativeToUriPath(extractParameter(argument)));
+ passThrough(argument);
+ }
+
handleShortOptions(String argument) {
var shortOptions = argument.substring(1).splitChars();
for (var shortOption in shortOptions) {
@@ -121,6 +127,7 @@ void compile(List<String> argv) {
new OptionHandler('--verbose', (_) => verbose = true),
new OptionHandler('--library-root=.+', setLibraryRoot),
new OptionHandler('--out=.+|-o.+', setOutput),
+ new OptionHandler('--source-map-out=.+', setSourceMapOutput),
ahe 2012/06/20 11:56:59 I just talked to the bigwigs. We want to turn on s
podivilov 2012/06/20 14:15:15 Done.
new OptionHandler('--allow-mock-compilation', passThrough),
new OptionHandler('--unparse-validation', passThrough),
new OptionHandler('--no-colors', (_) => enableColors = false),
@@ -181,6 +188,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;
@@ -228,11 +242,14 @@ void compile(List<String> argv) {
// TODO(ahe): We expect the future to be complete and call value
// directly. In effect, we don't support truly asynchronous API.
- String code = api.compile(uri, libraryRoot, packageRoot, provider, handler,
- options).value;
+ String code = api.compile(
+ uri, libraryRoot, packageRoot, provider, handler, options).value;
ahe 2012/06/20 11:56:59 This change seem unnecessary.
podivilov 2012/06/20 14:15:15 Done.
if (code === null) {
fail('Error: Compilation failed.');
}
+ if (sourceMapOut !== null) {
+ code = '$code\n//@ sourceMappingURL=$sourceMapOut';
+ }
writeString(out, code);
int jsBytesWritten = code.length;
info('compiled $dartBytesRead bytes Dart -> $jsBytesWritten bytes JS '

Powered by Google App Engine
This is Rietveld 408576698