#include <a.out.h>
#include <stab.h>
-#define private static
-#define and &&
-#define or ||
-#define not !
-#define div /
-#define mod %
-#define nil 0
-
#define bytes(bits) ((bits) / SZCHAR)
#define bsize(p) bytes(dimtab[p->sizoff]) /* size in bytes of a symbol */
#define NILINDEX -1
#define FORWARD -2
-typedef int Boolean;
+typedef int bool;
#define false 0
#define true 1
int stabLCSYM;
/*
- * Flag for producing either sdb or dbx symbol information.
+ * Flag for producing either sdb || dbx symbol information.
*/
int oldway = false;
+/*
+ * Since type names are lost in the travels && because C has
+ * structural type equivalence we keep a table of type words that
+ * we've already seen. The first time we see a type, it is assigned
+ * (inline) a number && future references just list that number.
+ * Structures, unions, enums, && arrays must be handled carefully
+ * since ! all the necessary information is in the type word.
+ */
+
+typedef struct Typeid *Typeid;
+
+struct Typeid {
+ TWORD tword;
+ int tarray;
+ int tstruct;
+ int tstrtag;
+ int tnum;
+ Typeid chain;
+};
+
+#define TABLESIZE 2003
+
+static int tcount = 1;
+static int t_int, t_char;
+static Typeid typetable[TABLESIZE];
+
/*
* Generate debugging info for a parameter.
* The offset isn't known when it is first entered into the symbol table
/*
* Determine if the given symbol is a global array with dimension 0,
* which only makes sense if it's dimension is to be given later.
- * We therefore currently do not generate symbol information for
+ * We therefore currently do ! generate symbol information for
* such entries.
*/
-#define isglobal(class) ( \
- class == EXTDEF or class == EXTERN or class == STATIC \
-)
-
-private Boolean zero_length_array(p)
+static bool zero_length_array(p)
register struct symtab *p;
{
- Boolean b;
+ bool b;
int t;
- if (not isglobal(p->sclass)) {
+ if (p->sclass != EXTDEF && p->sclass != EXTERN && p->sclass != STATIC) {
b = false;
} else {
t = p->stype;
if (ISFTN(t)) {
t = DECREF(t);
}
- b = (Boolean) (ISARY(t) and dimtab[p->dimoff] == 0);
+ b = (bool) (ISARY(t) && dimtab[p->dimoff] == 0);
}
return b;
}
register struct symtab *p;
char *classname;
int offset;
- Boolean ignore;
- static Boolean firsttime = true;
+ bool ignore;
+ static bool firsttime = true;
if (oldway) {
old_outstab(sym);
- } else if (gdebug and not zero_length_array(sym)) {
+ } else if (gdebug && ! zero_length_array(sym)) {
if (firsttime) {
firsttime = false;
inittypes();
ignore = true;
break;
}
- if (not ignore) {
+ if (! ignore) {
printf("\t.stabs\t\"%s:%s", p->sname, classname);
gentype(p);
geninfo(p);
}
}
-/*
- * Since type names are lost in the travels and because C has
- * structural type equivalence we keep a table of type words that
- * we've already seen. The first time we see a type, it is assigned
- * (inline) a number and future references just list that number.
- * Structures, unions, enums, and arrays must be handled carefully
- * since not all the necessary information is in the type word.
- */
-
-typedef struct Typeid *Typeid;
-
-struct Typeid {
- TWORD tword;
- int tarray;
- int tstruct;
- int tstrtag;
- int tnum;
- Typeid chain;
-};
-
-#define TABLESIZE 2003
-
-private int tcount = 1;
-private int t_int, t_char;
-private Typeid typetable[TABLESIZE];
-
/*
* Look for the given type word in the type table.
*/
-private Typeid typelookup(type, arrindex, strindex, strtag)
+static Typeid typelookup(type, arrindex, strindex, strtag)
TWORD type;
int arrindex;
int strindex;
register int i1, i2;
Typeid t;
- t = typetable[type mod TABLESIZE];
- while (t != nil) {
- if (t->tword == type and
- strindex == t->tstruct and strtag == t->tstrtag) {
+ t = typetable[type % TABLESIZE];
+ while (t != 0) {
+ if (t->tword == type &&
+ strindex == t->tstruct && strtag == t->tstrtag) {
if (arrindex == NILINDEX) {
break;
} else {
tword = type;
i1 = arrindex;
i2 = t->tarray;
- while (ISARY(tword) and dimtab[i1] == dimtab[i2]) {
+ while (ISARY(tword) && dimtab[i1] == dimtab[i2]) {
++i1;
++i2;
tword >>= TSHIFT;
}
/*
- * Enter a type word and associated symtab indices into the type table.
+ * Enter a type word && associated symtab indices into the type table.
*/
-private int entertype(type, arrindex, strindex, strtag)
+static int entertype(type, arrindex, strindex, strtag)
TWORD type;
int arrindex;
int strindex;
t->tstrtag = strtag;
t->tnum = tcount;
++tcount;
- i = type mod TABLESIZE;
+ i = type % TABLESIZE;
t->chain = typetable[i];
typetable[i] = t;
return t->tnum;
* as the old one.
*/
-private reentertype(typeid, type, arrindex, strindex, strtag)
+static reentertype(typeid, type, arrindex, strindex, strtag)
Typeid typeid;
TWORD type;
int arrindex;
t->tstruct = strindex;
t->tstrtag = strtag;
t->tnum = typeid->tnum;
- i = type mod TABLESIZE;
+ i = type % TABLESIZE;
t->chain = typetable[i];
typetable[i] = t;
}
#define builtintype(type) entertype(type, NILINDEX, NILINDEX, NILINDEX)
-private inittypes()
+static inittypes()
{
int t;
maketype("double", builtintype(DOUBLE), t_int, 8L, 0L);
t = builtintype(UNDEF);
printf("\t.stabs\t\"void:t%d=%d", t, t);
- geninfo(nil);
+ geninfo(0);
t = builtintype(FARG);
printf("\t.stabs\t\"???:t%d=%d", t, t_int);
- geninfo(nil);
+ geninfo(0);
}
/*
* Generate info for a new range type.
*/
-private maketype(name, tnum, eqtnum, lower, upper)
+static maketype(name, tnum, eqtnum, lower, upper)
char *name;
int tnum, eqtnum;
long lower, upper;
{
printf("\t.stabs\t\"%s:t%d=r%d;%d;%d;", name, tnum, eqtnum, lower, upper);
- geninfo(nil);
+ geninfo(0);
}
/*
* Generate debugging information for the given type of the given symbol.
*/
-private gentype(sym)
+static gentype(sym)
struct symtab *sym;
{
register struct symtab *p;
} else {
arrindex = NILINDEX;
}
- if (basictype == STRTY or basictype == UNIONTY or basictype == ENUMTY) {
+ if (basictype == STRTY || basictype == UNIONTY || basictype == ENUMTY) {
strindex = dimtab[p->sizoff + 1];
if (strindex == -1) {
strindex = FORWARD;
}
i = arrindex;
typeid = typelookup(t, arrindex, strindex, strtag);
- while (t != basictype and typeid == nil) {
+ while (t != basictype && typeid == 0) {
printf("%d=", entertype(t, i, strindex, strtag));
switch (t&TMASK) {
case PTR:
typeid = typelookup(t, i, strindex, strtag);
}
}
- if (typeid == nil) {
+ if (typeid == 0) {
if (strindex == FORWARD) {
typeid = typelookup(t, NILINDEX, FORWARD, dimtab[p->sizoff + 3]);
- if (typeid == nil) {
+ if (typeid == 0) {
cerror("unbelievable forward reference");
}
printf("%d", typeid->tnum);
}
/*
- * Generate type information for structures, unions, and enumerations.
+ * Generate type information for structures, unions, && enumerations.
*/
-private genstruct(t, structid, index, name, size)
+static genstruct(t, structid, index, name, size)
TWORD t;
int structid;
int index;
}
/*
- * Generate offset and size info.
+ * Generate offset && size info.
*/
-private geninfo(p)
+static geninfo(p)
register struct symtab *p;
{
int stabtype;
- if (p == nil) {
+ if (p == 0) {
printf("\",0x%x,0,0,0\n", N_LSYM);
} else {
switch (p->sclass) {
} else if (gdebug) {
i = dimtab[szindex + 3];
p = &stab[i];
- if (p->sname != nil) {
+ if (p->sname != 0) {
strindex = dimtab[p->sizoff + 1];
typeid = typelookup(p->stype, NILINDEX, FORWARD, i);
- if (typeid == nil) {
+ if (typeid == 0) {
t = 0;
} else {
t = typeid->tnum;
* Old way of doing things.
*/
-private old_fixarg(p)
+static old_fixarg(p)
struct symtab *p; {
if (gdebug) {
old_pstab(p->sname, N_PSYM);
}
}
-private old_outstab(p)
+static old_outstab(p)
struct symtab *p; {
register TWORD ptype;
register char *pname;
}
}
-private old_pstab(name, type)
+static old_pstab(name, type)
char *name;
int type; {
register int i;
}
#ifdef STABDOT
-private old_pstabdot(type, value)
+static old_pstabdot(type, value)
int type;
int value;
{
}
#endif
-private old_poffs(p)
+static old_poffs(p)
register struct symtab *p; {
int s;
if (!gdebug) return;
}
}
-private old_psline() {
+static old_psline() {
static int lastlineno;
register char *cp, *cq;
register int i;
}
}
-private old_plcstab(level) {
+static old_plcstab(level) {
if (!gdebug) return;
#ifdef STABDOT
old_pstabdot(N_LBRAC, level);
#endif
}
-private old_prcstab(level) {
+static old_prcstab(level) {
if (!gdebug) return;
#ifdef STABDOT
pstabdot(N_RBRAC, level);
#endif
}
-private old_pfstab(sname)
+static old_pfstab(sname)
char *sname; {
if (!gdebug) return;
pstab(sname, N_FUN);