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

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

Issue 11860008: Stop passing library elements to tons of namer functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Diff against https://codereview.chromium.org/11819060/. Created 7 years, 11 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 library universe; 5 library universe;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../dart2jslib.dart'; 9 import '../dart2jslib.dart';
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 bool isIndex() => identical(kind, SelectorKind.INDEX) && argumentCount == 1; 219 bool isIndex() => identical(kind, SelectorKind.INDEX) && argumentCount == 1;
220 bool isIndexSet() => identical(kind, SelectorKind.INDEX) && argumentCount == 2 ; 220 bool isIndexSet() => identical(kind, SelectorKind.INDEX) && argumentCount == 2 ;
221 221
222 bool isOperator() => identical(kind, SelectorKind.OPERATOR); 222 bool isOperator() => identical(kind, SelectorKind.OPERATOR);
223 bool isUnaryOperator() => isOperator() && argumentCount == 0; 223 bool isUnaryOperator() => isOperator() && argumentCount == 0;
224 bool isBinaryOperator() => isOperator() && argumentCount == 1; 224 bool isBinaryOperator() => isOperator() && argumentCount == 1;
225 225
226 /** Check whether this is a call to 'assert'. */ 226 /** Check whether this is a call to 'assert'. */
227 bool isAssert() => isCall() && identical(name.stringValue, "assert"); 227 bool isAssert() => isCall() && identical(name.stringValue, "assert");
228 228
229 /** Check whether this is a closure invocation call. */
230 bool isClosureCall() =>
231 isCall() && identical(name.stringValue, Compiler.CALL_OPERATOR_NAME);
232
229 int get hashCode => argumentCount + 1000 * namedArguments.length; 233 int get hashCode => argumentCount + 1000 * namedArguments.length;
230 int get namedArgumentCount => namedArguments.length; 234 int get namedArgumentCount => namedArguments.length;
231 int get positionalArgumentCount => argumentCount - namedArgumentCount; 235 int get positionalArgumentCount => argumentCount - namedArgumentCount;
232 DartType get receiverType => null; 236 DartType get receiverType => null;
233 237
234 /** 238 /**
235 * The member name for invocation mirrors created from this selector. 239 * The member name for invocation mirrors created from this selector.
236 */ 240 */
237 String get invocationMirrorMemberName => 241 String get invocationMirrorMemberName =>
238 isSetter() ? '${name.slowToString()}=' : name.slowToString(); 242 isSetter() ? '${name.slowToString()}=' : name.slowToString();
239 243
240 int get invocationMirrorKind { 244 int get invocationMirrorKind {
241 const int METHOD = 0; 245 const int METHOD = 0;
242 const int GETTER = 1; 246 const int GETTER = 1;
243 const int SETTER = 2; 247 const int SETTER = 2;
244 int kind = METHOD; 248 int kind = METHOD;
245 if (isGetter()) { 249 if (isGetter()) {
246 kind = GETTER; 250 kind = GETTER;
247 } else if (isSetter()) { 251 } else if (isSetter()) {
248 kind = SETTER; 252 kind = SETTER;
249 } 253 }
250 return kind; 254 return kind;
251 } 255 }
252 256
253 bool applies(Element element, Compiler compiler) 257 bool applies(Element element, Compiler compiler)
254 => appliesUntyped(element, compiler); 258 => appliesUntyped(element, compiler);
255 259
256 bool appliesUntyped(Element element, Compiler compiler) { 260 bool appliesUntyped(Element element, Compiler compiler) {
261 assert(name == element.name);
257 if (Elements.isUnresolved(element)) return false; 262 if (Elements.isUnresolved(element)) return false;
263 if (name.isPrivate() && library != element.getLibrary()) return false;
258 if (element.isForeign(compiler)) return true; 264 if (element.isForeign(compiler)) return true;
259
260 if (element.isSetter()) return isSetter(); 265 if (element.isSetter()) return isSetter();
261 if (element.isGetter()) return isGetter() || isCall(); 266 if (element.isGetter()) return isGetter() || isCall();
262 if (element.isField()) return isGetter() || isSetter() || isCall(); 267 if (element.isField()) return isGetter() || isSetter() || isCall();
263 if (isGetter()) return true; 268 if (isGetter()) return true;
264 if (isSetter()) return false; 269 if (isSetter()) return false;
265 270
266 FunctionElement function = element; 271 FunctionElement function = element;
267 FunctionSignature parameters = function.computeSignature(compiler); 272 FunctionSignature parameters = function.computeSignature(compiler);
268 if (argumentCount > parameters.parameterCount) return false; 273 if (argumentCount > parameters.parameterCount) return false;
269 int requiredParameterCount = parameters.requiredParameterCount; 274 int requiredParameterCount = parameters.requiredParameterCount;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 ClassElement cls = self; 480 ClassElement cls = self;
476 if (cls.isSubclassOf(other)) { 481 if (cls.isSubclassOf(other)) {
477 // Resolve an invocation of [element.name] on [self]. If it 482 // Resolve an invocation of [element.name] on [self]. If it
478 // is found, this selector is a candidate. 483 // is found, this selector is a candidate.
479 return hasElementIn(self, element) && appliesUntyped(element, compiler); 484 return hasElementIn(self, element) && appliesUntyped(element, compiler);
480 } 485 }
481 486
482 return false; 487 return false;
483 } 488 }
484 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698