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

Side by Side Diff: pkg/compiler/lib/src/dart2js.dart

Issue 824103005: Revert "Remove Compiler.assembledCode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart_backend/backend.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.cmdline; 5 library dart2js.cmdline;
6 6
7 import 'dart:async' 7 import 'dart:async'
8 show Future, EventSink; 8 show Future, EventSink;
9 import 'dart:convert' show UTF8, LineSplitter; 9 import 'dart:convert' show UTF8, LineSplitter;
10 import 'dart:io' 10 import 'dart:io'
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 continue OUTER; 94 continue OUTER;
95 } 95 }
96 } 96 }
97 throw 'Internal error: "$argument" did not match'; 97 throw 'Internal error: "$argument" did not match';
98 } 98 }
99 } 99 }
100 100
101 FormattingDiagnosticHandler diagnosticHandler; 101 FormattingDiagnosticHandler diagnosticHandler;
102 102
103 Future<api.CompilationResult> compile(List<String> argv) { 103 Future compile(List<String> argv) {
104 stackTraceFilePrefix = '$currentDirectory'; 104 stackTraceFilePrefix = '$currentDirectory';
105 Uri libraryRoot = currentDirectory; 105 Uri libraryRoot = currentDirectory;
106 Uri out = currentDirectory.resolve('out.js'); 106 Uri out = currentDirectory.resolve('out.js');
107 Uri sourceMapOut = currentDirectory.resolve('out.js.map'); 107 Uri sourceMapOut = currentDirectory.resolve('out.js.map');
108 Uri packageRoot = null; 108 Uri packageRoot = null;
109 List<String> options = new List<String>(); 109 List<String> options = new List<String>();
110 bool explicitOut = false; 110 bool explicitOut = false;
111 bool wantHelp = false; 111 bool wantHelp = false;
112 bool wantVersion = false; 112 bool wantVersion = false;
113 String outputLanguage = 'JavaScript'; 113 String outputLanguage = 'JavaScript';
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 diagnosticHandler.info('Package root is $packageRoot'); 416 diagnosticHandler.info('Package root is $packageRoot');
417 417
418 options.add('--out=$out'); 418 options.add('--out=$out');
419 options.add('--source-map=$sourceMapOut'); 419 options.add('--source-map=$sourceMapOut');
420 420
421 RandomAccessFileOutputProvider outputProvider = 421 RandomAccessFileOutputProvider outputProvider =
422 new RandomAccessFileOutputProvider( 422 new RandomAccessFileOutputProvider(
423 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail); 423 out, sourceMapOut, onInfo: diagnosticHandler.info, onFailure: fail);
424 424
425 api.CompilationResult compilationDone(api.CompilationResult result) { 425 compilationDone(String code) {
426 if (analyzeOnly) return result; 426 if (analyzeOnly) return;
427 if (!result.isSuccess) { 427 if (code == null) {
428 fail('Compilation failed.'); 428 fail('Compilation failed.');
429 } 429 }
430 writeString(Uri.parse('$out.deps'), 430 writeString(Uri.parse('$out.deps'),
431 getDepsOutput(inputProvider.sourceFiles)); 431 getDepsOutput(inputProvider.sourceFiles));
432 diagnosticHandler.info( 432 diagnosticHandler.info(
433 'Compiled ${inputProvider.dartCharactersRead} characters Dart ' 433 'Compiled ${inputProvider.dartCharactersRead} characters Dart '
434 '-> ${outputProvider.totalCharactersWritten} characters ' 434 '-> ${outputProvider.totalCharactersWritten} characters '
435 '$outputLanguage in ' 435 '$outputLanguage in '
436 '${relativize(currentDirectory, out, Platform.isWindows)}'); 436 '${relativize(currentDirectory, out, Platform.isWindows)}');
437 if (diagnosticHandler.verbose) { 437 if (diagnosticHandler.verbose) {
438 String input = uriPathToNative(arguments[0]); 438 String input = uriPathToNative(arguments[0]);
439 print('Dart file ($input) compiled to $outputLanguage.'); 439 print('Dart file ($input) compiled to $outputLanguage.');
440 print('Wrote the following files:'); 440 print('Wrote the following files:');
441 for (String filename in outputProvider.allOutputFiles) { 441 for (String filename in outputProvider.allOutputFiles) {
442 print(" $filename"); 442 print(" $filename");
443 } 443 }
444 } else if (!explicitOut) { 444 } else if (!explicitOut) {
445 String input = uriPathToNative(arguments[0]); 445 String input = uriPathToNative(arguments[0]);
446 String output = relativize(currentDirectory, out, Platform.isWindows); 446 String output = relativize(currentDirectory, out, Platform.isWindows);
447 print('Dart file ($input) compiled to $outputLanguage: $output'); 447 print('Dart file ($input) compiled to $outputLanguage: $output');
448 } 448 }
449 return result;
450 } 449 }
451 450
452 return compileFunc(uri, libraryRoot, packageRoot, 451 return compileFunc(uri, libraryRoot, packageRoot,
453 inputProvider, diagnosticHandler, 452 inputProvider, diagnosticHandler,
454 options, outputProvider, environment) 453 options, outputProvider, environment)
455 .then(compilationDone); 454 .then(compilationDone);
456 } 455 }
457 456
458 class AbortLeg { 457 class AbortLeg {
459 final message; 458 final message;
(...skipping 13 matching lines...) Expand all
473 void fail(String message) { 472 void fail(String message) {
474 if (diagnosticHandler != null) { 473 if (diagnosticHandler != null) {
475 diagnosticHandler.diagnosticHandler( 474 diagnosticHandler.diagnosticHandler(
476 null, -1, -1, message, api.Diagnostic.ERROR); 475 null, -1, -1, message, api.Diagnostic.ERROR);
477 } else { 476 } else {
478 print('Error: $message'); 477 print('Error: $message');
479 } 478 }
480 exitFunc(1); 479 exitFunc(1);
481 } 480 }
482 481
483 Future<api.CompilationResult> compilerMain(List<String> arguments) { 482 Future compilerMain(List<String> arguments) {
484 var root = uriPathToNative("/$LIBRARY_ROOT"); 483 var root = uriPathToNative("/$LIBRARY_ROOT");
485 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root'] 484 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root']
486 ..addAll(arguments); 485 ..addAll(arguments);
487 return compile(arguments); 486 return compile(arguments);
488 } 487 }
489 488
490 void help() { 489 void help() {
491 // This message should be no longer than 20 lines. The default 490 // This message should be no longer than 20 lines. The default
492 // terminal size normally 80x24. Two lines are used for the prompts 491 // terminal size normally 80x24. Two lines are used for the prompts
493 // before and after running the compiler. Another two lines may be 492 // before and after running the compiler. Another two lines may be
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 if (arguments.length > 0 && arguments.last == "--batch") { 635 if (arguments.length > 0 && arguments.last == "--batch") {
637 batchMain(arguments.sublist(0, arguments.length - 1)); 636 batchMain(arguments.sublist(0, arguments.length - 1));
638 return; 637 return;
639 } 638 }
640 internalMain(arguments); 639 internalMain(arguments);
641 } 640 }
642 641
643 var exitFunc = exit; 642 var exitFunc = exit;
644 var compileFunc = api.compile; 643 var compileFunc = api.compile;
645 644
646 Future<api.CompilationResult> internalMain(List<String> arguments) { 645 Future internalMain(List<String> arguments) {
647 Future onError(exception, trace) { 646 onError(exception, trace) {
648 try { 647 try {
649 print('The compiler crashed: $exception'); 648 print('The compiler crashed: $exception');
650 } catch (ignored) { 649 } catch (ignored) {
651 print('The compiler crashed: error while printing exception'); 650 print('The compiler crashed: error while printing exception');
652 } 651 }
653 652
654 try { 653 try {
655 if (trace != null) { 654 if (trace != null) {
656 print(trace); 655 print(trace);
657 } 656 }
658 } finally { 657 } finally {
659 exitFunc(253); // 253 is recognized as a crash by our test scripts. 658 exitFunc(253); // 253 is recognized as a crash by our test scripts.
660 } 659 }
661 return new Future.error(exception, trace);
662 } 660 }
663 661
664 try { 662 try {
665 return compilerMain(arguments).catchError(onError); 663 return compilerMain(arguments).catchError(onError);
666 } catch (exception, trace) { 664 } catch (exception, trace) {
667 return onError(exception, trace); 665 onError(exception, trace);
666 return new Future.value();
668 } 667 }
669 } 668 }
670 669
671 const _EXIT_SIGNAL = const Object(); 670 const _EXIT_SIGNAL = const Object();
672 671
673 void batchMain(List<String> batchArguments) { 672 void batchMain(List<String> batchArguments) {
674 int exitCode; 673 int exitCode;
675 exitFunc = (errorCode) { 674 exitFunc = (errorCode) {
676 // Since we only throw another part of the compiler might intercept our 675 // Since we only throw another part of the compiler might intercept our
677 // exception and try to exit with a different code. 676 // exception and try to exit with a different code.
(...skipping 26 matching lines...) Expand all
704 } else if (exitCode == 253) { 703 } else if (exitCode == 253) {
705 print(">>> TEST CRASH"); 704 print(">>> TEST CRASH");
706 } else { 705 } else {
707 print(">>> TEST FAIL"); 706 print(">>> TEST FAIL");
708 } 707 }
709 stderr.writeln(">>> EOF STDERR"); 708 stderr.writeln(">>> EOF STDERR");
710 subscription.resume(); 709 subscription.resume();
711 }); 710 });
712 }); 711 });
713 } 712 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/dart_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698