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

Side by Side Diff: pkg/compiler/lib/src/constants/values.dart

Issue 1777483006: Recognize identical() ConstantValues as equal. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart2js.constants.values; 5 library dart2js.constants.values;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../core_types.dart'; 8 import '../core_types.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart' 10 import '../elements/elements.dart'
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 this.hashCode = value.slowToString().hashCode; 382 this.hashCode = value.slowToString().hashCode;
383 383
384 StringConstantValue.fromString(String value) 384 StringConstantValue.fromString(String value)
385 : this(new DartString.literal(value)); 385 : this(new DartString.literal(value));
386 386
387 bool get isString => true; 387 bool get isString => true;
388 388
389 DartType getType(CoreTypes types) => types.stringType; 389 DartType getType(CoreTypes types) => types.stringType;
390 390
391 bool operator ==(var other) { 391 bool operator ==(var other) {
392 if (identical(this, other)) return true;
392 if (other is !StringConstantValue) return false; 393 if (other is !StringConstantValue) return false;
393 StringConstantValue otherString = other; 394 StringConstantValue otherString = other;
394 return hashCode == otherString.hashCode && 395 return hashCode == otherString.hashCode &&
395 primitiveValue == otherString.primitiveValue; 396 primitiveValue == otherString.primitiveValue;
396 } 397 }
397 398
398 DartString toDartString() => primitiveValue; 399 DartString toDartString() => primitiveValue;
399 400
400 int get length => primitiveValue.length; 401 int get length => primitiveValue.length;
401 402
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 final int hashCode; 455 final int hashCode;
455 456
456 ListConstantValue(InterfaceType type, List<ConstantValue> entries) 457 ListConstantValue(InterfaceType type, List<ConstantValue> entries)
457 : this.entries = entries, 458 : this.entries = entries,
458 hashCode = Hashing.listHash(entries, Hashing.objectHash(type)), 459 hashCode = Hashing.listHash(entries, Hashing.objectHash(type)),
459 super(type); 460 super(type);
460 461
461 bool get isList => true; 462 bool get isList => true;
462 463
463 bool operator ==(var other) { 464 bool operator ==(var other) {
465 if (identical(this, other)) return true;
464 if (other is !ListConstantValue) return false; 466 if (other is !ListConstantValue) return false;
465 ListConstantValue otherList = other; 467 ListConstantValue otherList = other;
466 if (hashCode != otherList.hashCode) return false; 468 if (hashCode != otherList.hashCode) return false;
467 if (type != otherList.type) return false; 469 if (type != otherList.type) return false;
468 if (entries.length != otherList.entries.length) return false; 470 if (entries.length != otherList.entries.length) return false;
469 for (int i = 0; i < entries.length; i++) { 471 for (int i = 0; i < entries.length; i++) {
470 if (entries[i] != otherList.entries[i]) return false; 472 if (entries[i] != otherList.entries[i]) return false;
471 } 473 }
472 return true; 474 return true;
473 } 475 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 this.hashCode = Hashing.listHash(values, 520 this.hashCode = Hashing.listHash(values,
519 Hashing.listHash(keys, 521 Hashing.listHash(keys,
520 Hashing.objectHash(type))), 522 Hashing.objectHash(type))),
521 super(type) { 523 super(type) {
522 assert(keys.length == values.length); 524 assert(keys.length == values.length);
523 } 525 }
524 526
525 bool get isMap => true; 527 bool get isMap => true;
526 528
527 bool operator ==(var other) { 529 bool operator ==(var other) {
530 if (identical(this, other)) return true;
528 if (other is !MapConstantValue) return false; 531 if (other is !MapConstantValue) return false;
529 MapConstantValue otherMap = other; 532 MapConstantValue otherMap = other;
530 if (hashCode != otherMap.hashCode) return false; 533 if (hashCode != otherMap.hashCode) return false;
531 if (type != other.type) return false; 534 if (type != other.type) return false;
532 if (length != other.length) return false; 535 if (length != other.length) return false;
533 for (int i = 0; i < length; i++) { 536 for (int i = 0; i < length; i++) {
534 if (keys[i] != otherMap.keys[i]) return false; 537 if (keys[i] != otherMap.keys[i]) return false;
535 if (values[i] != otherMap.values[i]) return false; 538 if (values[i] != otherMap.values[i]) return false;
536 } 539 }
537 return true; 540 return true;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 : this.fields = fields, 657 : this.fields = fields,
655 hashCode = Hashing.mapHash(fields, Hashing.objectHash(type)), 658 hashCode = Hashing.mapHash(fields, Hashing.objectHash(type)),
656 super(type) { 659 super(type) {
657 assert(type != null); 660 assert(type != null);
658 assert(!fields.containsValue(null)); 661 assert(!fields.containsValue(null));
659 } 662 }
660 663
661 bool get isConstructedObject => true; 664 bool get isConstructedObject => true;
662 665
663 bool operator ==(var otherVar) { 666 bool operator ==(var otherVar) {
667 if (identical(this, otherVar)) return true;
664 if (otherVar is !ConstructedConstantValue) return false; 668 if (otherVar is !ConstructedConstantValue) return false;
665 ConstructedConstantValue other = otherVar; 669 ConstructedConstantValue other = otherVar;
666 if (hashCode != other.hashCode) return false; 670 if (hashCode != other.hashCode) return false;
667 if (type != other.type) return false; 671 if (type != other.type) return false;
668 if (fields.length != other.fields.length) return false; 672 if (fields.length != other.fields.length) return false;
669 for (FieldElement field in fields.keys) { 673 for (FieldElement field in fields.keys) {
670 if (fields[field] != other.fields[field]) return false; 674 if (fields[field] != other.fields[field]) return false;
671 } 675 }
672 return true; 676 return true;
673 } 677 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 762
759 @override 763 @override
760 DartType getType(CoreTypes types) => const DynamicType(); 764 DartType getType(CoreTypes types) => const DynamicType();
761 765
762 @override 766 @override
763 String toStructuredString() => 'NonConstant'; 767 String toStructuredString() => 'NonConstant';
764 768
765 @override 769 @override
766 String unparse() => '>>non-constant<<'; 770 String unparse() => '>>non-constant<<';
767 } 771 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698