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

Side by Side Diff: lib/compiler/implementation/ssa/types.dart

Issue 10692087: Reapply change to update dart2js operator equals semantics to follow (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Whoops, fix eqB to use === true Created 8 years, 5 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 abstract class HType { 5 abstract class HType {
6 const HType(); 6 const HType();
7 7
8 /** 8 /**
9 * Returns an [HType] that represents [type] and all types that have 9 * Returns an [HType] that represents [type] and all types that have
10 * [type] as supertype. 10 * [type] as supertype.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 if (other.isBooleanOrNull()) return HType.BOOLEAN_OR_NULL; 192 if (other.isBooleanOrNull()) return HType.BOOLEAN_OR_NULL;
193 if (other.isBoolean()) return HType.BOOLEAN_OR_NULL; 193 if (other.isBoolean()) return HType.BOOLEAN_OR_NULL;
194 if (other.isNull()) return HType.BOOLEAN_OR_NULL; 194 if (other.isNull()) return HType.BOOLEAN_OR_NULL;
195 return HType.CONFLICTING; 195 return HType.CONFLICTING;
196 } 196 }
197 197
198 HType intersection(HType other) { 198 HType intersection(HType other) {
199 if (other.isUnknown()) return HType.BOOLEAN_OR_NULL; 199 if (other.isUnknown()) return HType.BOOLEAN_OR_NULL;
200 if (other.isBooleanOrNull()) return HType.BOOLEAN_OR_NULL; 200 if (other.isBooleanOrNull()) return HType.BOOLEAN_OR_NULL;
201 if (other.isBoolean()) return HType.BOOLEAN; 201 if (other.isBoolean()) return HType.BOOLEAN;
202 if (other.isNull()) return HType.NULL; 202 if (other.canBeNull()) return HType.NULL;
203 return HType.CONFLICTING; 203 return HType.CONFLICTING;
204 } 204 }
205 } 205 }
206 206
207 class HBooleanType extends HPrimitiveType { 207 class HBooleanType extends HPrimitiveType {
208 const HBooleanType(); 208 const HBooleanType();
209 bool isBoolean() => true; 209 bool isBoolean() => true;
210 String toString() => "boolean"; 210 String toString() => "boolean";
211 211
212 Type computeType(Compiler compiler) { 212 Type computeType(Compiler compiler) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 248
249 HType intersection(HType other) { 249 HType intersection(HType other) {
250 if (other.isUnknown()) return HType.NUMBER_OR_NULL; 250 if (other.isUnknown()) return HType.NUMBER_OR_NULL;
251 if (other.isInteger()) return HType.INTEGER; 251 if (other.isInteger()) return HType.INTEGER;
252 if (other.isDouble()) return HType.DOUBLE; 252 if (other.isDouble()) return HType.DOUBLE;
253 if (other.isNumber()) return HType.NUMBER; 253 if (other.isNumber()) return HType.NUMBER;
254 if (other.isIntegerOrNull()) return HType.INTEGER_OR_NULL; 254 if (other.isIntegerOrNull()) return HType.INTEGER_OR_NULL;
255 if (other.isDoubleOrNull()) return HType.DOUBLE_OR_NULL; 255 if (other.isDoubleOrNull()) return HType.DOUBLE_OR_NULL;
256 if (other.isNumberOrNull()) return HType.NUMBER_OR_NULL; 256 if (other.isNumberOrNull()) return HType.NUMBER_OR_NULL;
257 if (other.isNull()) return HType.NULL; 257 if (other.canBeNull()) return HType.NULL;
258 return HType.CONFLICTING; 258 return HType.CONFLICTING;
259 } 259 }
260 } 260 }
261 261
262 class HNumberType extends HPrimitiveType { 262 class HNumberType extends HPrimitiveType {
263 const HNumberType(); 263 const HNumberType();
264 bool isNumber() => true; 264 bool isNumber() => true;
265 String toString() => "number"; 265 String toString() => "number";
266 266
267 Type computeType(Compiler compiler) { 267 Type computeType(Compiler compiler) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 306 }
307 307
308 HType intersection(HType other) { 308 HType intersection(HType other) {
309 if (other.isUnknown()) return HType.INTEGER_OR_NULL; 309 if (other.isUnknown()) return HType.INTEGER_OR_NULL;
310 if (other.isIntegerOrNull()) return HType.INTEGER_OR_NULL; 310 if (other.isIntegerOrNull()) return HType.INTEGER_OR_NULL;
311 if (other.isInteger()) return HType.INTEGER; 311 if (other.isInteger()) return HType.INTEGER;
312 if (other.isDouble()) return HType.CONFLICTING; 312 if (other.isDouble()) return HType.CONFLICTING;
313 if (other.isDoubleOrNull()) return HType.CONFLICTING; 313 if (other.isDoubleOrNull()) return HType.CONFLICTING;
314 if (other.isNumber()) return HType.INTEGER; 314 if (other.isNumber()) return HType.INTEGER;
315 if (other.isNumberOrNull()) return HType.INTEGER_OR_NULL; 315 if (other.isNumberOrNull()) return HType.INTEGER_OR_NULL;
316 if (other.isNull()) return HType.NULL; 316 if (other.canBeNull()) return HType.NULL;
317 return HType.CONFLICTING; 317 return HType.CONFLICTING;
318 } 318 }
319 } 319 }
320 320
321 class HIntegerType extends HNumberType { 321 class HIntegerType extends HNumberType {
322 const HIntegerType(); 322 const HIntegerType();
323 bool isInteger() => true; 323 bool isInteger() => true;
324 String toString() => "integer"; 324 String toString() => "integer";
325 325
326 Type computeType(Compiler compiler) { 326 Type computeType(Compiler compiler) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 HType intersection(HType other) { 371 HType intersection(HType other) {
372 if (other.isUnknown()) return HType.DOUBLE_OR_NULL; 372 if (other.isUnknown()) return HType.DOUBLE_OR_NULL;
373 if (other.isIntegerOrNull()) return HType.CONFLICTING; 373 if (other.isIntegerOrNull()) return HType.CONFLICTING;
374 if (other.isInteger()) return HType.CONFLICTING; 374 if (other.isInteger()) return HType.CONFLICTING;
375 if (other.isDouble()) return HType.DOUBLE; 375 if (other.isDouble()) return HType.DOUBLE;
376 if (other.isDoubleOrNull()) return HType.DOUBLE_OR_NULL; 376 if (other.isDoubleOrNull()) return HType.DOUBLE_OR_NULL;
377 if (other.isNumber()) return HType.DOUBLE; 377 if (other.isNumber()) return HType.DOUBLE;
378 if (other.isNumberOrNull()) return HType.DOUBLE_OR_NULL; 378 if (other.isNumberOrNull()) return HType.DOUBLE_OR_NULL;
379 if (other.isNull()) return HType.NULL; 379 if (other.canBeNull()) return HType.NULL;
380 return HType.CONFLICTING; 380 return HType.CONFLICTING;
381 } 381 }
382 } 382 }
383 383
384 class HDoubleType extends HNumberType { 384 class HDoubleType extends HNumberType {
385 const HDoubleType(); 385 const HDoubleType();
386 bool isDouble() => true; 386 bool isDouble() => true;
387 String toString() => "double"; 387 String toString() => "double";
388 388
389 Type computeType(Compiler compiler) { 389 Type computeType(Compiler compiler) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 HType intersection(HType other) { 478 HType intersection(HType other) {
479 if (other.isUnknown()) return HType.STRING_OR_NULL; 479 if (other.isUnknown()) return HType.STRING_OR_NULL;
480 if (other.isString()) return HType.STRING; 480 if (other.isString()) return HType.STRING;
481 if (other.isStringOrNull()) return HType.STRING_OR_NULL; 481 if (other.isStringOrNull()) return HType.STRING_OR_NULL;
482 if (other.isArray()) return HType.CONFLICTING; 482 if (other.isArray()) return HType.CONFLICTING;
483 if (other.isIndexablePrimitive()) return HType.STRING; 483 if (other.isIndexablePrimitive()) return HType.STRING;
484 if (other is HBoundedPotentialPrimitiveString) { 484 if (other is HBoundedPotentialPrimitiveString) {
485 return other.canBeNull() ? HType.STRING_OR_NULL : HType.STRING; 485 return other.canBeNull() ? HType.STRING_OR_NULL : HType.STRING;
486 } 486 }
487 if (other.isNull()) return HType.NULL; 487 if (other.canBeNull()) return HType.NULL;
488 return HType.CONFLICTING; 488 return HType.CONFLICTING;
489 } 489 }
490 } 490 }
491 491
492 class HStringType extends HIndexablePrimitiveType { 492 class HStringType extends HIndexablePrimitiveType {
493 const HStringType(); 493 const HStringType();
494 bool isString() => true; 494 bool isString() => true;
495 String toString() => "String"; 495 String toString() => "String";
496 496
497 Type computeType(Compiler compiler) { 497 Type computeType(Compiler compiler) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 } 624 }
625 625
626 HType intersection(HType other) { 626 HType intersection(HType other) {
627 assert(!(isExact() && canBeNull())); 627 assert(!(isExact() && canBeNull()));
628 if (other.isNull()) return canBeNull() ? HType.NULL : HType.CONFLICTING; 628 if (other.isNull()) return canBeNull() ? HType.NULL : HType.CONFLICTING;
629 if (other is HBoundedType) { 629 if (other is HBoundedType) {
630 HBoundedType temp = other; 630 HBoundedType temp = other;
631 if (this.type === temp.type) { 631 if (this.type === temp.type) {
632 if (isExact()) { 632 if (isExact()) {
633 return this; 633 return this;
634 } else if (other.isExact()){ 634 } else if (other.isExact()) {
635 return other; 635 return other;
636 } else if (canBeNull()) { 636 } else if (canBeNull()) {
637 return other; 637 return other;
638 } else { 638 } else {
639 return this; 639 return this;
640 } 640 }
641 } else if (canBeNull() && other.canBeNull()) {
642 return HType.NULL;
643 } 641 }
644 } 642 }
645 if (other.isUnknown()) return this; 643 if (other.isUnknown()) return this;
644 if (other.canBeNull() && canBeNull()) return HType.NULL;
646 return HType.CONFLICTING; 645 return HType.CONFLICTING;
647 } 646 }
648 647
649 bool operator ==(HType other) { 648 bool operator ==(HType other) {
650 if (other is !HBoundedType) return false; 649 if (other is !HBoundedType) return false;
651 HBoundedType bounded = other; 650 HBoundedType bounded = other;
652 return (type === bounded.type && canBeNull() === bounded.canBeNull() 651 return (type === bounded.type && canBeNull() === bounded.canBeNull()
653 && isExact() === other .isExact()); 652 && isExact() === other .isExact());
654 } 653 }
655 654
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 HType intersection(HType other) { 733 HType intersection(HType other) {
735 if (other.isString()) return HType.STRING; 734 if (other.isString()) return HType.STRING;
736 if (other.isStringOrNull()) { 735 if (other.isStringOrNull()) {
737 return canBeNull() ? HType.STRING_OR_NULL : HType.STRING; 736 return canBeNull() ? HType.STRING_OR_NULL : HType.STRING;
738 } 737 }
739 if (other.isReadableArray()) return HType.CONFLICTING; 738 if (other.isReadableArray()) return HType.CONFLICTING;
740 if (other.isIndexablePrimitive()) return HType.STRING; 739 if (other.isIndexablePrimitive()) return HType.STRING;
741 return super.intersection(other); 740 return super.intersection(other);
742 } 741 }
743 } 742 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698