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

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: 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 e463a62ec3b58d9b12481d75fa0e3a9eabf051ef..f184553252ac6fa12a5cc3e5e36bb9530f579a33 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;
@@ -91,6 +92,10 @@ void compile(List<String> argv) {
out = cwd.resolve(nativeToUriPath(extractParameter(argument)));
}
+ setSourceMapOutput(String argument) {
+ sourceMapOut = cwd.resolve(nativeToUriPath(extractParameter(argument)));
+ }
+
handleShortOptions(String argument) {
var shortOptions = argument.substring(1).splitChars();
for (var shortOption in shortOptions) {
@@ -120,9 +125,11 @@ 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),
new OptionHandler('--allow-mock-compilation', passThrough),
new OptionHandler('--unparse-validation', passThrough),
new OptionHandler('--no-colors', (_) => colors.enabled = false),
ahe 2012/06/19 17:00:41 I think you accidentally copied a line here.
podivilov 2012/06/20 09:37:14 Done.
+ new OptionHandler('--no-colors', (_) => colors.enabled = false),
new OptionHandler('--enable[_-]checked[_-]mode|--checked',
(_) => passThrough('--enable-checked-mode')),
new OptionHandler(@'--help|/\?|/h', (_) => wantHelp = true),
@@ -202,11 +209,16 @@ 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;
+ api.CompiledScript script = api.compile(
+ uri, libraryRoot, packageRoot, provider, handler, options).value;
+ String code = script.code;
if (code === null) {
fail('Error: Compilation failed.');
}
+ if (sourceMapOut !== null) {
+ writeString(sourceMapOut, script.sourceMap);
+ 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