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

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

Issue 832363002: 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
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 compile(List<String> argv) { 103 Future<api.CompilationResult> 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 compilationDone(String code) { 425 api.CompilationResult compilationDone(api.CompilationResult result) {
426 if (analyzeOnly) return; 426 if (analyzeOnly) return result;
427 if (code == null) { 427 if (!result.isSuccess) {
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;
449 } 450 }
450 451
451 return compileFunc(uri, libraryRoot, packageRoot, 452 return compileFunc(uri, libraryRoot, packageRoot,
452 inputProvider, diagnosticHandler, 453 inputProvider, diagnosticHandler,
453 options, outputProvider, environment) 454 options, outputProvider, environment)
454 .then(compilationDone); 455 .then(compilationDone);
455 } 456 }
456 457
457 class AbortLeg { 458 class AbortLeg {
458 final message; 459 final message;
(...skipping 13 matching lines...) Expand all
472 void fail(String message) { 473 void fail(String message) {
473 if (diagnosticHandler != null) { 474 if (diagnosticHandler != null) {
474 diagnosticHandler.diagnosticHandler( 475 diagnosticHandler.diagnosticHandler(
475 null, -1, -1, message, api.Diagnostic.ERROR); 476 null, -1, -1, message, api.Diagnostic.ERROR);
476 } else { 477 } else {
477 print('Error: $message'); 478 print('Error: $message');
478 } 479 }
479 exitFunc(1); 480 exitFunc(1);
480 } 481 }
481 482
482 Future compilerMain(List<String> arguments) { 483 Future<api.CompilationResult> compilerMain(List<String> arguments) {
483 var root = uriPathToNative("/$LIBRARY_ROOT"); 484 var root = uriPathToNative("/$LIBRARY_ROOT");
484 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root'] 485 arguments = <String>['--library-root=${Platform.script.toFilePath()}$root']
485 ..addAll(arguments); 486 ..addAll(arguments);
486 return compile(arguments); 487 return compile(arguments);
487 } 488 }
488 489
489 void help() { 490 void help() {
490 // This message should be no longer than 20 lines. The default 491 // This message should be no longer than 20 lines. The default
491 // terminal size normally 80x24. Two lines are used for the prompts 492 // terminal size normally 80x24. Two lines are used for the prompts
492 // before and after running the compiler. Another two lines may be 493 // before and after running the compiler. Another two lines may be
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 if (arguments.length > 0 && arguments.last == "--batch") { 636 if (arguments.length > 0 && arguments.last == "--batch") {
636 batchMain(arguments.sublist(0, arguments.length - 1)); 637 batchMain(arguments.sublist(0, arguments.length - 1));
637 return; 638 return;
638 } 639 }
639 internalMain(arguments); 640 internalMain(arguments);
640 } 641 }
641 642
642 var exitFunc = exit; 643 var exitFunc = exit;
643 var compileFunc = api.compile; 644 var compileFunc = api.compile;
644 645
645 Future internalMain(List<String> arguments) { 646 Future<api.CompilationResult> internalMain(List<String> arguments) {
646 onError(exception, trace) { 647 api.CompilationResult onError(exception, trace) {
647 try { 648 try {
648 print('The compiler crashed: $exception'); 649 print('The compiler crashed: $exception');
649 } catch (ignored) { 650 } catch (ignored) {
650 print('The compiler crashed: error while printing exception'); 651 print('The compiler crashed: error while printing exception');
651 } 652 }
652 653
653 try { 654 try {
654 if (trace != null) { 655 if (trace != null) {
655 print(trace); 656 print(trace);
656 } 657 }
657 } finally { 658 } finally {
658 exitFunc(253); // 253 is recognized as a crash by our test scripts. 659 exitFunc(253); // 253 is recognized as a crash by our test scripts.
659 } 660 }
661 return new api.CompilationResult.error(exception, trace);
660 } 662 }
661 663
662 try { 664 try {
663 return compilerMain(arguments).catchError(onError); 665 return compilerMain(arguments).catchError(onError);
664 } catch (exception, trace) { 666 } catch (exception, trace) {
665 onError(exception, trace); 667 return new Future<api.CompilationResult>.value(onError(exception, trace));
666 return new Future.value();
667 } 668 }
668 } 669 }
669 670
670 const _EXIT_SIGNAL = const Object(); 671 const _EXIT_SIGNAL = const Object();
671 672
672 void batchMain(List<String> batchArguments) { 673 void batchMain(List<String> batchArguments) {
673 int exitCode; 674 int exitCode;
674 exitFunc = (errorCode) { 675 exitFunc = (errorCode) {
675 // Since we only throw another part of the compiler might intercept our 676 // Since we only throw another part of the compiler might intercept our
676 // exception and try to exit with a different code. 677 // exception and try to exit with a different code.
(...skipping 26 matching lines...) Expand all
703 } else if (exitCode == 253) { 704 } else if (exitCode == 253) {
704 print(">>> TEST CRASH"); 705 print(">>> TEST CRASH");
705 } else { 706 } else {
706 print(">>> TEST FAIL"); 707 print(">>> TEST FAIL");
707 } 708 }
708 stderr.writeln(">>> EOF STDERR"); 709 stderr.writeln(">>> EOF STDERR");
709 subscription.resume(); 710 subscription.resume();
710 }); 711 });
711 }); 712 });
712 } 713 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698