+ Have the DEBUG version compile

This commit is contained in:
carl 2019-03-17 22:24:54 +08:00
parent 6bfac1d24d
commit 9f29c76c74
3 changed files with 42 additions and 46 deletions

View file

@ -14,14 +14,16 @@
#include "arith.h" #include "arith.h"
#include "stack.h" #include "stack.h"
#include "def.h" #include "def.h"
#include "idf.h"
#include "type.h" #include "type.h"
#include "proto.h" #include "proto.h"
#include "struct.h" #include "struct.h"
#include "field.h" #include "field.h"
#include "print.h"
#include "Lpars.h" #include "Lpars.h"
#include "label.h" #include "label.h"
#include "expr.h" #include "expr.h"
#include "static.h" /*#include "static.h"*/
#include "declar.h" #include "declar.h"
/* Some routines (symbol2str, type2str, qual2str) which should have /* Some routines (symbol2str, type2str, qual2str) which should have
@ -36,16 +38,29 @@
extern char options[]; extern char options[];
extern char *sprint();
extern struct idf *idf_hashtable[]; extern struct idf *idf_hashtable[];
extern char *symbol2str(), *type2str(), *qual2str(), *next_transient(); extern char *symbol2str();
enum sdef_kind {selector, field}; /* parameter for dumpsdefs */ enum sdef_kind {selector, field}; /* parameter for dumpsdefs */
static int dumplevel; static int dumplevel;
newline() { /* Forward declarations */
static void dumpstack(void);
static char *next_transient(void);
static char *qual2str(int);
static char *type2str(register struct type *);
static void p1_indent(register int);
static void dumpdefs(register struct def *, int);
void dumpidf(register struct idf *, int);
void dumptags(register struct tag *);
void dumptype(register struct type *);
void dumpsdefs(register struct sdef *, enum sdef_kind);
static void p1_expr(int, register struct expr *);
void newline(void)
{
register int dl = dumplevel; register int dl = dumplevel;
print("\n"); print("\n");
@ -57,10 +72,9 @@ newline() {
print(" "); print(" ");
} }
int dumpidf();
dumpidftab(msg, opt)
char msg[]; void dumpidftab(char msg[], int opt)
{ {
/* Dumps the identifier table in readable form (but in /* Dumps the identifier table in readable form (but in
arbitrary order). arbitrary order).
@ -76,7 +90,7 @@ dumpidftab(msg, opt)
print(">>> DUMPIDF, %s (end)\n", msg); print(">>> DUMPIDF, %s (end)\n", msg);
} }
dumpstack() static void dumpstack(void)
{ {
/* Dumps the identifier stack, starting at the top. /* Dumps the identifier stack, starting at the top.
*/ */
@ -96,8 +110,7 @@ dumpstack()
print("\n"); print("\n");
} }
dumpidf(idf, opt) void dumpidf(register struct idf *idf, int opt)
register struct idf *idf;
{ {
/* All information about the identifier idf is divulged in a /* All information about the identifier idf is divulged in a
hopefully readable format. hopefully readable format.
@ -136,8 +149,7 @@ dumpidf(idf, opt)
} }
} }
dumpdefs(def, opt) void dumpdefs(register struct def *def, int opt)
register struct def *def;
{ {
dumplevel++; dumplevel++;
while (def && ((opt&4) || def->df_level)) { while (def && ((opt&4) || def->df_level)) {
@ -158,8 +170,7 @@ dumpdefs(def, opt)
dumplevel--; dumplevel--;
} }
dumptags(tag) void dumptags(register struct tag *tag)
register struct tag *tag;
{ {
dumplevel++; dumplevel++;
while (tag) { while (tag) {
@ -186,9 +197,7 @@ dumptags(tag)
dumplevel--; dumplevel--;
} }
dumpsdefs(sdef, sdk) void dumpsdefs(register struct sdef *sdef, enum sdef_kind sdk)
register struct sdef *sdef;
enum sdef_kind sdk;
{ {
/* Since sdef's are members of two chains, there are actually /* Since sdef's are members of two chains, there are actually
two dumpsdefs's, one following the chain of all selectors two dumpsdefs's, one following the chain of all selectors
@ -218,8 +227,7 @@ dumpsdefs(sdef, sdk)
dumplevel--; dumplevel--;
} }
dumpproto(pl) void dumpproto(register struct proto *pl)
register struct proto *pl;
{ {
register struct type *type; register struct type *type;
register int argcnt = 0; register int argcnt = 0;
@ -234,7 +242,7 @@ dumpproto(pl)
: (pl->pl_flag & PL_ELLIPSIS : (pl->pl_flag & PL_ELLIPSIS
? "ellipsis" : "unknown" )); ? "ellipsis" : "unknown" ));
newline(); newline();
if (type = pl->pl_type){ if ( (type = pl->pl_type) ){
dumptype(type); dumptype(type);
newline(); newline();
} }
@ -250,8 +258,7 @@ dumpproto(pl)
print("dump proto type list (end)\n"); print("dump proto type list (end)\n");
} }
dumptype(tp) void dumptype(register struct type *tp)
register struct type *tp;
{ {
int ops = 1; int ops = 1;
@ -308,9 +315,7 @@ dumptype(tp)
dumplevel--; dumplevel--;
} }
char * static char *type2str(register struct type *tp)
type2str(tp)
register struct type *tp;
{ {
/* Yields a pointer to a one-line description of the type tp. /* Yields a pointer to a one-line description of the type tp.
*/ */
@ -362,9 +367,7 @@ type2str(tp)
return buf; return buf;
} }
char * static char *qual2str(int qual)
qual2str(qual)
int qual;
{ {
char *buf = next_transient(); char *buf = next_transient();
@ -381,8 +384,8 @@ qual2str(qual)
GSTATIC char trans_buf[MAXTRANS][300]; GSTATIC char trans_buf[MAXTRANS][300];
char * /* the ultimate transient buffer supplier */ static char * /* the ultimate transient buffer supplier */
next_transient() next_transient(void)
{ {
static int bnum; static int bnum;
@ -391,9 +394,7 @@ next_transient()
return trans_buf[bnum]; return trans_buf[bnum];
} }
print_expr(msg, expr) void print_expr(char msg[], struct expr *expr)
char msg[];
struct expr *expr;
{ {
/* Provisional routine to print an expression preceded by a /* Provisional routine to print an expression preceded by a
message msg. message msg.
@ -405,8 +406,7 @@ print_expr(msg, expr)
} }
} }
p1_expr(lvl, expr) static void p1_expr(int lvl, register struct expr *expr)
register struct expr *expr;
{ {
p1_indent(lvl); p1_indent(lvl);
if (!expr) { if (!expr) {
@ -481,8 +481,7 @@ p1_expr(lvl, expr)
} }
} }
p1_indent(lvl) static void p1_indent(register int lvl)
register int lvl;
{ {
while (lvl--) while (lvl--)
print(" "); print(" ");

View file

@ -284,8 +284,8 @@ void Info(void)
{ {
extern int cnt_string_cst, cnt_formal, extern int cnt_string_cst, cnt_formal,
cnt_decl_unary, cnt_def, cnt_expr, cnt_field, cnt_decl_unary, cnt_def, cnt_expr, cnt_field,
cnt_e_stack, cnt_localvar, cnt_proto, cnt_repl, cnt_e_stack, cnt_localvar, cnt_proto,
cnt_args, cnt_macro, cnt_stack_level, cnt_stack_level,
cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag, cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag,
cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace, cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace,
cnt_lint_stack_entry, cnt_state, cnt_auto_def, cnt_lint_stack_entry, cnt_state, cnt_auto_def,
@ -293,16 +293,16 @@ void Info(void)
print("\ print("\
%6d string_cst\n%6d formal\n\ %6d string_cst\n%6d formal\n\
%6d decl_unary\n%6d def\n%6d expr\n%6d field\n\ %6d decl_unary\n%6d def\n%6d expr\n%6d field\n\
%6d e_stack\n%6d localvar\n%6d proto\n%6d repl\n\ %6d e_stack\n%6d localvar\n%6d proto\n\
%6d args\n%6d macro\n%6d stack_level\n\ %6d stack_level\n\
%6d stack_entry\n%6d stmt_block\n%6d sdef\n%6d tag\n\ %6d stack_entry\n%6d stmt_block\n%6d sdef\n%6d tag\n\
%6d switch_hdr\n%6d case_entry\n%6d type\n%6d brace\n\ %6d switch_hdr\n%6d case_entry\n%6d type\n%6d brace\n\
%6d lint_stack_entry\n%6d state\n%6d auto_def\n\ %6d lint_stack_entry\n%6d state\n%6d auto_def\n\
%6d expr_state\n%6d argument\n", %6d expr_state\n%6d argument\n",
cnt_string_cst, cnt_formal, cnt_string_cst, cnt_formal,
cnt_decl_unary, cnt_def, cnt_expr, cnt_field, cnt_decl_unary, cnt_def, cnt_expr, cnt_field,
cnt_e_stack, cnt_localvar, cnt_proto, cnt_repl, cnt_e_stack, cnt_localvar, cnt_proto,
cnt_args, cnt_macro, cnt_stack_level, cnt_stack_level,
cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag, cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag,
cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace, cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace,
cnt_lint_stack_entry, cnt_state, cnt_auto_def, cnt_lint_stack_entry, cnt_state, cnt_auto_def,

View file

@ -73,9 +73,6 @@ void add_sel( /* this is horrible */
given in sdefpp; the hook itself must still be empty. given in sdefpp; the hook itself must still be empty.
*/ */
arith offset; arith offset;
#ifndef NOBITFIELD
extern arith add_field();
#endif /* NOBITFIELD */
struct tag *tg = stp->tp_idf->id_tag; /* or union */ struct tag *tg = stp->tp_idf->id_tag; /* or union */
struct sdef *sdef = idf->id_sdef; struct sdef *sdef = idf->id_sdef;