X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3e12a539bbd885a6ede3fbf9e6b2e9a0f3230c44..453fc342adf94edb47bb9e20aebfc9665cc835b0:/usr/src/old/dbx/symbols.c diff --git a/usr/src/old/dbx/symbols.c b/usr/src/old/dbx/symbols.c index 6b7499e3f3..3060f55dd4 100644 --- a/usr/src/old/dbx/symbols.c +++ b/usr/src/old/dbx/symbols.c @@ -5,10 +5,10 @@ */ #ifndef lint -static char sccsid[] = "@(#)symbols.c 5.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)symbols.c 5.4 (Berkeley) %G%"; #endif not lint -static char rcsid[] = "$Header: symbols.c,v 1.6 84/12/26 10:42:31 linton Exp $"; +static char rcsid[] = "$Header: symbols.c,v 1.3 87/03/26 23:17:35 donn Exp $"; /* * Symbol management. @@ -41,7 +41,8 @@ typedef struct Symbol *Symbol; */ typedef enum { - BADUSE, CONST, TYPE, VAR, ARRAY, DYNARRAY, SUBARRAY, PTRFILE, RECORD, FIELD, + BADUSE, CONST, TYPE, VAR, ARRAY, OPENARRAY, DYNARRAY, SUBARRAY, + PTRFILE, RECORD, FIELD, PROC, FUNC, FVAR, REF, PTR, FILET, SET, RANGE, LABEL, WITHPTR, SCAL, STR, PROG, IMPROPER, VARNT, FPROC, FFUNC, MODULE, TAG, COMMON, EXTREF, TYPEREF @@ -49,11 +50,18 @@ typedef enum { typedef enum { R_CONST, R_TEMP, R_ARG, R_ADJUST } Rangetype; +#define INREG 0 +#define STK 1 +#define EXT 2 + +typedef unsigned integer Storage; + struct Symbol { Name name; Language language; - Symclass class; - Integer level; + Symclass class : 8; + Storage storage : 2; + unsigned int level : 6; /* for variables stored on stack only */ Symbol type; Symbol chain; union { @@ -125,7 +133,7 @@ boolean showaggrs; #define nosource(f) (not (f)->symvalue.funcv.src) #define isinline(f) ((f)->symvalue.funcv.inline) -#define isreg(s) (s->level < 0) +#define isreg(s) (s->storage == INREG) #include "tree.h" @@ -149,19 +157,21 @@ boolean showaggrs; /* * Symbol table structure currently does not support deletions. + * Hash table size is a power of two to make hashing faster. + * Using a non-prime is ok since we aren't doing rehashing. */ -#define HASHTABLESIZE 2003 +#define HASHTABLESIZE 8192 private Symbol hashtab[HASHTABLESIZE]; -#define hash(name) ((((unsigned) name) >> 2) mod HASHTABLESIZE) +#define hash(name) ((((unsigned) name) >> 2) & (HASHTABLESIZE - 1)) /* * Allocate a new symbol. */ -#define SYMBLOCKSIZE 100 +#define SYMBLOCKSIZE 1000 typedef struct Sympool { struct Symbol sym[SYMBLOCKSIZE]; @@ -177,7 +187,7 @@ public Symbol symbol_alloc() if (nleft <= 0) { newpool = new(Sympool); - bzero(newpool, sizeof(newpool)); + bzero(newpool, sizeof(*newpool)); newpool->prevpool = sympool; sympool = newpool; nleft = SYMBLOCKSIZE; @@ -240,6 +250,7 @@ Symbol chain; s = symbol_alloc(); s->name = name; s->language = primlang; + s->storage = EXT; s->level = blevel; s->class = class; s->type = type; @@ -513,7 +524,7 @@ Symbol s; integer r; checkref(s); - if (s->level < 0) { + if (s->storage == INREG) { r = s->symvalue.offset; } else { r = -1; @@ -549,9 +560,9 @@ Symbol s; * register - offset is register number */ -#define isglobal(s) (s->level == 1) -#define islocaloff(s) (s->level >= 2 and s->symvalue.offset < 0) -#define isparamoff(s) (s->level >= 2 and s->symvalue.offset >= 0) +#define isglobal(s) (s->storage == EXT) +#define islocaloff(s) (s->storage == STK and s->symvalue.offset < 0) +#define isparamoff(s) (s->storage == STK and s->symvalue.offset >= 0) public Address address (s, frame) Symbol s; @@ -610,7 +621,8 @@ integer r; s = insert(n); s->language = t_addr->language; s->class = VAR; - s->level = -3; + s->storage = INREG; + s->level = 3; s->type = t_addr; s->symvalue.offset = r; } @@ -756,6 +768,7 @@ Symbol sym; r = nel*elsize; break; + case OPENARRAY: case DYNARRAY: r = (t->symvalue.ndims + 1) * sizeof(Word); break; @@ -782,9 +795,16 @@ Symbol sym; break; case TYPE: + /* + * This causes problems on the IRIS because of the compiler bug + * with stab offsets for parameters. Not sure it's really + * necessary anyway. + */ +# ifndef IRIS if (t->type->class == PTR and t->type->type->class == BADUSE) { findtype(t); } +# endif r = size(t->type); break; @@ -885,7 +905,7 @@ Symbol s; if (s->class == REF) { t = rtype(s->type); - if (t->class == DYNARRAY) { + if (t->class == OPENARRAY) { r = (t->symvalue.ndims + 1) * sizeof(Word); } else if (t->class == SUBARRAY) { r = (2 * t->symvalue.ndims + 1) * sizeof(Word); @@ -925,7 +945,7 @@ Symbol type; Symbol t; t = rtype(type); - return (boolean) (t->class == DYNARRAY); + return (boolean) (t->class == OPENARRAY); } /* @@ -1051,17 +1071,17 @@ register Symbol t1, t2; b = isblock(t2); } else if (t2 == procsym) { b = isblock(t1); - } else if (t1->language == primlang) { - if (t2->language == primlang) { - b = primlang_typematch(rtype(t1), rtype(t2)); - } else { - b = (boolean) (*language_op(t2->language, L_TYPEMATCH))(t1, t2); - } - } else if (t2->language == primlang) { - b = (boolean) (*language_op(t1->language, L_TYPEMATCH))(t1, t2); } else if (t1->language == nil) { if (t2->language == nil) { b = false; + } else if (t2->language == primlang) { + b = (boolean) primlang_typematch(rtype(t1), rtype(t2)); + } else { + b = (boolean) (*language_op(t2->language, L_TYPEMATCH))(t1, t2); + } + } else if (t1->language == primlang) { + if (t2->language == primlang or t2->language == nil) { + b = primlang_typematch(rtype(t1), rtype(t2)); } else { b = (boolean) (*language_op(t2->language, L_TYPEMATCH))(t1, t2); }