| 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 final bool REPORT_EXCESS_RESOLUTION = false; | 10 final bool REPORT_EXCESS_RESOLUTION = false; |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 library.addToScope(new ForeignElement( | 518 library.addToScope(new ForeignElement( |
| 519 const SourceString('JS_HAS_EQUALS'), library), this); | 519 const SourceString('JS_HAS_EQUALS'), library), this); |
| 520 library.addToScope(new ForeignElement( | 520 library.addToScope(new ForeignElement( |
| 521 const SourceString('JS_CURRENT_ISOLATE'), library), this); | 521 const SourceString('JS_CURRENT_ISOLATE'), library), this); |
| 522 library.addToScope(new ForeignElement( | 522 library.addToScope(new ForeignElement( |
| 523 const SourceString('JS_CALL_IN_ISOLATE'), library), this); | 523 const SourceString('JS_CALL_IN_ISOLATE'), library), this); |
| 524 library.addToScope(new ForeignElement( | 524 library.addToScope(new ForeignElement( |
| 525 const SourceString('DART_CLOSURE_TO_JS'), library), this); | 525 const SourceString('DART_CLOSURE_TO_JS'), library), this); |
| 526 } | 526 } |
| 527 | 527 |
| 528 /** Enable the 'JS' helper for a library if needed. */ |
| 529 void maybeEnableJSHelper(library) { |
| 530 String libraryName = library.uri.toString(); |
| 531 if (library.entryCompilationUnit.script.name.contains( |
| 532 'dart/tests/compiler/dart2js_native') |
| 533 || libraryName == 'dart:isolate' |
| 534 || libraryName == 'dart:math' |
| 535 || libraryName == 'dart:html') { |
| 536 library.addToScope(findHelper(const SourceString('JS')), this); |
| 537 if (jsIndexingBehaviorInterface !== null) { |
| 538 library.addToScope(jsIndexingBehaviorInterface, this); |
| 539 } |
| 540 } |
| 541 } |
| 542 |
| 528 void runCompiler(Uri uri) { | 543 void runCompiler(Uri uri) { |
| 529 scanBuiltinLibraries(); | 544 scanBuiltinLibraries(); |
| 530 mainApp = scanner.loadLibrary(uri, null, uri); | 545 mainApp = scanner.loadLibrary(uri, null, uri); |
| 546 libraries.forEach((_, library) { |
| 547 maybeEnableJSHelper(library); |
| 548 }); |
| 531 final Element main = mainApp.find(MAIN); | 549 final Element main = mainApp.find(MAIN); |
| 532 if (main === null) { | 550 if (main === null) { |
| 533 reportFatalError('Could not find $MAIN', mainApp); | 551 reportFatalError('Could not find $MAIN', mainApp); |
| 534 } else { | 552 } else { |
| 535 if (!main.isFunction()) reportFatalError('main is not a function', main); | 553 if (!main.isFunction()) reportFatalError('main is not a function', main); |
| 536 FunctionElement mainMethod = main; | 554 FunctionElement mainMethod = main; |
| 537 FunctionSignature parameters = mainMethod.computeSignature(this); | 555 FunctionSignature parameters = mainMethod.computeSignature(this); |
| 538 parameters.forEachParameter((Element parameter) { | 556 parameters.forEachParameter((Element parameter) { |
| 539 reportFatalError('main cannot have parameters', parameter); | 557 reportFatalError('main cannot have parameters', parameter); |
| 540 }); | 558 }); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 final endOffset = end.charOffset + end.slowCharCount; | 917 final endOffset = end.charOffset + end.slowCharCount; |
| 900 | 918 |
| 901 // [begin] and [end] might be the same for the same empty token. This | 919 // [begin] and [end] might be the same for the same empty token. This |
| 902 // happens for instance when scanning '$$'. | 920 // happens for instance when scanning '$$'. |
| 903 assert(endOffset >= beginOffset); | 921 assert(endOffset >= beginOffset); |
| 904 return f(beginOffset, endOffset); | 922 return f(beginOffset, endOffset); |
| 905 } | 923 } |
| 906 | 924 |
| 907 String toString() => 'SourceSpan($uri, $begin, $end)'; | 925 String toString() => 'SourceSpan($uri, $begin, $end)'; |
| 908 } | 926 } |
| OLD | NEW |