in the middle of repairing bugs in hashcode
This commit is contained in:
parent
07b44b2239
commit
3066822ad0
|
@ -95,6 +95,8 @@
|
||||||
'make-hasheq
|
'make-hasheq
|
||||||
'hash-ref
|
'hash-ref
|
||||||
'hash-set!
|
'hash-set!
|
||||||
|
'equal-hash-code
|
||||||
|
|
||||||
))
|
))
|
||||||
(define-predicate KernelPrimitiveName? KernelPrimitiveName)
|
(define-predicate KernelPrimitiveName? KernelPrimitiveName)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
Bytes.prototype.hashCode = function(depth) {
|
Bytes.prototype.hashCode = function(depth) {
|
||||||
var i;
|
var i;
|
||||||
var k = baselib.hashes.getEqualHashCode('Bytes');
|
var k = baselib.hashes.getEqualHashCode('Bytes');
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < this.bytes.length; i++) {
|
||||||
k += this.bytes[i];
|
k += this.bytes[i];
|
||||||
k = baselib.hashes.hashMix(k);
|
k = baselib.hashes.hashMix(k);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof (x) === 'object' && typeof (y) === 'object' &&
|
if (typeof(x) === 'object' &&
|
||||||
typeof(x.hashCode) === 'function') {
|
typeof(x.hashCode) === 'function') {
|
||||||
return x.hashCode(depth + 1);
|
return x.hashCode(depth + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2591,6 +2591,15 @@
|
||||||
return hash.containsKey(key);
|
return hash.containsKey(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
installPrimitiveProcedure(
|
||||||
|
'equal-hash-code',
|
||||||
|
1,
|
||||||
|
function(M) {
|
||||||
|
return baselib.hashes.getEqualHashCode(checkAny(M, 'equal-hash-code', 0));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exports['Primitives'] = Primitives;
|
exports['Primitives'] = Primitives;
|
||||||
exports['installPrimitiveProcedure'] = installPrimitiveProcedure;
|
exports['installPrimitiveProcedure'] = installPrimitiveProcedure;
|
||||||
|
|
|
@ -155,6 +155,8 @@
|
||||||
make-hasheq
|
make-hasheq
|
||||||
hash-ref
|
hash-ref
|
||||||
hash-set!
|
hash-set!
|
||||||
|
equal-hash-code
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; Kernel inlinable
|
;; Kernel inlinable
|
||||||
|
|
|
@ -1,14 +1,51 @@
|
||||||
#lang planet dyoo/whalesong/base
|
#lang planet dyoo/whalesong/base
|
||||||
|
(require (planet dyoo/whalesong/lang/private/shared))
|
||||||
|
|
||||||
;; boxes
|
;; boxes
|
||||||
|
(equal-hash-code (box 42))
|
||||||
|
|
||||||
;; bytes
|
;; bytes
|
||||||
|
(equal-hash-code #"testing")
|
||||||
;; chars
|
;; chars
|
||||||
|
|
||||||
|
(equal-hash-code #\A)
|
||||||
|
(equal-hash-code #\B)
|
||||||
;; hashes
|
;; hashes
|
||||||
|
|
||||||
|
(equal-hash-code (make-hash '((1 . x)
|
||||||
|
(2 . y)
|
||||||
|
(3 . z))))
|
||||||
|
(define ht (make-hash))
|
||||||
|
(hash-set! ht 'self ht)
|
||||||
|
(hash-set! ht 'foo 4)
|
||||||
|
(equal-hash-code ht)
|
||||||
|
|
||||||
;; keywords
|
;; keywords
|
||||||
|
;
|
||||||
|
|
||||||
;; lists
|
;; lists
|
||||||
|
(equal-hash-code (list 1 2 3 4 5))
|
||||||
|
(equal-hash-code (shared ([a (cons 1 b)]
|
||||||
|
[b (cons 2 a)])
|
||||||
|
a))
|
||||||
|
|
||||||
|
|
||||||
;; paths
|
;; paths
|
||||||
|
;
|
||||||
;; placeholders
|
;; placeholders
|
||||||
|
;;
|
||||||
|
|
||||||
;; strings
|
;; strings
|
||||||
|
(equal-hash-code "Hello world")
|
||||||
|
|
||||||
;; structs
|
;; structs
|
||||||
|
(define-struct thing (name age) #:mutable)
|
||||||
|
(equal-hash-code (make-thing "danny" 32))
|
||||||
|
(equal-hash-code (shared ([a (make-thing a a)]) a))
|
||||||
|
|
||||||
;; symbols
|
;; symbols
|
||||||
;; vectors
|
(equal-hash-code 'hello)
|
||||||
|
|
||||||
|
;; vectors
|
||||||
|
(equal-hash-code #(1 2 3 4 5))
|
||||||
|
(equal-hash-code (shared ([v (vector 1 2 v 3 v)]) v))
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
(provide version)
|
(provide version)
|
||||||
(: version String)
|
(: version String)
|
||||||
(define version "1.55")
|
(define version "1.56")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user