--- gforth/hash.fs 1994/11/15 15:55:36 1.5 +++ gforth/hash.fs 1995/03/13 09:17:28 1.9 @@ -1,6 +1,6 @@ \ Hashed dictionaries 15jul94py -9 value hashbits +11 value hashbits 1 hashbits lshift Value Hashlen Variable insRule insRule on @@ -29,7 +29,7 @@ Variable HashIndex : hash-find ( addr len wordlist -- nfa / false ) - $C + @ >r + [ 3 cells ] Literal + @ >r 2dup hash r> xor cells HashTable @ + @ (hashfind) ; \ hash vocabularies 16jul94py @@ -37,9 +37,9 @@ Variable HashIndex : lastlink! ( addr link -- ) BEGIN dup @ dup WHILE nip REPEAT drop ! ; -: (reveal ( addr voc -- ) $C + dup @ 0< IF 2drop EXIT THEN +: (reveal ( addr voc -- ) [ 3 cells ] Literal + dup @ 0< IF 2drop EXIT THEN @ over cell+ count $1F and Hash xor cells >r - HashPointer 8 $400 NewFix + HashPointer 2 Cells $400 NewFix tuck cell+ ! r> HashTable @ + insRule @ IF dup @ 2 pick ! ! ELSE lastlink! THEN revealed on ; @@ -58,9 +58,9 @@ Variable HashIndex REPEAT I ! cell +LOOP HashIndex off ; -: rehash clearhash addall ; +: re-hash clearhash addall ; : (rehash) ( addr -- ) - drop revealed @ IF rehash revealed off THEN ; + drop revealed @ IF re-hash revealed off THEN ; Create hashsearch ' hash-find A, ' hash-reveal A, ' (rehash) A, @@ -93,7 +93,12 @@ addall \ Baum aufbauen : hash-cold ( -- ) Defers 'cold HashPointer off HashTable off HashIndex off - addall ; + voclink + BEGIN @ dup @ WHILE + dup cell - @ >r + dup 'initvoc + r> over cell - ! + REPEAT drop ; ' hash-cold IS 'cold : .words ( -- )