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

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

Issue 17569004: Implement hashCode on objects stored in a set or used as map keys. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with TOT Created 7 years, 6 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 part of dart2js; 5 part of dart2js;
6 6
7 abstract class ConstantVisitor<R> { 7 abstract class ConstantVisitor<R> {
8 R visitFunction(FunctionConstant constant); 8 R visitFunction(FunctionConstant constant);
9 R visitNull(NullConstant constant); 9 R visitNull(NullConstant constant);
10 R visitInt(IntConstant constant); 10 R visitInt(IntConstant constant);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const PrimitiveConstant(); 84 const PrimitiveConstant();
85 bool isPrimitive() => true; 85 bool isPrimitive() => true;
86 86
87 bool operator ==(var other) { 87 bool operator ==(var other) {
88 if (other is !PrimitiveConstant) return false; 88 if (other is !PrimitiveConstant) return false;
89 PrimitiveConstant otherPrimitive = other; 89 PrimitiveConstant otherPrimitive = other;
90 // We use == instead of 'identical' so that DartStrings compare correctly. 90 // We use == instead of 'identical' so that DartStrings compare correctly.
91 return value == otherPrimitive.value; 91 return value == otherPrimitive.value;
92 } 92 }
93 93
94 int get hashCode => throw new UnsupportedError('PrimitiveConstant.hashCode');
95
94 String toString() => value.toString(); 96 String toString() => value.toString();
95 // Primitive constants don't have dependencies. 97 // Primitive constants don't have dependencies.
96 List<Constant> getDependencies() => const <Constant>[]; 98 List<Constant> getDependencies() => const <Constant>[];
97 DartString toDartString(); 99 DartString toDartString();
98 } 100 }
99 101
100 class NullConstant extends PrimitiveConstant { 102 class NullConstant extends PrimitiveConstant {
101 /** The value a Dart null is compiled to in JavaScript. */ 103 /** The value a Dart null is compiled to in JavaScript. */
102 static const String JsNull = "null"; 104 static const String JsNull = "null";
103 105
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 for (int i = 0; i < fields.length; i++) { 479 for (int i = 0; i < fields.length; i++) {
478 if (fields[i] != other.fields[i]) return false; 480 if (fields[i] != other.fields[i]) return false;
479 } 481 }
480 return true; 482 return true;
481 } 483 }
482 484
483 List<Constant> getDependencies() => fields; 485 List<Constant> getDependencies() => fields;
484 486
485 accept(ConstantVisitor visitor) => visitor.visitConstructed(this); 487 accept(ConstantVisitor visitor) => visitor.visitConstructed(this);
486 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698