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

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

Issue 12033003: Deferred (aka lazy) loading of static functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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
Index: dart/sdk/lib/_internal/compiler/implementation/compiler.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
index 01e5cc2813090a642cd612efb2c75984d6a7839b..cbfb3735f24d9ea16cc00dc70bfb2280b04a85b8 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/compiler.dart
@@ -234,6 +234,9 @@ abstract class Compiler implements DiagnosticListener {
ClassElement listClass;
ClassElement typeClass;
ClassElement mapClass;
+ ClassElement deferLoadClass;
+ ClassElement onLibraryLoadedClass;
+
ClassElement jsInvocationMirrorClass;
/// Document class from dart:mirrors.
ClassElement documentClass;
@@ -291,6 +294,7 @@ abstract class Compiler implements DiagnosticListener {
ConstantHandler metadataHandler;
EnqueueTask enqueuer;
CompilerTask fileReadingTask;
+ DeferredLoadTask deferredLoadTask;
static const SourceString MAIN = const SourceString('main');
static const SourceString CALL_OPERATOR_NAME = const SourceString('call');
@@ -369,6 +373,7 @@ abstract class Compiler implements DiagnosticListener {
checker = new TypeCheckerTask(this),
typesTask = new ti.TypesTask(this),
constantHandler = new ConstantHandler(this, backend.constantSystem),
+ deferredLoadTask = new DeferredLoadTask(this),
enqueuer = new EnqueueTask(this)];
tasks.addAll(backend.tasks);
@@ -450,6 +455,8 @@ abstract class Compiler implements DiagnosticListener {
return spanFromHInstruction(node);
} else if (node is Element) {
return spanFromElement(node);
+ } else if (node is MetadataAnnotation) {
+ return spanFromTokens(node.beginToken, node.beginToken);
} else {
throw 'No error location.';
}
@@ -502,23 +509,25 @@ abstract class Compiler implements DiagnosticListener {
void initializeSpecialClasses() {
final List missingCoreClasses = [];
- ClassElement lookupCoreClass(SourceString name) {
- ClassElement result = coreLibrary.find(name);
+ ClassElement lookupCoreClass(String name) {
+ ClassElement result = coreLibrary.find(new SourceString(name));
if (result == null) {
- missingCoreClasses.add(name.slowToString());
+ missingCoreClasses.add(name);
}
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'));
+ objectClass = lookupCoreClass('Object');
+ boolClass = lookupCoreClass('bool');
+ numClass = lookupCoreClass('num');
+ intClass = lookupCoreClass('int');
+ doubleClass = lookupCoreClass('double');
+ stringClass = lookupCoreClass('String');
+ functionClass = lookupCoreClass('Function');
+ listClass = lookupCoreClass('List');
+ typeClass = lookupCoreClass('Type');
+ mapClass = lookupCoreClass('Map');
+ deferLoadClass = lookupCoreClass('DeferLoad');
+ onLibraryLoadedClass = lookupCoreClass('OnLibraryLoaded');
if (!missingCoreClasses.isEmpty) {
internalErrorOnElement(coreLibrary,
'dart:core library does not contain required classes: '
@@ -526,18 +535,17 @@ abstract class Compiler implements DiagnosticListener {
}
final List missingHelperClasses = [];
- ClassElement lookupHelperClass(SourceString name) {
- ClassElement result = jsHelperLibrary.find(name);
+ ClassElement lookupHelperClass(String name) {
+ ClassElement result = jsHelperLibrary.find(new SourceString(name));
if (result == null) {
- missingHelperClasses.add(name.slowToString());
+ missingHelperClasses.add(name);
}
return result;
}
- jsInvocationMirrorClass =
- lookupHelperClass(const SourceString('JSInvocationMirror'));
- closureClass = lookupHelperClass(const SourceString('Closure'));
- dynamicClass = lookupHelperClass(const SourceString('Dynamic_'));
- nullClass = lookupHelperClass(const SourceString('Null'));
+ jsInvocationMirrorClass = lookupHelperClass('JSInvocationMirror');
+ closureClass = lookupHelperClass('Closure');
+ dynamicClass = lookupHelperClass('Dynamic_');
+ nullClass = lookupHelperClass('Null');
if (!missingHelperClasses.isEmpty) {
internalErrorOnElement(jsHelperLibrary,
'dart:_js_helper library does not contain required classes: '
@@ -634,6 +642,8 @@ abstract class Compiler implements DiagnosticListener {
}
}
+ deferredLoadTask.registerMainApp(mainApp);
+
log('Resolving...');
phase = PHASE_RESOLVING;
if (analyzeAll) {

Powered by Google App Engine
This is Rietveld 408576698