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