--- gforth/hash.fs 1997/07/06 15:55:24 1.18 +++ gforth/hash.fs 1998/10/10 10:28:34 1.21 @@ -18,19 +18,15 @@ \ along with this program; if not, write to the Free Software \ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -[IFUNDEF] e? : e? name 2drop false ; [THEN] - -e? ec -[IF] +[IFUNDEF] allocate : reserve-mem here swap allot ; -\ ToDo: check memory space with unused \ move to a kernel/memory.fs [ELSE] : reserve-mem allocate throw ; [THEN] [IFUNDEF] hashbits -11 value hashbits +11 Value hashbits [THEN] 1 hashbits lshift Value Hashlen @@ -92,7 +88,8 @@ Defer hash-alloc : inithash ( wid -- ) wordlist-extend - insRule @ >r insRule off hash-alloc 3 cells - dup + insRule @ >r insRule off hash-alloc 3 cells - + dup wordlist-id BEGIN @ dup WHILE 2dup swap (reveal REPEAT 2drop r> insRule ! ; @@ -140,7 +137,7 @@ to hashsearch-map HashTable Hashlen cells erase THEN HashIndex @ over ! 1 HashIndex +! HashIndex @ Hashlen >= - [ e? ec [IF] ] + [ [IFUNDEF] allocate ] ABORT" no more space in hashtable" [ [ELSE] ] IF HashTable >r clearhash @@ -151,27 +148,27 @@ to hashsearch-map [ [THEN] ] ; is hash-alloc \ Hash-Find 01jan93py -e? cross 0= +has? cross 0= [IF] : make-hash - hashsearch-map forth-wordlist cell+ ! + hashsearch-map forth-wordlist wordlist-map ! addall ; make-hash \ Baumsuche ist installiert. [ELSE] - hashsearch-map forth-wordlist cell+ ! + hashsearch-map forth-wordlist wordlist-map ! [THEN] \ for ec version display that vocabulary goes hashed : hash-cold ( -- ) -[ e? ec [IF] ] ." Hashing..." [ [THEN] ] +[ has? ec [IF] ] ." Hashing..." [ [THEN] ] HashPointer off 0 TO HashTable HashIndex off addall \ voclink \ BEGIN @ dup WHILE \ dup 0 wordlist-link - initvoc \ REPEAT drop -[ e? ec [IF] ] ." Done" cr [ [THEN] ] ; +[ has? ec [IF] ] ." Done" cr [ [THEN] ] ; ' hash-cold INIT8 chained @@ -179,7 +176,7 @@ e? cross 0= base @ >r hex HashTable Hashlen 0 DO cr i 2 .r ." : " dup i cells + BEGIN @ dup WHILE - dup cell+ @ head>string type space REPEAT drop + dup cell+ @ name>string type space REPEAT drop LOOP drop r> base ! ; \ \ this stuff is for evaluating the hash function