OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 /** | 7 /** |
8 * If true, print a warning for each method that was resolved, but not | 8 * If true, print a warning for each method that was resolved, but not |
9 * compiled. | 9 * compiled. |
10 */ | 10 */ |
11 const bool REPORT_EXCESS_RESOLUTION = false; | 11 const bool REPORT_EXCESS_RESOLUTION = false; |
12 | 12 |
13 /** | 13 /** |
14 * If true, dump the inferred types after compilation. | 14 * If true, dump the inferred types after compilation. |
15 */ | 15 */ |
16 const bool DUMP_INFERRED_TYPES = false; | 16 const bool DUMP_INFERRED_TYPES = false; |
17 | 17 |
18 /** | 18 /** |
19 * A string to identify the revision or build. | |
20 * | |
21 * This ID is displayed if the compiler crashes and in verbose mode, and is | |
22 * an aid in reproducing bug reports. | |
23 * | |
24 * The actual string is rewritten during the SDK build process. | |
25 */ | |
26 const String BUILD_ID = 'build number could not be determined'; | |
27 | |
28 /** | |
29 * Contains backend-specific data that is used throughout the compilation of | 19 * Contains backend-specific data that is used throughout the compilation of |
30 * one work item. | 20 * one work item. |
31 */ | 21 */ |
32 class ItemCompilationContext { | 22 class ItemCompilationContext { |
33 } | 23 } |
34 | 24 |
35 abstract class WorkItem { | 25 abstract class WorkItem { |
36 final ItemCompilationContext compilationContext; | 26 final ItemCompilationContext compilationContext; |
37 /** | 27 /** |
38 * Documentation wanted -- johnniwinther | 28 * Documentation wanted -- johnniwinther |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 ResolverTask resolver; | 356 ResolverTask resolver; |
367 closureMapping.ClosureTask closureToClassMapper; | 357 closureMapping.ClosureTask closureToClassMapper; |
368 TypeCheckerTask checker; | 358 TypeCheckerTask checker; |
369 ti.TypesTask typesTask; | 359 ti.TypesTask typesTask; |
370 Backend backend; | 360 Backend backend; |
371 ConstantHandler constantHandler; | 361 ConstantHandler constantHandler; |
372 ConstantHandler metadataHandler; | 362 ConstantHandler metadataHandler; |
373 EnqueueTask enqueuer; | 363 EnqueueTask enqueuer; |
374 CompilerTask fileReadingTask; | 364 CompilerTask fileReadingTask; |
375 DeferredLoadTask deferredLoadTask; | 365 DeferredLoadTask deferredLoadTask; |
| 366 String buildId; |
376 | 367 |
377 static const SourceString MAIN = const SourceString('main'); | 368 static const SourceString MAIN = const SourceString('main'); |
378 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); | 369 static const SourceString CALL_OPERATOR_NAME = const SourceString('call'); |
379 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); | 370 static const SourceString NO_SUCH_METHOD = const SourceString('noSuchMethod'); |
380 static const int NO_SUCH_METHOD_ARG_COUNT = 1; | 371 static const int NO_SUCH_METHOD_ARG_COUNT = 1; |
381 static const SourceString CREATE_INVOCATION_MIRROR = | 372 static const SourceString CREATE_INVOCATION_MIRROR = |
382 const SourceString('createInvocationMirror'); | 373 const SourceString('createInvocationMirror'); |
383 static const SourceString INVOKE_ON = const SourceString('invokeOn'); | 374 static const SourceString INVOKE_ON = const SourceString('invokeOn'); |
384 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); | 375 static const SourceString RUNTIME_TYPE = const SourceString('runtimeType'); |
385 static const SourceString START_ROOT_ISOLATE = | 376 static const SourceString START_ROOT_ISOLATE = |
(...skipping 25 matching lines...) Expand all Loading... |
411 bool emitJavaScript: true, | 402 bool emitJavaScript: true, |
412 bool generateSourceMap: true, | 403 bool generateSourceMap: true, |
413 bool disallowUnsafeEval: false, | 404 bool disallowUnsafeEval: false, |
414 bool analyzeAll: false, | 405 bool analyzeAll: false, |
415 bool analyzeOnly: false, | 406 bool analyzeOnly: false, |
416 bool analyzeSignaturesOnly: false, | 407 bool analyzeSignaturesOnly: false, |
417 bool rejectDeprecatedFeatures: false, | 408 bool rejectDeprecatedFeatures: false, |
418 bool checkDeprecationInSdk: false, | 409 bool checkDeprecationInSdk: false, |
419 bool preserveComments: false, | 410 bool preserveComments: false, |
420 bool verbose: false, | 411 bool verbose: false, |
| 412 String buildId: "build number could not be determined", |
421 outputProvider, | 413 outputProvider, |
422 List<String> strips: const []}) | 414 List<String> strips: const []}) |
423 : tracer = tracer, | 415 : tracer = tracer, |
424 enableTypeAssertions = enableTypeAssertions, | 416 enableTypeAssertions = enableTypeAssertions, |
425 enableUserAssertions = enableUserAssertions, | 417 enableUserAssertions = enableUserAssertions, |
426 enableConcreteTypeInference = enableConcreteTypeInference, | 418 enableConcreteTypeInference = enableConcreteTypeInference, |
427 maxConcreteTypeSize = maxConcreteTypeSize, | 419 maxConcreteTypeSize = maxConcreteTypeSize, |
428 enableMinification = enableMinification, | 420 enableMinification = enableMinification, |
429 enableNativeLiveTypeAnalysis = enableNativeLiveTypeAnalysis, | 421 enableNativeLiveTypeAnalysis = enableNativeLiveTypeAnalysis, |
430 analyzeAll = analyzeAll, | 422 analyzeAll = analyzeAll, |
431 rejectDeprecatedFeatures = rejectDeprecatedFeatures, | 423 rejectDeprecatedFeatures = rejectDeprecatedFeatures, |
432 checkDeprecationInSdk = checkDeprecationInSdk, | 424 checkDeprecationInSdk = checkDeprecationInSdk, |
433 preserveComments = preserveComments, | 425 preserveComments = preserveComments, |
434 verbose = verbose, | 426 verbose = verbose, |
435 libraries = new Map<String, LibraryElement>(), | 427 libraries = new Map<String, LibraryElement>(), |
436 progress = new Stopwatch(), | 428 progress = new Stopwatch(), |
| 429 this.buildId = buildId, |
437 this.analyzeOnly = analyzeOnly || analyzeSignaturesOnly, | 430 this.analyzeOnly = analyzeOnly || analyzeSignaturesOnly, |
438 this.analyzeSignaturesOnly = analyzeSignaturesOnly, | 431 this.analyzeSignaturesOnly = analyzeSignaturesOnly, |
439 this.outputProvider = | 432 this.outputProvider = |
440 (outputProvider == null) ? NullSink.outputProvider : outputProvider | 433 (outputProvider == null) ? NullSink.outputProvider : outputProvider |
441 | 434 |
442 { | 435 { |
443 progress.start(); | 436 progress.start(); |
444 world = new World(this); | 437 world = new World(this); |
445 | 438 |
446 closureMapping.ClosureNamer closureNamer; | 439 closureMapping.ClosureNamer closureNamer; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 void unhandledExceptionOnElement(Element element) { | 503 void unhandledExceptionOnElement(Element element) { |
511 if (hasCrashed) return; | 504 if (hasCrashed) return; |
512 hasCrashed = true; | 505 hasCrashed = true; |
513 reportDiagnostic(spanFromElement(element), | 506 reportDiagnostic(spanFromElement(element), |
514 MessageKind.COMPILER_CRASHED.error().toString(), | 507 MessageKind.COMPILER_CRASHED.error().toString(), |
515 api.Diagnostic.CRASH); | 508 api.Diagnostic.CRASH); |
516 pleaseReportCrash(); | 509 pleaseReportCrash(); |
517 } | 510 } |
518 | 511 |
519 void pleaseReportCrash() { | 512 void pleaseReportCrash() { |
520 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': BUILD_ID})); | 513 print(MessageKind.PLEASE_REPORT_THE_CRASH.message({'buildId': buildId})); |
521 } | 514 } |
522 | 515 |
523 void cancel(String reason, {Node node, Token token, | 516 void cancel(String reason, {Node node, Token token, |
524 HInstruction instruction, Element element}) { | 517 HInstruction instruction, Element element}) { |
525 assembledCode = null; // Compilation failed. Make sure that we | 518 assembledCode = null; // Compilation failed. Make sure that we |
526 // don't return a bogus result. | 519 // don't return a bogus result. |
527 SourceSpan span = null; | 520 SourceSpan span = null; |
528 if (node != null) { | 521 if (node != null) { |
529 span = spanFromNode(node); | 522 span = spanFromNode(node); |
530 } else if (token != null) { | 523 } else if (token != null) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 * Get an [Uri] pointing to a patch for the dart: library with | 710 * Get an [Uri] pointing to a patch for the dart: library with |
718 * the given path. Returns null if there is no patch. | 711 * the given path. Returns null if there is no patch. |
719 */ | 712 */ |
720 Uri resolvePatchUri(String dartLibraryPath); | 713 Uri resolvePatchUri(String dartLibraryPath); |
721 | 714 |
722 void runCompiler(Uri uri) { | 715 void runCompiler(Uri uri) { |
723 assert(uri != null || analyzeOnly); | 716 assert(uri != null || analyzeOnly); |
724 scanBuiltinLibraries(); | 717 scanBuiltinLibraries(); |
725 if (librariesToAnalyzeWhenRun != null) { | 718 if (librariesToAnalyzeWhenRun != null) { |
726 for (Uri libraryUri in librariesToAnalyzeWhenRun) { | 719 for (Uri libraryUri in librariesToAnalyzeWhenRun) { |
727 log('analyzing $libraryUri ($BUILD_ID)'); | 720 log('analyzing $libraryUri ($buildId)'); |
728 libraryLoader.loadLibrary(libraryUri, null, libraryUri); | 721 libraryLoader.loadLibrary(libraryUri, null, libraryUri); |
729 } | 722 } |
730 } | 723 } |
731 if (uri != null) { | 724 if (uri != null) { |
732 if (analyzeOnly) { | 725 if (analyzeOnly) { |
733 log('analyzing $uri ($BUILD_ID)'); | 726 log('analyzing $uri ($buildId)'); |
734 } else { | 727 } else { |
735 log('compiling $uri ($BUILD_ID)'); | 728 log('compiling $uri ($buildId)'); |
736 } | 729 } |
737 mainApp = libraryLoader.loadLibrary(uri, null, uri); | 730 mainApp = libraryLoader.loadLibrary(uri, null, uri); |
738 } | 731 } |
739 Element main = null; | 732 Element main = null; |
740 if (mainApp != null) { | 733 if (mainApp != null) { |
741 main = mainApp.find(MAIN); | 734 main = mainApp.find(MAIN); |
742 if (main == null) { | 735 if (main == null) { |
743 if (!analyzeOnly) { | 736 if (!analyzeOnly) { |
744 // Allow analyze only of libraries with no main. | 737 // Allow analyze only of libraries with no main. |
745 reportFatalError('Could not find $MAIN', mainApp); | 738 reportFatalError('Could not find $MAIN', mainApp); |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 | 1271 |
1279 void close() {} | 1272 void close() {} |
1280 | 1273 |
1281 toString() => name; | 1274 toString() => name; |
1282 | 1275 |
1283 /// Convenience method for getting an [api.CompilerOutputProvider]. | 1276 /// Convenience method for getting an [api.CompilerOutputProvider]. |
1284 static NullSink outputProvider(String name, String extension) { | 1277 static NullSink outputProvider(String name, String extension) { |
1285 return new NullSink('$name.$extension'); | 1278 return new NullSink('$name.$extension'); |
1286 } | 1279 } |
1287 } | 1280 } |
OLD | NEW |