| 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 */ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 final bool checkDeprecationInSdk; | 121 final bool checkDeprecationInSdk; |
| 122 | 122 |
| 123 bool disableInlining = false; | 123 bool disableInlining = false; |
| 124 | 124 |
| 125 final Tracer tracer; | 125 final Tracer tracer; |
| 126 | 126 |
| 127 CompilerTask measuredTask; | 127 CompilerTask measuredTask; |
| 128 Element _currentElement; | 128 Element _currentElement; |
| 129 LibraryElement coreLibrary; | 129 LibraryElement coreLibrary; |
| 130 LibraryElement isolateLibrary; | 130 LibraryElement isolateLibrary; |
| 131 LibraryElement isolateHelperLibrary; |
| 131 LibraryElement jsHelperLibrary; | 132 LibraryElement jsHelperLibrary; |
| 132 LibraryElement interceptorsLibrary; | 133 LibraryElement interceptorsLibrary; |
| 133 LibraryElement foreignLibrary; | 134 LibraryElement foreignLibrary; |
| 134 LibraryElement mainApp; | 135 LibraryElement mainApp; |
| 135 | 136 |
| 136 ClassElement objectClass; | 137 ClassElement objectClass; |
| 137 ClassElement closureClass; | 138 ClassElement closureClass; |
| 138 ClassElement dynamicClass; | 139 ClassElement dynamicClass; |
| 139 ClassElement boolClass; | 140 ClassElement boolClass; |
| 140 ClassElement numClass; | 141 ClassElement numClass; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 396 |
| 396 createInvocationMirrorElement = | 397 createInvocationMirrorElement = |
| 397 findHelper(CREATE_INVOCATION_MIRROR); | 398 findHelper(CREATE_INVOCATION_MIRROR); |
| 398 enqueuer.resolution.addToWorkList(createInvocationMirrorElement); | 399 enqueuer.resolution.addToWorkList(createInvocationMirrorElement); |
| 399 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); | 400 enqueuer.codegen.addToWorkList(createInvocationMirrorElement); |
| 400 } | 401 } |
| 401 | 402 |
| 402 void enableIsolateSupport(LibraryElement element) { | 403 void enableIsolateSupport(LibraryElement element) { |
| 403 // TODO(ahe): Move this method to Enqueuer. | 404 // TODO(ahe): Move this method to Enqueuer. |
| 404 isolateLibrary = element.patch; | 405 isolateLibrary = element.patch; |
| 405 enqueuer.resolution.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); | 406 isolateHelperLibrary = scanBuiltinLibrary('_isolate_helper'); |
| 407 importForeignLibrary(isolateHelperLibrary); |
| 408 importHelperLibrary(isolateHelperLibrary); |
| 409 |
| 410 libraryLoader.importLibrary(isolateLibrary, isolateHelperLibrary, null); |
| 406 enqueuer.resolution.addToWorkList( | 411 enqueuer.resolution.addToWorkList( |
| 407 isolateLibrary.find(const SourceString('_currentIsolate'))); | 412 isolateHelperLibrary.find(START_ROOT_ISOLATE)); |
| 408 enqueuer.resolution.addToWorkList( | 413 enqueuer.resolution.addToWorkList( |
| 409 isolateLibrary.find(const SourceString('_callInIsolate'))); | 414 isolateHelperLibrary.find(const SourceString('_currentIsolate'))); |
| 410 enqueuer.codegen.addToWorkList(isolateLibrary.find(START_ROOT_ISOLATE)); | 415 enqueuer.resolution.addToWorkList( |
| 416 isolateHelperLibrary.find(const SourceString('_callInIsolate'))); |
| 417 enqueuer.codegen.addToWorkList( |
| 418 isolateHelperLibrary.find(START_ROOT_ISOLATE)); |
| 419 |
| 420 // The helper library does not use the native language extension, |
| 421 // so we manually set the native classes this library defines. |
| 422 // TODO(ngeoffray): Enable annotations on these classes. |
| 423 ClassElement cls = isolateHelperLibrary.find(const SourceString('_Window')); |
| 424 cls.setNative('"*DOMWindow"'); |
| 425 |
| 426 cls = isolateHelperLibrary.find(const SourceString('_WorkerStub')); |
| 427 cls.setNative('"*Worker"'); |
| 428 |
| 429 enqueuer.resolution.nativeEnqueuer.processNativeClassesInLibrary( |
| 430 isolateHelperLibrary); |
| 431 enqueuer.codegen.nativeEnqueuer.processNativeClassesInLibrary( |
| 432 isolateHelperLibrary); |
| 411 } | 433 } |
| 412 | 434 |
| 413 bool hasIsolateSupport() => isolateLibrary != null; | 435 bool hasIsolateSupport() => isolateLibrary != null; |
| 414 | 436 |
| 415 /** | 437 /** |
| 416 * This method is called before [library] import and export scopes have been | 438 * This method is called before [library] import and export scopes have been |
| 417 * set up. | 439 * set up. |
| 418 */ | 440 */ |
| 419 void onLibraryScanned(LibraryElement library, Uri uri) { | 441 void onLibraryScanned(LibraryElement library, Uri uri) { |
| 420 if (dynamicClass != null) { | 442 if (dynamicClass != null) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 515 } |
| 494 | 516 |
| 495 /** | 517 /** |
| 496 * Get an [Uri] pointing to a patch for the dart: library with | 518 * Get an [Uri] pointing to a patch for the dart: library with |
| 497 * the given path. Returns null if there is no patch. | 519 * the given path. Returns null if there is no patch. |
| 498 */ | 520 */ |
| 499 Uri resolvePatchUri(String dartLibraryPath); | 521 Uri resolvePatchUri(String dartLibraryPath); |
| 500 | 522 |
| 501 /** Define the JS helper functions in the given library. */ | 523 /** Define the JS helper functions in the given library. */ |
| 502 void importForeignLibrary(LibraryElement library) { | 524 void importForeignLibrary(LibraryElement library) { |
| 503 if (jsHelperLibrary != null) { | 525 if (foreignLibrary != null) { |
| 504 libraryLoader.importLibrary(library, foreignLibrary, null); | 526 libraryLoader.importLibrary(library, foreignLibrary, null); |
| 505 } | 527 } |
| 506 } | 528 } |
| 507 | 529 |
| 508 // TODO(karlklose,floitsch): move this to the javascript backend. | 530 // TODO(karlklose,floitsch): move this to the javascript backend. |
| 509 /** Enable the 'JS' helper for a library if needed. */ | 531 /** Enable the 'JS' helper for a library if needed. */ |
| 510 void maybeEnableJSHelper(LibraryElement library) { | 532 void maybeEnableJSHelper(LibraryElement library) { |
| 511 String libraryName = library.uri.toString(); | 533 String libraryName = library.uri.toString(); |
| 512 bool nativeTest = library.entryCompilationUnit.script.name.contains( | 534 bool nativeTest = library.entryCompilationUnit.script.name.contains( |
| 513 'dart/tests/compiler/dart2js_native'); | 535 'dart/tests/compiler/dart2js_native'); |
| 514 if (nativeTest | 536 if (nativeTest |
| 515 || libraryName == 'dart:mirrors' | 537 || libraryName == 'dart:mirrors' |
| 516 || libraryName == 'dart:isolate' | |
| 517 || libraryName == 'dart:math' | 538 || libraryName == 'dart:math' |
| 518 || libraryName == 'dart:html' | 539 || libraryName == 'dart:html' |
| 519 || libraryName == 'dart:html_common' | 540 || libraryName == 'dart:html_common' |
| 520 || libraryName == 'dart:indexed_db' | 541 || libraryName == 'dart:indexed_db' |
| 521 || libraryName == 'dart:svg' | 542 || libraryName == 'dart:svg' |
| 522 || libraryName == 'dart:web_audio') { | 543 || libraryName == 'dart:web_audio') { |
| 523 if (nativeTest | 544 if (nativeTest |
| 524 || libraryName == 'dart:html' | 545 || libraryName == 'dart:html' |
| 525 || libraryName == 'dart:html_common' | 546 || libraryName == 'dart:html_common' |
| 526 || libraryName == 'dart:indexed_db' | 547 || libraryName == 'dart:indexed_db' |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 976 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
| 956 // information on assertion errors. | 977 // information on assertion errors. |
| 957 if (condition is Function){ | 978 if (condition is Function){ |
| 958 condition = condition(); | 979 condition = condition(); |
| 959 } | 980 } |
| 960 if (spannable == null || !condition) { | 981 if (spannable == null || !condition) { |
| 961 throw new SpannableAssertionFailure(spannable, message); | 982 throw new SpannableAssertionFailure(spannable, message); |
| 962 } | 983 } |
| 963 return true; | 984 return true; |
| 964 } | 985 } |
| OLD | NEW |