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

Side by Side Diff: dart/lib/compiler/implementation/world.dart

Issue 10826243: Restore lazy parsing of classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class World { 5 class World {
6 Compiler compiler; // Set in populate(). 6 Compiler compiler; // Set in populate().
7 final Map<ClassElement, Set<ClassElement>> subtypes; 7 final Map<ClassElement, Set<ClassElement>> subtypes;
8 8
9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); 9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>();
10 10
11 void populate(Compiler compiler, Collection<LibraryElement> libraries) { 11 void populate(Compiler compiler) {
12 void addSubtypes(ClassElement cls) { 12 void addSubtypes(ClassElement cls) {
13 if (!cls.isResolved) {
14 compiler.internalErrorOnElement(
15 cls, 'Class "${cls.name.slowToString()}" is not resolved.');
16 }
13 for (Type type in cls.allSupertypes) { 17 for (Type type in cls.allSupertypes) {
14 Set<Element> subtypesOfCls = subtypes.putIfAbsent( 18 Set<Element> subtypesOfCls =
15 type.element, 19 subtypes.putIfAbsent(type.element, () => new Set<ClassElement>());
16 () => new Set<ClassElement>());
17 subtypesOfCls.add(cls); 20 subtypesOfCls.add(cls);
18 } 21 }
19 } 22 }
20 23
21 libraries.forEach((LibraryElement library) { 24 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes);
22 for (Link<Element> link = library.topLevelElements;
23 !link.isEmpty();
24 link = link.tail) {
25 Element element = link.head;
26 if (!element.isClass()) continue;
27 ClassElement cls = element;
28 compiler.resolveClass(cls);
29 addSubtypes(cls);
30 }
31 });
32 25
33 // Mark the world as populated. 26 // Mark the world as populated.
34 assert(compiler !== null); 27 assert(compiler !== null);
35 this.compiler = compiler; 28 this.compiler = compiler;
36 } 29 }
37 30
38 /** 31 /**
39 * Returns a [MemberSet] that contains the possible targets of a 32 * Returns a [MemberSet] that contains the possible targets of a
40 * selector named [member] on a receiver whose type is [type]. 33 * selector named [member] on a receiver whose type is [type].
41 */ 34 */
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 final SourceString name; 91 final SourceString name;
99 92
100 MemberSet(SourceString this.name) : elements = new Set<Element>(); 93 MemberSet(SourceString this.name) : elements = new Set<Element>();
101 94
102 void add(Element element) { 95 void add(Element element) {
103 elements.add(element); 96 elements.add(element);
104 } 97 }
105 98
106 bool isEmpty() => elements.isEmpty(); 99 bool isEmpty() => elements.isEmpty();
107 } 100 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/compiler.dart ('k') | dart/lib/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698