Diff for /gforth/hash.fs between versions 1.4 and 1.9

version 1.4, 1994/10/18 15:51:18 version 1.9, 1995/03/13 09:17:28
Line 1 Line 1
 \ Hashed dictionaries                                  15jul94py  \ Hashed dictionaries                                  15jul94py
   
 9 value hashbits  11 value hashbits
 1 hashbits lshift Value Hashlen  1 hashbits lshift Value Hashlen
   
 Variable insRule        insRule on  Variable insRule        insRule on
Line 29  Variable HashIndex Line 29  Variable HashIndex
   
   
 : hash-find ( addr len wordlist -- nfa / false )  : hash-find ( addr len wordlist -- nfa / false )
     $C + @ >r      [ 3 cells ] Literal + @ >r
     2dup hash r> xor cells HashTable @ + @ (hashfind) ;      2dup hash r> xor cells HashTable @ + @ (hashfind) ;
   
 \ hash vocabularies                                    16jul94py  \ hash vocabularies                                    16jul94py
Line 37  Variable HashIndex Line 37  Variable HashIndex
 : lastlink! ( addr link -- )  : lastlink! ( addr link -- )
   BEGIN  dup @ dup  WHILE  nip  REPEAT  drop ! ;    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    @ over cell+ count $1F and Hash xor cells >r
   HashPointer 8 $400 NewFix    HashPointer 2 Cells $400 NewFix
   tuck cell+ ! r> HashTable @ + insRule @    tuck cell+ ! r> HashTable @ + insRule @
   IF  dup @ 2 pick ! !  ELSE  lastlink!  THEN  revealed on ;    IF  dup @ 2 pick ! !  ELSE  lastlink!  THEN  revealed on ;
   
Line 58  Variable HashIndex Line 58  Variable HashIndex
         REPEAT  I !          REPEAT  I !
     cell +LOOP  HashIndex off ;      cell +LOOP  HashIndex off ;
   
 : rehash  clearhash addall ;  : re-hash  clearhash addall ;
 : (rehash) ( addr -- )  : (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,  Create hashsearch  ' hash-find A, ' hash-reveal A, ' (rehash) A,
   
Line 91  Create hashsearch  ' hash-find A, ' hash Line 91  Create hashsearch  ' hash-find A, ' hash
 addall          \ Baum aufbauen  addall          \ Baum aufbauen
 \ Baumsuche ist installiert.  \ Baumsuche ist installiert.
   
   : hash-cold  ( -- ) Defers 'cold
     HashPointer off  HashTable off  HashIndex off
     voclink
     BEGIN  @ dup @  WHILE
            dup cell - @ >r
            dup 'initvoc
            r> over cell - !
     REPEAT  drop ;
   ' hash-cold IS 'cold
   
 : .words  ( -- )  : .words  ( -- )
   base @ >r hex HashTable @  Hashlen 0    base @ >r hex HashTable @  Hashlen 0
   DO  cr  i 2 .r ." : " dup i cells +    DO  cr  i 2 .r ." : " dup i cells +

Removed from v.1.4  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>