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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/universe/function_set.dart

Issue 266913017: Convert property methods into getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 6 years, 7 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 part of universe; 5 part of universe;
6 6
7 // TODO(kasperl): This actually holds getters and setters just fine 7 // TODO(kasperl): This actually holds getters and setters just fine
8 // too and stricly they aren't functions. Maybe this needs a better 8 // too and stricly they aren't functions. Maybe this needs a better
9 // name -- something like ElementSet seems a bit too generic. 9 // name -- something like ElementSet seems a bit too generic.
10 class FunctionSet { 10 class FunctionSet {
11 final Compiler compiler; 11 final Compiler compiler;
12 final Map<String, FunctionSetNode> nodes = 12 final Map<String, FunctionSetNode> nodes =
13 new Map<String, FunctionSetNode>(); 13 new Map<String, FunctionSetNode>();
14 FunctionSet(this.compiler); 14 FunctionSet(this.compiler);
15 15
16 FunctionSetNode newNode(String name) 16 FunctionSetNode newNode(String name)
17 => new FunctionSetNode(name); 17 => new FunctionSetNode(name);
18 18
19 void add(Element element) { 19 void add(Element element) {
20 assert(element.isInstanceMember()); 20 assert(element.isInstanceMember);
21 assert(!element.isAbstract); 21 assert(!element.isAbstract);
22 String name = element.name; 22 String name = element.name;
23 FunctionSetNode node = nodes.putIfAbsent(name, () => newNode(name)); 23 FunctionSetNode node = nodes.putIfAbsent(name, () => newNode(name));
24 node.add(element); 24 node.add(element);
25 } 25 }
26 26
27 void remove(Element element) { 27 void remove(Element element) {
28 assert(element.isInstanceMember()); 28 assert(element.isInstanceMember);
29 assert(!element.isAbstract); 29 assert(!element.isAbstract);
30 String name = element.name; 30 String name = element.name;
31 FunctionSetNode node = nodes[name]; 31 FunctionSetNode node = nodes[name];
32 if (node != null) { 32 if (node != null) {
33 node.remove(element); 33 node.remove(element);
34 } 34 }
35 } 35 }
36 36
37 bool contains(Element element) { 37 bool contains(Element element) {
38 assert(element.isInstanceMember()); 38 assert(element.isInstanceMember);
39 assert(!element.isAbstract); 39 assert(!element.isAbstract);
40 String name = element.name; 40 String name = element.name;
41 FunctionSetNode node = nodes[name]; 41 FunctionSetNode node = nodes[name];
42 return (node != null) 42 return (node != null)
43 ? node.contains(element) 43 ? node.contains(element)
44 : false; 44 : false;
45 } 45 }
46 46
47 /** 47 /**
48 * Returns an object that allows iterating over all the functions 48 * Returns an object that allows iterating over all the functions
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 class FullFunctionSetQuery extends FunctionSetQuery { 208 class FullFunctionSetQuery extends FunctionSetQuery {
209 TypeMask _mask; 209 TypeMask _mask;
210 210
211 /** 211 /**
212 * Compute the type of all potential receivers of this function set. 212 * Compute the type of all potential receivers of this function set.
213 */ 213 */
214 TypeMask computeMask(Compiler compiler) { 214 TypeMask computeMask(Compiler compiler) {
215 if (_mask != null) return _mask; 215 if (_mask != null) return _mask;
216 return _mask = new TypeMask.unionOf(functions 216 return _mask = new TypeMask.unionOf(functions
217 .expand((element) { 217 .expand((element) {
218 ClassElement cls = element.getEnclosingClass(); 218 ClassElement cls = element.enclosingClass;
219 return compiler.world.isUsedAsMixin(cls) 219 return compiler.world.isUsedAsMixin(cls)
220 ? ([cls]..addAll(compiler.world.mixinUses[cls])) 220 ? ([cls]..addAll(compiler.world.mixinUses[cls]))
221 : [cls]; 221 : [cls];
222 }) 222 })
223 .map((cls) { 223 .map((cls) {
224 if (compiler.backend.isNullImplementation(cls)) { 224 if (compiler.backend.isNullImplementation(cls)) {
225 return const TypeMask.empty(); 225 return const TypeMask.empty();
226 } 226 }
227 return compiler.world.hasSubclasses(cls) 227 return compiler.world.hasSubclasses(cls)
228 ? new TypeMask.nonNullSubclass(cls.declaration) 228 ? new TypeMask.nonNullSubclass(cls.declaration)
229 : new TypeMask.nonNullExact(cls.declaration); 229 : new TypeMask.nonNullExact(cls.declaration);
230 }), 230 }),
231 compiler); 231 compiler);
232 } 232 }
233 233
234 FullFunctionSetQuery(functions) : super(functions); 234 FullFunctionSetQuery(functions) : super(functions);
235 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698