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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 586 |
587 void importIsolateHelperLibrary(LibraryElement library) { | 587 void importIsolateHelperLibrary(LibraryElement library) { |
588 if (isolateHelperLibrary != null) { | 588 if (isolateHelperLibrary != null) { |
589 libraryLoader.importLibrary(library, isolateHelperLibrary, null); | 589 libraryLoader.importLibrary(library, isolateHelperLibrary, null); |
590 } | 590 } |
591 } | 591 } |
592 | 592 |
593 // TODO(karlklose,floitsch): move this to the javascript backend. | 593 // TODO(karlklose,floitsch): move this to the javascript backend. |
594 /** Enable the 'JS' helper for a library if needed. */ | 594 /** Enable the 'JS' helper for a library if needed. */ |
595 void maybeEnableJSHelper(LibraryElement library) { | 595 void maybeEnableJSHelper(LibraryElement library) { |
596 String libraryName = library.uri.toString(); | 596 String libraryName = library.canonicalUri.toString(); |
597 bool nativeTest = library.entryCompilationUnit.script.name.contains( | 597 bool nativeTest = library.entryCompilationUnit.script.name.contains( |
598 'dart/tests/compiler/dart2js_native'); | 598 'dart/tests/compiler/dart2js_native'); |
599 if (nativeTest | 599 if (nativeTest |
600 || libraryName == 'dart:async' | 600 || libraryName == 'dart:async' |
601 || libraryName == 'dart:chrome' | 601 || libraryName == 'dart:chrome' |
602 || libraryName == 'dart:mirrors' | 602 || libraryName == 'dart:mirrors' |
603 || libraryName == 'dart:math' | 603 || libraryName == 'dart:math' |
604 || libraryName == 'dart:html' | 604 || libraryName == 'dart:html' |
605 || libraryName == 'dart:html_common' | 605 || libraryName == 'dart:html_common' |
606 || libraryName == 'dart:indexed_db' | 606 || libraryName == 'dart:indexed_db' |
(...skipping 13 matching lines...) Expand all Loading... |
620 foreignLibrary.findLocal(const SourceString('JS')), this); | 620 foreignLibrary.findLocal(const SourceString('JS')), this); |
621 Element jsIndexingBehaviorInterface = | 621 Element jsIndexingBehaviorInterface = |
622 findHelper(const SourceString('JavaScriptIndexingBehavior')); | 622 findHelper(const SourceString('JavaScriptIndexingBehavior')); |
623 if (jsIndexingBehaviorInterface != null) { | 623 if (jsIndexingBehaviorInterface != null) { |
624 library.addToScope(jsIndexingBehaviorInterface, this); | 624 library.addToScope(jsIndexingBehaviorInterface, this); |
625 } | 625 } |
626 } | 626 } |
627 } | 627 } |
628 | 628 |
629 void maybeEnableIsolateHelper(LibraryElement library) { | 629 void maybeEnableIsolateHelper(LibraryElement library) { |
630 String libraryName = library.uri.toString(); | 630 String libraryName = library.canonicalUri.toString(); |
631 if (libraryName == 'dart:isolate' | 631 if (libraryName == 'dart:isolate' |
632 || libraryName == 'dart:html' | 632 || libraryName == 'dart:html' |
633 // TODO(floitsch): create a separate async-helper library instead of | 633 // TODO(floitsch): create a separate async-helper library instead of |
634 // importing the isolate-library just for TimerImpl. | 634 // importing the isolate-library just for TimerImpl. |
635 || libraryName == 'dart:async') { | 635 || libraryName == 'dart:async') { |
636 importIsolateHelperLibrary(library); | 636 importIsolateHelperLibrary(library); |
637 } | 637 } |
638 } | 638 } |
639 | 639 |
640 void runCompiler(Uri uri) { | 640 void runCompiler(Uri uri) { |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 Element element = instruction.sourceElement; | 974 Element element = instruction.sourceElement; |
975 if (element == null) element = currentElement; | 975 if (element == null) element = currentElement; |
976 var position = instruction.sourcePosition; | 976 var position = instruction.sourcePosition; |
977 if (position == null) return spanFromElement(element); | 977 if (position == null) return spanFromElement(element); |
978 Token token = position.token; | 978 Token token = position.token; |
979 if (token == null) return spanFromElement(element); | 979 if (token == null) return spanFromElement(element); |
980 Uri uri = element.getCompilationUnit().script.uri; | 980 Uri uri = element.getCompilationUnit().script.uri; |
981 return spanFromTokens(token, token, uri); | 981 return spanFromTokens(token, token, uri); |
982 } | 982 } |
983 | 983 |
984 Script readScript(Uri uri, [Node node]) { | 984 /** |
| 985 * Translates the [resolvedUri] into a readable URI. |
| 986 * |
| 987 * The [importingLibrary] holds the library importing [resolvedUri] or |
| 988 * [:null:] if [resolvedUri] is loaded as the main library. The |
| 989 * [importingLibrary] is used to grant access to internal libraries from |
| 990 * platform libraries and patch libraries. |
| 991 * |
| 992 * If the [resolvedUri] is not accessible from [importingLibrary], this method |
| 993 * is responsible for reporting errors. |
| 994 * |
| 995 * See [LibraryLoader] for terminology on URIs. |
| 996 */ |
| 997 Uri translateResolvedUri(LibraryElement importingLibrary, |
| 998 Uri resolvedUri, Node node) { |
| 999 unimplemented('Compiler.translateResolvedUri'); |
| 1000 } |
| 1001 |
| 1002 /** |
| 1003 * Reads the script specified by the [readableUri]. |
| 1004 * |
| 1005 * See [LibraryLoader] for terminology on URIs. |
| 1006 */ |
| 1007 Script readScript(Uri readableUri, [Node node]) { |
985 unimplemented('Compiler.readScript'); | 1008 unimplemented('Compiler.readScript'); |
986 } | 1009 } |
987 | 1010 |
988 String get legDirectory { | 1011 String get legDirectory { |
989 unimplemented('Compiler.legDirectory'); | 1012 unimplemented('Compiler.legDirectory'); |
990 } | 1013 } |
991 | 1014 |
992 // TODO(karlklose): split into findHelperFunction and findHelperClass and | 1015 // TODO(karlklose): split into findHelperFunction and findHelperClass and |
993 // add a check that the element has the expected kind. | 1016 // add a check that the element has the expected kind. |
994 Element findHelper(SourceString name) | 1017 Element findHelper(SourceString name) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 // TODO(johnniwinther): Use [spannable] and [message] to provide better | 1139 // TODO(johnniwinther): Use [spannable] and [message] to provide better |
1117 // information on assertion errors. | 1140 // information on assertion errors. |
1118 if (condition is Function){ | 1141 if (condition is Function){ |
1119 condition = condition(); | 1142 condition = condition(); |
1120 } | 1143 } |
1121 if (spannable == null || !condition) { | 1144 if (spannable == null || !condition) { |
1122 throw new SpannableAssertionFailure(spannable, message); | 1145 throw new SpannableAssertionFailure(spannable, message); |
1123 } | 1146 } |
1124 return true; | 1147 return true; |
1125 } | 1148 } |
OLD | NEW |