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

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

Issue 10965034: Implement Object.hashCode() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Update dart2dart status 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
Index: dart/lib/compiler/implementation/lib/js_helper.dart
diff --git a/dart/lib/compiler/implementation/lib/js_helper.dart b/dart/lib/compiler/implementation/lib/js_helper.dart
index 99145eb1d78817c1f5fc7ce6e6f5c720a14a4776..60bb747009465801145e7e8efc17b89afda5a2c4 100644
--- a/dart/lib/compiler/implementation/lib/js_helper.dart
+++ b/dart/lib/compiler/implementation/lib/js_helper.dart
@@ -353,6 +353,18 @@ class ListIterator<T> implements Iterator<T> {
}
class Primitives {
+ static int hashCodeSeed = 0;
+
+ static int objectHashCode(object) {
+ int hash = JS('var', r'#.$identityHash', object);
+ if (hash === null) {
+ // TOOD(ahe): We should probably randomize this somehow.
+ hash = ++hashCodeSeed;
+ JS('void', r'#.$identityHash = #', object, hash);
+ }
+ return hash;
+ }
+
/**
* This is the low-level method that is used to implement
* [print]. It is possible to override this function from JavaScript
« no previous file with comments | « dart/lib/compiler/implementation/lib/core_patch.dart ('k') | dart/lib/compiler/implementation/lib/native_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698