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

Unified Diff: lib/compiler/implementation/lib/interceptors.dart

Issue 10979050: Ensure that hashCode and runtimeType work on null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | runtime/lib/object_patch.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/lib/interceptors.dart
diff --git a/lib/compiler/implementation/lib/interceptors.dart b/lib/compiler/implementation/lib/interceptors.dart
index 1cb7fc62d7a92317aafed8afc5a771b8d18adfaf..2742d196b5346ab5673b83ec0241aeae2d26868b 100644
--- a/lib/compiler/implementation/lib/interceptors.dart
+++ b/lib/compiler/implementation/lib/interceptors.dart
@@ -617,7 +617,10 @@ trim(receiver) {
hashCode(receiver) {
// TODO(ahe): This method shouldn't have to use JS. Update when our
// optimizations are smarter.
+ if (receiver === null) return 0;
if (receiver is num) return JS('int', r'# & 0x1FFFFFFF', receiver);
+ if (receiver is bool) return receiver ? 0x40377024 : 0xc18c0076;
ahe 2012/09/27 11:30:54 How and why did you pick these numbers? I think bo
+ if (isJsArray(receiver)) return Primitives.objectHashCode(receiver);
if (receiver is !String) return UNINTERCEPTED(receiver.hashCode());
int hash = 0;
int length = JS('int', r'#.length', receiver);
@@ -651,8 +654,6 @@ isOdd(receiver) {
return (receiver & 1) === 1;
}
-get$toString(receiver) => () => toString(receiver);
-
get$runtimeType(receiver) {
if (receiver is int) {
return getOrCreateCachedRuntimeType('int');
@@ -660,9 +661,19 @@ get$runtimeType(receiver) {
return getOrCreateCachedRuntimeType('String');
} else if (receiver is double) {
return getOrCreateCachedRuntimeType('double');
+ } else if (receiver is bool) {
+ return getOrCreateCachedRuntimeType('bool');
+ } else if (receiver === null) {
+ return getOrCreateCachedRuntimeType('Null');
} else if (isJsArray(receiver)) {
return getOrCreateCachedRuntimeType('List');
} else {
return UNINTERCEPTED(receiver.runtimeType);
}
}
+
+// TODO(lrn): These getters should be generated automatically for all
+// intercepted methods.
+get$toString(receiver) => () => toString(receiver);
+
+get$hashCode(receiver) => () => hashCode(receiver);
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | runtime/lib/object_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698