-
Notifications
You must be signed in to change notification settings - Fork 1
/
METHHASH
73 lines (61 loc) · 2.22 KB
/
METHHASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
\ PRIMHASH.F primitive hash functions
\ -------------------- Find Name for Hashed Value --------------------
16 #vocabulary hashed
2 #vocabulary classes
here ' classes >body - ( voc-pfa-size )
5 cells reserve ( extra for a class )
constant voc-pfa-size
' hashed vcfa>voc constant hash-wid
: unhash ( hash-val -- addr len )
hash-wid voc#threads ( #threads ) 0
do hash-wid i cells+
begin @ ?dup
while ( hash-val link-field )
2dup cell+ ( link> ) >body @ =
if nip ( discard hash value )
l>name nfa-count ( addr len )
unloop exit
then
repeat
loop
drop S" Unknown" ;
: ?unhash ( hash-val -- f1 )
hash-wid voc#threads ( #threads ) 0
do hash-wid i cells+
begin @ ?dup
while ( hash-val link-field )
2dup cell+ ( link> ) >body @ =
if 2drop true
unloop exit
then
repeat
loop drop false ;
0 value obj-save
: .M0NAME ( a1 -- )
1 cells - @ unhash type ;
: .M1NAME ( a1 a2 -- a3 )
2 cells - @ unhash type
cell+ ( a1 becomes a3 ) \ skip next cell also
dup @ ?dup
if obj-save cell - @ \ should use >CLASS, not yet there
voc-pfa-size cell+ + \ should use IFA, not yet there
begin @ 2dup 3 cells+ @ =
start/stop
until nip dup
if cell+ @ unhash space type
else drop ." ???"
then space
else ." self "
then ;
: add-hash ( addr len hash-val -- )
>r 2dup hash-wid search-wordlist
if
r> 2drop 2drop ( already found )
else
current @ >r
hash-wid current !
"header
r> current !
docon ,
r> ,
then ;