Chromium Code Reviews| 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 /** |
|
ahe
2012/08/30 23:00:47
I forgot to add a comment here.
| |
| 18 */ | |
| 19 const String BUILD_ID = 'build number could not be determined'; | |
| 20 | |
| 21 | |
| 22 /** | |
| 18 * Contains backend-specific data that is used throughout the compilation of | 23 * Contains backend-specific data that is used throughout the compilation of |
| 19 * one work item. | 24 * one work item. |
| 20 */ | 25 */ |
| 21 class ItemCompilationContext { | 26 class ItemCompilationContext { |
| 22 } | 27 } |
| 23 | 28 |
| 24 class WorkItem { | 29 class WorkItem { |
| 25 final ItemCompilationContext compilationContext; | 30 final ItemCompilationContext compilationContext; |
| 26 final Element element; | 31 final Element element; |
| 27 TreeElements resolutionTree; | 32 TreeElements resolutionTree; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 void internalErrorOnElement(Element element, String message) { | 227 void internalErrorOnElement(Element element, String message) { |
| 223 internalError(message, element: element); | 228 internalError(message, element: element); |
| 224 } | 229 } |
| 225 | 230 |
| 226 void unhandledExceptionOnElement(Element element) { | 231 void unhandledExceptionOnElement(Element element) { |
| 227 if (hasCrashed) return; | 232 if (hasCrashed) return; |
| 228 hasCrashed = true; | 233 hasCrashed = true; |
| 229 reportDiagnostic(spanFromElement(element), | 234 reportDiagnostic(spanFromElement(element), |
| 230 MessageKind.COMPILER_CRASHED.error().toString(), | 235 MessageKind.COMPILER_CRASHED.error().toString(), |
| 231 api.Diagnostic.CRASH); | 236 api.Diagnostic.CRASH); |
| 232 // TODO(ahe): Obtain the build ID. | 237 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 } | 238 } |
| 236 | 239 |
| 237 void cancel([String reason, Node node, Token token, | 240 void cancel([String reason, Node node, Token token, |
| 238 HInstruction instruction, Element element]) { | 241 HInstruction instruction, Element element]) { |
| 239 assembledCode = null; // Compilation failed. Make sure that we | 242 assembledCode = null; // Compilation failed. Make sure that we |
| 240 // don't return a bogus result. | 243 // don't return a bogus result. |
| 241 SourceSpan span = null; | 244 SourceSpan span = null; |
| 242 if (node !== null) { | 245 if (node !== null) { |
| 243 span = spanFromNode(node); | 246 span = spanFromNode(node); |
| 244 } else if (token !== null) { | 247 } else if (token !== null) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 || libraryName == 'dart:math' | 518 || libraryName == 'dart:math' |
| 516 || libraryName == 'dart:html') { | 519 || libraryName == 'dart:html') { |
| 517 library.addToScope(findHelper(const SourceString('JS')), this); | 520 library.addToScope(findHelper(const SourceString('JS')), this); |
| 518 if (jsIndexingBehaviorInterface !== null) { | 521 if (jsIndexingBehaviorInterface !== null) { |
| 519 library.addToScope(jsIndexingBehaviorInterface, this); | 522 library.addToScope(jsIndexingBehaviorInterface, this); |
| 520 } | 523 } |
| 521 } | 524 } |
| 522 } | 525 } |
| 523 | 526 |
| 524 void runCompiler(Uri uri) { | 527 void runCompiler(Uri uri) { |
| 528 log('compiling $uri ($BUILD_ID)'); | |
| 525 scanBuiltinLibraries(); | 529 scanBuiltinLibraries(); |
| 526 mainApp = scanner.loadLibrary(uri, null, uri); | 530 mainApp = scanner.loadLibrary(uri, null, uri); |
| 527 libraries.forEach((_, library) { | 531 libraries.forEach((_, library) { |
| 528 maybeEnableJSHelper(library); | 532 maybeEnableJSHelper(library); |
| 529 }); | 533 }); |
| 530 final Element main = mainApp.find(MAIN); | 534 final Element main = mainApp.find(MAIN); |
| 531 if (main === null) { | 535 if (main === null) { |
| 532 reportFatalError('Could not find $MAIN', mainApp); | 536 reportFatalError('Could not find $MAIN', mainApp); |
| 533 } else { | 537 } else { |
| 534 if (!main.isFunction()) reportFatalError('main is not a function', main); | 538 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; | 902 final endOffset = end.charOffset + end.slowCharCount; |
| 899 | 903 |
| 900 // [begin] and [end] might be the same for the same empty token. This | 904 // [begin] and [end] might be the same for the same empty token. This |
| 901 // happens for instance when scanning '$$'. | 905 // happens for instance when scanning '$$'. |
| 902 assert(endOffset >= beginOffset); | 906 assert(endOffset >= beginOffset); |
| 903 return f(beginOffset, endOffset); | 907 return f(beginOffset, endOffset); |
| 904 } | 908 } |
| 905 | 909 |
| 906 String toString() => 'SourceSpan($uri, $begin, $end)'; | 910 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 907 } | 911 } |
| OLD | NEW |