Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: sdk/lib/_internal/compiler/implementation/compiler.dart

Issue 11973006: Private libraries used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update copy_dart.py to handle show in one line. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/async_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart
index 2bfbdf253c1808b7fe806382b83bdd24490b5d09..0137e2f2dcf8766f0aa96b2e569ce73b52d4b5f7 100644
--- a/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -492,33 +492,50 @@ abstract class Compiler implements DiagnosticListener {
LibraryElement scanBuiltinLibrary(String filename);
void initializeSpecialClasses() {
- final List missingClasses = [];
- ClassElement lookupSpecialClass(SourceString name) {
+ final List missingCoreClasses = [];
+ ClassElement lookupCoreClass(SourceString name) {
ClassElement result = coreLibrary.find(name);
if (result == null) {
- missingClasses.add(name.slowToString());
+ missingCoreClasses.add(name.slowToString());
+ }
+ return result;
+ }
+ objectClass = lookupCoreClass(const SourceString('Object'));
+ boolClass = lookupCoreClass(const SourceString('bool'));
+ numClass = lookupCoreClass(const SourceString('num'));
+ intClass = lookupCoreClass(const SourceString('int'));
+ doubleClass = lookupCoreClass(const SourceString('double'));
+ stringClass = lookupCoreClass(const SourceString('String'));
+ functionClass = lookupCoreClass(const SourceString('Function'));
+ listClass = lookupCoreClass(const SourceString('List'));
+ typeClass = lookupCoreClass(const SourceString('Type'));
+ mapClass = lookupCoreClass(const SourceString('Map'));
+ if (!missingCoreClasses.isEmpty) {
+ internalErrorOnElement(coreLibrary,
+ 'dart:core library does not contain required classes: '
+ '$missingCoreClasses');
+ }
+
+ final List missingHelperClasses = [];
+ ClassElement lookupHelperClass(SourceString name) {
+ ClassElement result = jsHelperLibrary.find(name);
+ if (result == null) {
+ missingHelperClasses.add(name.slowToString());
}
return result;
}
- objectClass = lookupSpecialClass(const SourceString('Object'));
- boolClass = lookupSpecialClass(const SourceString('bool'));
- numClass = lookupSpecialClass(const SourceString('num'));
- intClass = lookupSpecialClass(const SourceString('int'));
- doubleClass = lookupSpecialClass(const SourceString('double'));
- stringClass = lookupSpecialClass(const SourceString('String'));
- functionClass = lookupSpecialClass(const SourceString('Function'));
- listClass = lookupSpecialClass(const SourceString('List'));
- typeClass = lookupSpecialClass(const SourceString('Type'));
- mapClass = lookupSpecialClass(const SourceString('Map'));
jsInvocationMirrorClass =
- lookupSpecialClass(const SourceString('JSInvocationMirror'));
- closureClass = lookupSpecialClass(const SourceString('Closure'));
- dynamicClass = lookupSpecialClass(const SourceString('Dynamic_'));
- nullClass = lookupSpecialClass(const SourceString('Null'));
- types = new Types(this, dynamicClass);
- if (!missingClasses.isEmpty) {
- cancel('core library does not contain required classes: $missingClasses');
+ lookupHelperClass(const SourceString('JSInvocationMirror'));
+ closureClass = lookupHelperClass(const SourceString('Closure'));
+ dynamicClass = lookupHelperClass(const SourceString('Dynamic_'));
+ nullClass = lookupHelperClass(const SourceString('Null'));
+ if (!missingHelperClasses.isEmpty) {
+ internalErrorOnElement(jsHelperLibrary,
+ 'dart:_js_helper library does not contain required classes: '
+ '$missingHelperClasses');
}
+
+ types = new Types(this, dynamicClass);
}
void scanBuiltinLibraries() {
@@ -533,18 +550,6 @@ abstract class Compiler implements DiagnosticListener {
isolateHelperLibrary.find(const SourceString('_WorkerStub'));
cls.setNative('"*Worker"');
- // The core library was loaded and patched before jsHelperLibrary was
- // initialized, so it wasn't imported into those two libraries during
- // patching.
- importHelperLibrary(coreLibrary);
- importHelperLibrary(interceptorsLibrary);
-
- importForeignLibrary(jsHelperLibrary);
- importForeignLibrary(interceptorsLibrary);
-
- importForeignLibrary(isolateHelperLibrary);
- importHelperLibrary(isolateHelperLibrary);
-
assertMethod = jsHelperLibrary.find(const SourceString('assertHelper'));
identicalFunction = coreLibrary.find(const SourceString('identical'));
@@ -577,67 +582,6 @@ abstract class Compiler implements DiagnosticListener {
*/
Uri resolvePatchUri(String dartLibraryPath);
- /** Define the JS helper functions in the given library. */
- void importForeignLibrary(LibraryElement library) {
- if (foreignLibrary != null) {
- libraryLoader.importLibrary(library, foreignLibrary, null);
- }
- }
-
- void importIsolateHelperLibrary(LibraryElement library) {
- if (isolateHelperLibrary != null) {
- libraryLoader.importLibrary(library, isolateHelperLibrary, null);
- }
- }
-
- // TODO(karlklose,floitsch): move this to the javascript backend.
- /** Enable the 'JS' helper for a library if needed. */
- void maybeEnableJSHelper(LibraryElement library) {
- String libraryName = library.canonicalUri.toString();
- bool nativeTest = library.entryCompilationUnit.script.name.contains(
- 'dart/tests/compiler/dart2js_native');
- if (nativeTest
- || libraryName == 'dart:async'
- || libraryName == 'dart:chrome'
- || libraryName == 'dart:mirrors'
- || libraryName == 'dart:math'
- || libraryName == 'dart:html'
- || libraryName == 'dart:html_common'
- || libraryName == 'dart:indexed_db'
- || libraryName == 'dart:svg'
- || libraryName == 'dart:web_audio') {
- if (nativeTest
- || libraryName == 'dart:chrome'
- || libraryName == 'dart:html'
- || libraryName == 'dart:html_common'
- || libraryName == 'dart:indexed_db'
- || libraryName == 'dart:svg') {
- // dart:html and dart:svg need access to convertDartClosureToJS and
- // annotation classes.
- // dart:mirrors needs access to the Primitives class.
- importHelperLibrary(library);
- }
- library.addToScope(
- foreignLibrary.findLocal(const SourceString('JS')), this);
- Element jsIndexingBehaviorInterface =
- findHelper(const SourceString('JavaScriptIndexingBehavior'));
- if (jsIndexingBehaviorInterface != null) {
- library.addToScope(jsIndexingBehaviorInterface, this);
- }
- }
- }
-
- void maybeEnableIsolateHelper(LibraryElement library) {
- String libraryName = library.canonicalUri.toString();
- if (libraryName == 'dart:isolate'
- || libraryName == 'dart:html'
- // TODO(floitsch): create a separate async-helper library instead of
- // importing the isolate-library just for TimerImpl.
- || libraryName == 'dart:async') {
- importIsolateHelperLibrary(library);
- }
- }
-
void runCompiler(Uri uri) {
assert(uri != null || analyzeOnly);
scanBuiltinLibraries();
@@ -655,10 +599,6 @@ abstract class Compiler implements DiagnosticListener {
}
mainApp = libraryLoader.loadLibrary(uri, null, uri);
}
- libraries.forEach((_, library) {
- maybeEnableJSHelper(library);
- maybeEnableIsolateHelper(library);
- });
Element main = null;
if (mainApp != null) {
main = mainApp.find(MAIN);
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/lib/async_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698