/* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Header$ */ /* IDENTIFIER DESCRIPTOR */ #include "nopp.h" /* Since the % operation in the calculation of the hash function turns out to be expensive, it is replaced by the cheaper XOR (^). Each character of the identifier is xored with an 8-bit mask which depends on the position of the character; the sum of these results is the hash value. The random masks are obtained from a congruence generator in idf.c. */ #define HASHSIZE 256 /* must be a power of 2 */ #define HASH_X 0253 /* Knuth's X */ #define HASH_A 77 /* Knuth's a */ #define HASH_C 153 /* Knuth's c */ extern char hmask[]; /* the random masks */ #define HASHMASK (HASHSIZE-1) /* since it is a power of 2 */ #define STARTHASH() (0) #define ENHASH(hs,ch,ps) (hs + (ch ^ hmask[ps])) #define STOPHASH(hs) (hs & HASHMASK) struct idf { struct idf *next; char *id_text; #ifndef NOPP struct macro *id_macro; int id_resmac; /* if nonzero: keyword of macroproc. */ #endif /* NOPP */ int id_reserved; /* non-zero for reserved words */ char *id_file; /* file containing the occurrence */ unsigned int id_line; /* line number of the occurrence */ struct def *id_def; /* variables, typedefs, enum-constants */ struct sdef *id_sdef; /* selector tags */ struct tag *id_struct; /* struct and union tags */ struct tag *id_enum; /* enum tags */ int id_special; /* special action needed at occurrence */ }; /* ALLOCDEF "idf" 50 */ extern struct idf *str2idf(), *idf_hashed(); extern int level; extern struct idf *gen_idf();