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

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

Issue 10383065: Start creating a MemberSet abstraction, and use it to fold getters/setters into field accesses. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class World {
6 final Map<ClassElement, Set<ClassElement>> subtypes;
7
8 World() : subtypes = new Map<ClassElement, Set<ClassElement>>();
9
10 /**
11 * Returns a [MemberSet] that contains the possible targets of a
12 * selector named [member] on a receiver whose type is [type].
13 */
14 MemberSet memberSetFor(Type type, SourceString member) {
kasperl 2012/05/09 11:13:03 I'm not sure this functionality needs to be expose
ngeoffray 2012/05/09 11:34:22 Made it library private.
15 ClassElement cls = type.element;
16 MemberSet result = new MemberSet(member);
17 Element element = cls.lookupMember(member);
18 if (element !== null) result.add(element);
19
20 Set<ClassElement> subtypes = subtypes[cls];
21 if (subtypes !== null) {
22 for (ClassElement sub in subtypes) {
23 element = sub.lookupLocalMember(member);
24 if (element !== null) result.add(element);
25 }
26 }
27 return result;
28 }
29 }
30
31 /**
32 * A [MemberSet] contains all the possible targets for a selector.
33 */
34 class MemberSet {
35 final Set<Element> elements;
36 final SourceString name;
37
38 MemberSet(SourceString this.name) : elements = new Set<Element>();
39
40 void add(Element element) {
41 elements.add(element);
42 }
43
44 bool isEmpty() => elements.isEmpty();
45
46 bool hasJustFields() {
47 return elements.every((Element element) => element.isField());
48 }
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698