1 #include "qcc.h" 2 #include "hash.h" 3 4 struct hash_element *htable[HSIZE1]; 5 int optable[OPTABLESIZE]; 6 7 int stats[HSIZE1]; 8 9 void inithash()10inithash() 11 { 12 int i=0; 13 int index=0; 14 15 for (i=0; i<HSIZE1; i++) 16 { 17 htable[i] = NULL; 18 stats[i] = 0; 19 } 20 21 // JPG - added optable 22 for (i = 0 ; i < OPTABLESIZE ; i++) 23 optable[i] = 0; 24 for (i = 0 ; pr_opcodes[i].name ; i++) 25 { 26 if (pr_opcodes[i].priority > 0) 27 { 28 if (strcmp(pr_opcodes[i].name, pr_opcodes[i-1].name)) 29 { 30 index = (pr_opcodes[i].name[0] + pr_opcodes[i].name[1]) & (OPTABLESIZE - 1); 31 if (optable[index]) 32 { 33 printf("conflict!\n"); 34 exit(1); 35 } 36 optable[index] = i; 37 } 38 } 39 } 40 } 41 HashImmediate(void)42void HashImmediate (void) 43 { 44 if (pr_immediate_type == &type_string) 45 pr_immediate_index = hash(pr_immediate_string); 46 else if (pr_immediate_type == &type_float) 47 { 48 char tmpchar[40]; 49 sprintf(tmpchar, "%d", pr_immediate._int); 50 pr_immediate_index = hash(tmpchar); 51 } 52 else if (pr_immediate_type == &type_vector) 53 { 54 char tmpchar[80]; 55 sprintf(tmpchar, "%.4f,%.4f,%.4f", pr_immediate.vector[0], pr_immediate.vector[1], pr_immediate.vector[2]); 56 pr_immediate_index = hash(tmpchar); 57 } 58 else 59 PR_ParseError ("weird immediate type"); 60 }