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

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: Moved assert detection further down. Now demetered. 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<SourceString> instantiatedClassInstanceFields; 9 final Set<SourceString> instantiatedClassInstanceFields;
10 final Set<FunctionElement> staticFunctionsNeedingGetter; 10 final Set<FunctionElement> staticFunctionsNeedingGetter;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 bool isSetter() => kind === SelectorKind.SETTER; 158 bool isSetter() => kind === SelectorKind.SETTER;
159 bool isCall() => kind === SelectorKind.CALL; 159 bool isCall() => kind === SelectorKind.CALL;
160 160
161 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1; 161 bool isIndex() => kind === SelectorKind.INDEX && argumentCount == 1;
162 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2; 162 bool isIndexSet() => kind === SelectorKind.INDEX && argumentCount == 2;
163 163
164 bool isOperator() => kind === SelectorKind.OPERATOR; 164 bool isOperator() => kind === SelectorKind.OPERATOR;
165 bool isUnaryOperator() => isOperator() && argumentCount == 0; 165 bool isUnaryOperator() => isOperator() && argumentCount == 0;
166 bool isBinaryOperator() => isOperator() && argumentCount == 1; 166 bool isBinaryOperator() => isOperator() && argumentCount == 1;
167 167
168 /** Check whether this is a call to 'assert' with one positional parameter. */
169 bool isAssertSyntax() {
170 return (isCall() &&
171 name == const SourceString("assert") &&
172 argumentCount == 1 &&
173 namedArgumentCount == 0);
174 }
175
168 int hashCode() => argumentCount + 1000 * namedArguments.length; 176 int hashCode() => argumentCount + 1000 * namedArguments.length;
169 int get namedArgumentCount => namedArguments.length; 177 int get namedArgumentCount => namedArguments.length;
170 int get positionalArgumentCount => argumentCount - namedArgumentCount; 178 int get positionalArgumentCount => argumentCount - namedArgumentCount;
171 DartType get receiverType => null; 179 DartType get receiverType => null;
172 180
173 bool applies(Element element, Compiler compiler) 181 bool applies(Element element, Compiler compiler)
174 => appliesUntyped(element, compiler); 182 => appliesUntyped(element, compiler);
175 183
176 bool appliesUntyped(Element element, Compiler compiler) { 184 bool appliesUntyped(Element element, Compiler compiler) {
177 if (element.isSetter()) return isSetter(); 185 if (element.isSetter()) return isSetter();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 300
293 static bool sameNames(List<SourceString> first, List<SourceString> second) { 301 static bool sameNames(List<SourceString> first, List<SourceString> second) {
294 for (int i = 0; i < first.length; i++) { 302 for (int i = 0; i < first.length; i++) {
295 if (first[i] != second[i]) return false; 303 if (first[i] != second[i]) return false;
296 } 304 }
297 return true; 305 return true;
298 } 306 }
299 307
300 bool operator ==(other) { 308 bool operator ==(other) {
301 if (other is !Selector) return false; 309 if (other is !Selector) return false;
302 return receiverType === other.receiverType 310 Selector otherSelector = other;
303 && equalsUntyped(other); 311 return receiverType === otherSelector.receiverType
312 && equalsUntyped(otherSelector);
304 } 313 }
305 314
306 bool equalsUntyped(Selector other) { 315 bool equalsUntyped(Selector other) {
307 return name == other.name 316 return name == other.name
308 && library === other.library 317 && library === other.library
309 && argumentCount == other.argumentCount 318 && argumentCount == other.argumentCount
310 && namedArguments.length == other.namedArguments.length 319 && namedArguments.length == other.namedArguments.length
311 && sameNames(namedArguments, other.namedArguments); 320 && sameNames(namedArguments, other.namedArguments);
312 } 321 }
313 322
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 395 }
387 396
388 return false; 397 return false;
389 } 398 }
390 399
391 toString() { 400 toString() {
392 return 'Selector($kind, "${name.slowToString()}", ' 401 return 'Selector($kind, "${name.slowToString()}", '
393 '$argumentCount, type=$receiverType)'; 402 '$argumentCount, type=$receiverType)';
394 } 403 }
395 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698