Index: dart/lib/compiler/implementation/enqueue.dart |
diff --git a/dart/lib/compiler/implementation/enqueue.dart b/dart/lib/compiler/implementation/enqueue.dart |
index 855c539fa1d4a28b9b0a875062deca3965ceb5cf..ed6bc108eb1ac8f6271b129d4a1ffe267c285fb1 100644 |
--- a/dart/lib/compiler/implementation/enqueue.dart |
+++ b/dart/lib/compiler/implementation/enqueue.dart |
@@ -22,7 +22,8 @@ class Enqueuer { |
final Map<String, Link<Element>> instanceMembersByName; |
final Set<ClassElement> seenClasses; |
final Universe universe; |
- final Queue<WorkItem> queue; |
+ final Queue<WorkItem> _queue; |
kasperl
2012/06/12 05:50:12
Why did you have to turn this private?
ahe
2012/06/12 06:22:49
Make public again.
ahe
2012/06/12 10:56:11
Temporary refactoring aid, reverted.
ahe
2012/06/12 10:56:11
Done.
|
+ final Map<Element, TreeElements> resolvedElements; |
bool queueIsClosed = false; |
EnqueueTask task; |
@@ -30,19 +31,44 @@ class Enqueuer { |
: instanceMembersByName = new Map<String, Link<Element>>(), |
seenClasses = new Set<ClassElement>(), |
universe = new Universe(), |
- queue = new Queue<WorkItem>(); |
+ _queue = new Queue<WorkItem>(), |
+ resolvedElements = new Map<Element, TreeElements>(); |
+ |
+ bool get isFirstQueue() => compiler.enqueuer.resolution === this; |
+ |
+ TreeElements getCachedElements(Element element) { |
+ Element owner = element.getOutermostEnclosingMemberOrTopLevel(); |
+ return compiler.enqueuer.resolution.resolvedElements[owner]; |
+ } |
void addToWorkList(Element element, [TreeElements elements]) { |
+ // int allowed = ElementCategory.VARIABLE | ElementCategory.FUNCTION |
kasperl
2012/06/12 05:50:12
There's a lot of commented out code in this method
ahe
2012/06/12 06:22:49
Remove comments.
ahe
2012/06/12 10:56:11
Done.
ahe
2012/06/12 10:56:11
Done.
|
+ // | ElementCategory.FACTORY; |
+ // if (element is AbstractFieldElement) return; |
+ // if (!element.isAccessor() && (element.kind.category & allowed) == 0) return; |
+ // if (!element.isParameter() && !element.isTopLevel() && !element.enclosingElement.isClass()) return; |
+ if (element.isForeign()) return; |
if (queueIsClosed) { |
+ if (isFirstQueue && getCachedElements(element) !== null) return; |
compiler.internalErrorOnElement(element, "Work list is closed."); |
} |
- if (element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { |
+ if (!isFirstQueue && element.kind === ElementKind.GENERATIVE_CONSTRUCTOR) { |
registerInstantiatedClass(element.enclosingElement); |
} |
- queue.add(new WorkItem(element, elements)); |
+ if (elements === null) { |
+ elements = getCachedElements(element); |
+ if (!isFirstQueue && elements === null) { |
ahe
2012/06/12 06:22:49
Remove this dead code.
ahe
2012/06/12 10:56:11
Done.
|
+ if (element.getLibrary() !== compiler.interceptorsLibrary && |
+ element.getLibrary() !== compiler.jsHelperLibrary) { |
+ // compiler.internalErrorOnElement(element, 'Unresolved element'); |
+ } |
+ } |
+ } |
+ _queue.add(new WorkItem(element, elements)); |
} |
void registerInstantiatedClass(ClassElement cls) { |
+ if (cls.isInterface()) throw '$cls is an interface'; |
ahe
2012/06/12 06:22:49
Remove this.
ahe
2012/06/12 10:56:11
Turned into an internal error.
|
universe.instantiatedClasses.add(cls); |
onRegisterInstantiatedClass(cls); |
} |
@@ -86,6 +112,7 @@ class Enqueuer { |
void processInstantiatedClassMember(Element member) { |
if (universe.generatedCode.containsKey(member)) return; |
+ if (resolvedElements[member] !== null) return; |
if (!member.isInstanceMember()) return; |
if (member.isField()) return; |
@@ -227,4 +254,10 @@ class Enqueuer { |
void registerIsCheck(Element element) { |
universe.isChecks.add(element); |
} |
+ |
+ void forEach(f(WorkItem work)) { |
+ while (!_queue.isEmpty()) { |
+ f(_queue.removeLast()); |
+ } |
+ } |
} |