static void type_add(char *name, char *value) { int h; stabtype *s; char sc =0; char *v; char *vr; char *split; if (!stab_type_init) { init_hash(); stab_type_init = 1; } /* Split the "value" up into a type name and a value */ split = strchr(value,'='); if (value[0] != '(') split = 0; if (split) { sc = *split; v = value; *split = 0; vr = split+1; } else { v = value; sc = 0; vr = 0; } h = thash(name); s = lnames[h]; while (s) { if (strcmp(s->name,name) == 0) { if (strcmp(s->value,v)) { s->value = wad_string_lookup(v); } goto add_more; } s = s->next; } s = deadnames[h]; if (!s) { s = (stabtype *) wad_malloc(sizeof(stabtype)); } else { deadnames[h] = s->next; } s->name = wad_string_lookup(name); s->value = wad_string_lookup(v); s->next = lnames[h]; s->visit = 0; lnames[h] = s; /* Now take a look at the value. If it is contains other types, we might be able to define more stuff */ add_more: if (vr) { /* There is a mapping to another type */ type_add(v,vr); } }
void type_init(void) { /* These MUST stay in order */ NIL_TYPE = type_add(SIMPLE_KIND); ttab.type[NIL_TYPE].size = 0; BOOLEAN_TYPE = type_add(SIMPLE_KIND); ttab.type[BOOLEAN_TYPE].size = 1; CHAR_TYPE = type_add(SIMPLE_KIND); ttab.type[CHAR_TYPE].size = 1; SHORTINT_TYPE = type_add(SIMPLE_KIND); ttab.type[SHORTINT_TYPE].size = 1; INTEGER_TYPE = type_add(SIMPLE_KIND); ttab.type[INTEGER_TYPE].size = 2; LONGINT_TYPE = type_add(SIMPLE_KIND); ttab.type[LONGINT_TYPE].size = 4; REAL_TYPE = type_add(SIMPLE_KIND); ttab.type[REAL_TYPE].size = 4; }
Type type_add_string(int len) { Type t; if( len == 1 ) return CHAR_TYPE; t=type_add(ARRAY_KIND); ttab.type[t].size = len; ttab.type[t].low = 1; ttab.type[t].high = len+1; ttab.type[t].basetype = CHAR_TYPE; ttab.type[t].strconst = 1; return t; }
static void stab_symbol(Stab *s, char *stabstr) { char *str; char *pstr; char name[1024]; char value[65536]; str = stabstr+s->n_strx; pstr = stab_string_parm(str); if (!pstr) return; strncpy(name,str, pstr-str); name[(int)(pstr-str)] = 0; if ((pstr[1] == 't') || (pstr[1] == 'p') || (pstr[1] == 'r')) { /* A stabs type definition */ /* printf("stab lsym: other=%d, desc=%d, value=%d, str='%s'\n", s->n_other,s->n_desc,s->n_value, stabstr+s->n_strx); */ /* wad_printf("name = '%s', pstr='%s'\n", name, pstr+2); */ wad_strcpy(value,pstr+2); type_add(name,value); } }