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

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 userDefinedGetters;
8 9
9 World() : subtypes = new Map<ClassElement, Set<ClassElement>>(); 10 World(Compiler compiler)
11 : subtypes = new Map<ClassElement, Set<ClassElement>>(),
12 userDefinedGetters = 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);
29 }
25 30
26 // Mark the world as populated. 31 void recordUserDefinedGetter(Element element) {
27 assert(compiler !== null); 32 assert(element.isGetter());
28 this.compiler = compiler; 33 userDefinedGetters.add(element);
34 }
35
36 bool hasAnyUserDefinedGetter(Selector selector) {
37 return userDefinedGetters.hasAnyElementMatchingSelector(selector);
38 }
39
40 void registerUsedElement(Element element) {
41 if (element.isMember() && element.isGetter()) {
42 // We're collecting user-defined getters to let the codegen know which
43 // field accesses might have side effects.
44 userDefinedGetters.add(element);
45 }
29 } 46 }
30 47
31 /** 48 /**
32 * Returns a [MemberSet] that contains the possible targets of the given 49 * Returns a [MemberSet] that contains the possible targets of the given
33 * [selector] on a receiver with the given [type]. This includes all sub 50 * [selector] on a receiver with the given [type]. This includes all sub
34 * types. 51 * types.
35 */ 52 */
36 MemberSet _memberSetFor(DartType type, Selector selector) { 53 MemberSet _memberSetFor(DartType type, Selector selector) {
37 assert(compiler !== null); 54 assert(compiler !== null);
38 ClassElement cls = type.element; 55 ClassElement cls = type.element;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 final SourceString name; 113 final SourceString name;
97 114
98 MemberSet(SourceString this.name) : elements = new Set<Element>(); 115 MemberSet(SourceString this.name) : elements = new Set<Element>();
99 116
100 void add(Element element) { 117 void add(Element element) {
101 elements.add(element); 118 elements.add(element);
102 } 119 }
103 120
104 bool isEmpty() => elements.isEmpty(); 121 bool isEmpty() => elements.isEmpty();
105 } 122 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/universe/function_set.dart ('k') | pkg/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698