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

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

Issue 14636002: Make TypeMask an interface and start hiding implementation details of FlatTypeMask. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses; 9 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; 10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 VariableElement locateSingleField(Selector selector) { 145 VariableElement locateSingleField(Selector selector) {
146 Element result = locateSingleElement(selector); 146 Element result = locateSingleElement(selector);
147 return (result != null && result.isField()) ? result : null; 147 return (result != null && result.isField()) ? result : null;
148 } 148 }
149 149
150 Element locateSingleElement(Selector selector) { 150 Element locateSingleElement(Selector selector) {
151 Iterable<Element> targets = allFunctions.filter(selector); 151 Iterable<Element> targets = allFunctions.filter(selector);
152 if (targets.length != 1) return null; 152 if (targets.length != 1) return null;
153 Element result = targets.first; 153 Element result = targets.first;
154 ClassElement enclosing = result.getEnclosingClass(); 154 ClassElement enclosing = result.getEnclosingClass();
155 // TODO(kasperl): Move this code to the type mask.
156 ti.TypeMask mask = selector.mask; 155 ti.TypeMask mask = selector.mask;
157 ClassElement receiverTypeElement = (mask == null || mask.base == null) 156 ClassElement receiverTypeElement = (mask == null || mask.isEmpty)
158 ? compiler.objectClass 157 ? compiler.objectClass
159 : mask.base.element; 158 : mask.topClass();
160 // We only return the found element if it is guaranteed to be 159 // We only return the found element if it is guaranteed to be
161 // implemented on the exact receiver type. It could be found in a 160 // implemented on the exact receiver type. It could be found in a
162 // subclass or in an inheritance-wise unrelated class in case of 161 // subclass or in an inheritance-wise unrelated class in case of
163 // subtype selectors. 162 // subtype selectors.
164 return (receiverTypeElement.isSubclassOf(enclosing)) ? result : null; 163 return (receiverTypeElement.isSubclassOf(enclosing)) ? result : null;
165 } 164 }
166 165
167 bool hasSingleMatch(Selector selector) { 166 bool hasSingleMatch(Selector selector) {
168 Iterable<Element> targets = allFunctions.filter(selector); 167 Iterable<Element> targets = allFunctions.filter(selector);
169 return targets.length == 1; 168 return targets.length == 1;
(...skipping 13 matching lines...) Expand all
183 } 182 }
184 183
185 void addFunctionCalledInLoop(Element element) { 184 void addFunctionCalledInLoop(Element element) {
186 functionsCalledInLoop.add(element); 185 functionsCalledInLoop.add(element);
187 } 186 }
188 187
189 bool isCalledInLoop(Element element) { 188 bool isCalledInLoop(Element element) {
190 return functionsCalledInLoop.contains(element); 189 return functionsCalledInLoop.contains(element);
191 } 190 }
192 } 191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698