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

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

Issue 10915083: Change assert implementation to not depend on a top-level function called 'assert'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert to using lexicalScope 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 Universe { 5 class Universe {
6 Map<Element, CodeBuffer> generatedCode; 6 Map<Element, CodeBuffer> generatedCode;
7 Map<Element, CodeBuffer> generatedBailoutCode; 7 Map<Element, CodeBuffer> generatedBailoutCode;
8 final Set<ClassElement> instantiatedClasses; 8 final Set<ClassElement> instantiatedClasses;
9 final Set<FunctionElement> staticFunctionsNeedingGetter; 9 final Set<FunctionElement> staticFunctionsNeedingGetter;
10 final Map<SourceString, Set<Selector>> invokedNames; 10 final Map<SourceString, Set<Selector>> invokedNames;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 bool isSetter() => kind === SelectorKind.SETTER; 156 bool isSetter() => kind === SelectorKind.SETTER;
157 bool isCall() => kind === SelectorKind.CALL; 157 bool isCall() => kind === SelectorKind.CALL;
158 158
159 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1; 159 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1;
160 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2; 160 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2;
161 161
162 bool isOperator() => kind === SelectorKind.OPERATOR; 162 bool isOperator() => kind === SelectorKind.OPERATOR;
163 bool isUnaryOperator() => isOperator() && argumentCount == 0; 163 bool isUnaryOperator() => isOperator() && argumentCount == 0;
164 bool isBinaryOperator() => isOperator() && argumentCount == 1; 164 bool isBinaryOperator() => isOperator() && argumentCount == 1;
165 165
166 /** Check whether this is a call to 'assert' with one positional parameter. */
167 bool isAssertSyntax() {
168 return (isCall() &&
169 name == const SourceString("assert") &&
ahe 2012/09/06 22:25:53 name.stringValue === 'assert'
Lasse Reichstein Nielsen 2012/09/07 10:18:57 Done.
170 argumentCount == 1 &&
171 namedArgumentCount == 0);
172 }
173
166 int hashCode() => argumentCount + 1000 * namedArguments.length; 174 int hashCode() => argumentCount + 1000 * namedArguments.length;
167 int get namedArgumentCount => namedArguments.length; 175 int get namedArgumentCount => namedArguments.length;
168 int get positionalArgumentCount => argumentCount - namedArgumentCount; 176 int get positionalArgumentCount => argumentCount - namedArgumentCount;
169 DartType get receiverType => null; 177 DartType get receiverType => null;
170 178
171 bool applies(Element element, Compiler compiler) 179 bool applies(Element element, Compiler compiler)
172 => appliesUntyped(element, compiler); 180 => appliesUntyped(element, compiler);
173 181
174 bool appliesUntyped(Element element, Compiler compiler) { 182 bool appliesUntyped(Element element, Compiler compiler) {
175 if (element.isSetter()) return isSetter(); 183 if (element.isSetter()) return isSetter();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 298
291 static bool sameNames(List<SourceString> first, List<SourceString> second) { 299 static bool sameNames(List<SourceString> first, List<SourceString> second) {
292 for (int i = 0; i < first.length; i++) { 300 for (int i = 0; i < first.length; i++) {
293 if (first[i] != second[i]) return false; 301 if (first[i] != second[i]) return false;
294 } 302 }
295 return true; 303 return true;
296 } 304 }
297 305
298 bool operator ==(other) { 306 bool operator ==(other) {
299 if (other is !Selector) return false; 307 if (other is !Selector) return false;
300 return receiverType === other.receiverType 308 Selector otherSelector = other;
ahe 2012/09/06 22:25:53 This change is unnecessary and doesn't improve rea
Lasse Reichstein Nielsen 2012/09/07 10:18:57 Done.
301 && equalsUntyped(other); 309 return receiverType === otherSelector.receiverType
310 && equalsUntyped(otherSelector);
302 } 311 }
303 312
304 bool equalsUntyped(Selector other) { 313 bool equalsUntyped(Selector other) {
305 return name == other.name 314 return name == other.name
306 && library === other.library 315 && library === other.library
307 && argumentCount == other.argumentCount 316 && argumentCount == other.argumentCount
308 && namedArguments.length == other.namedArguments.length 317 && namedArguments.length == other.namedArguments.length
309 && sameNames(namedArguments, other.namedArguments); 318 && sameNames(namedArguments, other.namedArguments);
310 } 319 }
311 320
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 407
399 if (!self.isInterface() && self.isSubclassOf(other)) { 408 if (!self.isInterface() && self.isSubclassOf(other)) {
400 // Resolve an invocation of [element.name] on [self]. If it 409 // Resolve an invocation of [element.name] on [self]. If it
401 // is found, this selector is a candidate. 410 // is found, this selector is a candidate.
402 return hasElementIn(self, element) && appliesUntyped(element, compiler); 411 return hasElementIn(self, element) && appliesUntyped(element, compiler);
403 } 412 }
404 413
405 return false; 414 return false;
406 } 415 }
407 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698