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

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

Issue 10911181: Collect getters in a FunctionSet while resolving. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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 final Compiler compiler;
7 final Map<ClassElement, Set<ClassElement>> subtypes; 7 final Map<ClassElement, Set<ClassElement>> subtypes;
8 final FunctionSet getters;
ahe 2012/09/10 15:15:21 Could you add a method named something like "recor
kasperl 2012/09/11 07:39:11 Maybe change name to userDefinedGetters or nonTriv
ngeoffray 2012/09/11 08:51:08 Done.
ngeoffray 2012/09/11 08:51:08 Done.
8 9
9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); 10 World(Compiler compiler)
11 : subtypes = new Map<ClassElement, Set<ClassElement>>(),
12 getters = new FunctionSet(compiler),
13 this.compiler = compiler;
10 14
11 void populate(Compiler compiler) { 15 void populate() {
12 void addSubtypes(ClassElement cls) { 16 void addSubtypes(ClassElement cls) {
13 if (cls.resolutionState != STATE_DONE) { 17 if (cls.resolutionState != STATE_DONE) {
14 compiler.internalErrorOnElement( 18 compiler.internalErrorOnElement(
15 cls, 'Class "${cls.name.slowToString()}" is not resolved.'); 19 cls, 'Class "${cls.name.slowToString()}" is not resolved.');
16 } 20 }
17 for (DartType type in cls.allSupertypes) { 21 for (DartType type in cls.allSupertypes) {
18 Set<Element> subtypesOfCls = 22 Set<Element> subtypesOfCls =
19 subtypes.putIfAbsent(type.element, () => new Set<ClassElement>()); 23 subtypes.putIfAbsent(type.element, () => new Set<ClassElement>());
20 subtypesOfCls.add(cls); 24 subtypesOfCls.add(cls);
21 } 25 }
22 } 26 }
23 27
24 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes); 28 compiler.resolverWorld.instantiatedClasses.forEach(addSubtypes);
25
26 // Mark the world as populated.
27 assert(compiler !== null);
28 this.compiler = compiler;
29 } 29 }
30 30
31 /** 31 /**
32 * Returns a [MemberSet] that contains the possible targets of the given 32 * Returns a [MemberSet] that contains the possible targets of the given
33 * [selector] on a receiver with the given [type]. This includes all sub 33 * [selector] on a receiver with the given [type]. This includes all sub
34 * types. 34 * types.
35 */ 35 */
36 MemberSet _memberSetFor(DartType type, Selector selector) { 36 MemberSet _memberSetFor(DartType type, Selector selector) {
37 assert(compiler !== null); 37 assert(compiler !== null);
38 ClassElement cls = type.element; 38 ClassElement cls = type.element;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 final SourceString name; 96 final SourceString name;
97 97
98 MemberSet(SourceString this.name) : elements = new Set<Element>(); 98 MemberSet(SourceString this.name) : elements = new Set<Element>();
99 99
100 void add(Element element) { 100 void add(Element element) {
101 elements.add(element); 101 elements.add(element);
102 } 102 }
103 103
104 bool isEmpty() => elements.isEmpty(); 104 bool isEmpty() => elements.isEmpty();
105 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698