| 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 | 5 |
| 6 /** | 6 /** |
| 7 * If true, print a warning for each method that was resolved, but not | 7 * If true, print a warning for each method that was resolved, but not |
| 8 * compiled. | 8 * compiled. |
| 9 */ | 9 */ |
| 10 const bool REPORT_EXCESS_RESOLUTION = false; | 10 const bool REPORT_EXCESS_RESOLUTION = false; |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * If true, trace information on pass2 optimizations. | 13 * If true, trace information on pass2 optimizations. |
| 14 */ | 14 */ |
| 15 const bool REPORT_PASS2_OPTIMIZATIONS = false; | 15 const bool REPORT_PASS2_OPTIMIZATIONS = false; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * A string to identify the revision or build. |
| 19 * |
| 20 * This ID is displayed if the compiler crashes and in verbose mode, and is |
| 21 * an aid in reproducing bug reports. |
| 22 * |
| 23 * The actual string is rewritten during the SDK build process. |
| 24 */ |
| 25 const String BUILD_ID = 'build number could not be determined'; |
| 26 |
| 27 |
| 28 /** |
| 18 * Contains backend-specific data that is used throughout the compilation of | 29 * Contains backend-specific data that is used throughout the compilation of |
| 19 * one work item. | 30 * one work item. |
| 20 */ | 31 */ |
| 21 class ItemCompilationContext { | 32 class ItemCompilationContext { |
| 22 } | 33 } |
| 23 | 34 |
| 24 class WorkItem { | 35 class WorkItem { |
| 25 final ItemCompilationContext compilationContext; | 36 final ItemCompilationContext compilationContext; |
| 26 final Element element; | 37 final Element element; |
| 27 TreeElements resolutionTree; | 38 TreeElements resolutionTree; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void internalErrorOnElement(Element element, String message) { | 233 void internalErrorOnElement(Element element, String message) { |
| 223 internalError(message, element: element); | 234 internalError(message, element: element); |
| 224 } | 235 } |
| 225 | 236 |
| 226 void unhandledExceptionOnElement(Element element) { | 237 void unhandledExceptionOnElement(Element element) { |
| 227 if (hasCrashed) return; | 238 if (hasCrashed) return; |
| 228 hasCrashed = true; | 239 hasCrashed = true; |
| 229 reportDiagnostic(spanFromElement(element), | 240 reportDiagnostic(spanFromElement(element), |
| 230 MessageKind.COMPILER_CRASHED.error().toString(), | 241 MessageKind.COMPILER_CRASHED.error().toString(), |
| 231 api.Diagnostic.CRASH); | 242 api.Diagnostic.CRASH); |
| 232 // TODO(ahe): Obtain the build ID. | 243 print(MessageKind.PLEASE_REPORT_THE_CRASH.message([BUILD_ID])); |
| 233 var buildId = 'build number could not be determined'; | |
| 234 print(MessageKind.PLEASE_REPORT_THE_CRASH.message([buildId])); | |
| 235 } | 244 } |
| 236 | 245 |
| 237 void cancel([String reason, Node node, Token token, | 246 void cancel([String reason, Node node, Token token, |
| 238 HInstruction instruction, Element element]) { | 247 HInstruction instruction, Element element]) { |
| 239 assembledCode = null; // Compilation failed. Make sure that we | 248 assembledCode = null; // Compilation failed. Make sure that we |
| 240 // don't return a bogus result. | 249 // don't return a bogus result. |
| 241 SourceSpan span = null; | 250 SourceSpan span = null; |
| 242 if (node !== null) { | 251 if (node !== null) { |
| 243 span = spanFromNode(node); | 252 span = spanFromNode(node); |
| 244 } else if (token !== null) { | 253 } else if (token !== null) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 || libraryName == 'dart:math' | 524 || libraryName == 'dart:math' |
| 516 || libraryName == 'dart:html') { | 525 || libraryName == 'dart:html') { |
| 517 library.addToScope(findHelper(const SourceString('JS')), this); | 526 library.addToScope(findHelper(const SourceString('JS')), this); |
| 518 if (jsIndexingBehaviorInterface !== null) { | 527 if (jsIndexingBehaviorInterface !== null) { |
| 519 library.addToScope(jsIndexingBehaviorInterface, this); | 528 library.addToScope(jsIndexingBehaviorInterface, this); |
| 520 } | 529 } |
| 521 } | 530 } |
| 522 } | 531 } |
| 523 | 532 |
| 524 void runCompiler(Uri uri) { | 533 void runCompiler(Uri uri) { |
| 534 log('compiling $uri ($BUILD_ID)'); |
| 525 scanBuiltinLibraries(); | 535 scanBuiltinLibraries(); |
| 526 mainApp = scanner.loadLibrary(uri, null, uri); | 536 mainApp = scanner.loadLibrary(uri, null, uri); |
| 527 libraries.forEach((_, library) { | 537 libraries.forEach((_, library) { |
| 528 maybeEnableJSHelper(library); | 538 maybeEnableJSHelper(library); |
| 529 }); | 539 }); |
| 530 final Element main = mainApp.find(MAIN); | 540 final Element main = mainApp.find(MAIN); |
| 531 if (main === null) { | 541 if (main === null) { |
| 532 reportFatalError('Could not find $MAIN', mainApp); | 542 reportFatalError('Could not find $MAIN', mainApp); |
| 533 } else { | 543 } else { |
| 534 if (!main.isFunction()) reportFatalError('main is not a function', main); | 544 if (!main.isFunction()) reportFatalError('main is not a function', main); |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 final endOffset = end.charOffset + end.slowCharCount; | 908 final endOffset = end.charOffset + end.slowCharCount; |
| 899 | 909 |
| 900 // [begin] and [end] might be the same for the same empty token. This | 910 // [begin] and [end] might be the same for the same empty token. This |
| 901 // happens for instance when scanning '$$'. | 911 // happens for instance when scanning '$$'. |
| 902 assert(endOffset >= beginOffset); | 912 assert(endOffset >= beginOffset); |
| 903 return f(beginOffset, endOffset); | 913 return f(beginOffset, endOffset); |
| 904 } | 914 } |
| 905 | 915 |
| 906 String toString() => 'SourceSpan($uri, $begin, $end)'; | 916 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 907 } | 917 } |
| OLD | NEW |