8 typedef struct hashlevel
{
10 struct hashlevel
*sublevels
;
13 static hashlevel
*root
;
15 void hashmap_initialize()
19 root
= calloc(1, sizeof (hashlevel
));
20 temp
= find_var("one");
21 temp
->type
= KNIGHT_REF
;
22 temp
->val
.knight_ref
= 1;
24 temp
= find_var("two");
25 temp
->type
= KNIGHT_REF
;
26 temp
->val
.knight_ref
= 2;
28 temp
= find_var("three");
29 temp
->type
= KNIGHT_REF
;
30 temp
->val
.knight_ref
= 3;
32 temp
= find_var("four");
33 temp
->type
= KNIGHT_REF
;
34 temp
->val
.knight_ref
= 4;
36 temp
= find_var("five");
37 temp
->type
= KNIGHT_REF
;
38 temp
->val
.knight_ref
= 5;
40 temp
= find_var("six");
41 temp
->type
= KNIGHT_REF
;
42 temp
->val
.knight_ref
= 6;
44 temp
= find_var("seven");
45 temp
->type
= KNIGHT_REF
;
46 temp
->val
.knight_ref
= 7;
48 temp
= find_var("eight");
49 temp
->type
= KNIGHT_REF
;
50 temp
->val
.knight_ref
= 8;
52 temp
= find_var("nine");
53 temp
->type
= KNIGHT_REF
;
54 temp
->val
.knight_ref
= 9;
58 static int index(const char c
)
69 ast_var
*find_var(const char *key
)
71 const char *c_key
= key
;
72 hashlevel
*c_hash
= root
;
78 while (*c_key
!= '\0') {
79 c_idx
= index(*c_key
);
80 if (!c_hash
->sublevels
)
81 c_hash
->sublevels
= calloc(37, sizeof (hashlevel
));
82 c_hash
= &(c_hash
->sublevels
[c_idx
]);
87 c_hash
->data
= calloc(1, sizeof (ast_var
));