#include "macro.h"
#include "macbuf.h"
#include "replace.h"
+#include "dbsymtab.h"
+#ifdef DBSYMTAB
+#include <stb.h>
+int IncludeLevel = 0;
+#endif
extern char options[];
extern char **inctable; /* list of include directories */
FileName = result;
LineNumber = 0;
nestlow = nestlevel;
+#ifdef DBSYMTAB
+ IncludeLevel++;
+ if (options['g']) {
+ C_ms_std(FileName, N_BINCL, 0);
+ }
+#endif /* DBSYMTAB */
}
}
}
{
struct token tk;
int t = GetToken(&tk);
- static char *saved_name = (char *)0;
if (t != EOI) SkipToNewLine();
LineNumber = l; /* the number of the next input line */
if (t == STRING) { /* is there a filespecifier? */
- extern char *source; /* defined in main.c */
-
- if (FileName != source) { /* source points into argv */
- /* Since we are looking one token ahead, we can't
- * free the string when it is mentioned in dot.
- */
- if (dot.tok_file != FileName) {
- free(FileName);
- } else if (dot.tok_file != saved_name) {
- if (saved_name) free(saved_name);
- saved_name = dot.tok_file;
- }
- }
+ /*
+ * Do not attempt to free the old string, since it might
+ * be used in a def structure.
+ */
FileName = tk.tk_bts;
}
}
char *s;
{
register struct idf *p = str2idf(s);
-
+
if (! p->id_resmac) {
p->id_resmac = K_FILE;
p->id_file = (char *) file_head;
init();
LineNumber = 0;
nestlow = -1;
+
+#ifndef LINT
+ init_code(destination
+ && strcmp(destination, "-") != 0
+ ? destination
+ : 0);
+#endif LINT
+
#ifndef NOPP
WorkingDir = getwdir(source);
PushLex(); /* initialize lex machine */
#endif NOPP
#endif DEBUG
{
-#ifndef LINT
- init_code(destination && strcmp(destination, "-") != 0 ?
- destination : 0);
-#endif LINT
-
/* compile the source text */
C_program();
{
while (si->si_identifier) {
struct idf *idf = str2idf(si->si_identifier);
-
+
if (idf->id_special)
fatal("maximum identifier length insufficient");
idf->id_special = si->si_flag;
}
static
-stb_type(tp, assign_num)
+stb_type(tp)
register struct type *tp;
{
char buf[128];
adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
return;
}
- if (tp->tp_dbindex == 0 && assign_num) {
- tp->tp_dbindex = ++stb_count;
- }
- if (tp->tp_dbindex > 0) {
- adds_db_str(sprint(buf, "%d=", tp->tp_dbindex));
- }
- if (tp == void_type) {
- adds_db_str(sprint(buf, "%d", tp->tp_dbindex));
+ if (tp->tp_dbindex < 0 && tp->tp_size < 0) {
+ adds_db_str(sprint(buf, "%d", -tp->tp_dbindex));
return;
}
+ if (tp->tp_dbindex <= 0) {
+ tp->tp_dbindex = ++stb_count;
+ }
+ adds_db_str(sprint(buf, "%d=", tp->tp_dbindex));
switch(tp->tp_fund) {
/* simple types ... */
+ case VOID:
+ adds_db_str(sprint(buf, "%d", void_type->tp_dbindex));
+ break;
case INT:
case LONG:
case CHAR:
/* constructed types ... */
case POINTER:
addc_db_str('*');
- stb_type(tp->tp_up, 0);
+ stb_type(tp->tp_up);
break;
case ARRAY:
if (tp->tp_size > 0) {
adds_db_str("ar");
- stb_type(int_type, 0);
+ stb_type(int_type);
adds_db_str(sprint(buf, ";0;%ld;", tp->tp_size / tp->tp_up->tp_size - 1));
- stb_type(tp->tp_up, 0);
+ stb_type(tp->tp_up);
}
break;
case ENUM:
adds_db_str(sprint(buf,
"xe%s:",
tp->tp_idf->id_text));
+ tp->tp_dbindex = -tp->tp_dbindex;
break;
}
addc_db_str('e');
"x%c%s:",
tp->tp_fund == STRUCT ? 's' : 'u',
tp->tp_idf->id_text));
+ tp->tp_dbindex = -tp->tp_dbindex;
break;
}
adds_db_str(sprint(buf,
adds_db_str(sdef->sd_idf->id_text);
addc_db_str(':');
if (sdef->sd_type->tp_fund == FIELD) {
- stb_type(sdef->sd_type->tp_up, 0);
+ stb_type(sdef->sd_type->tp_up);
adds_db_str(sprint(buf,
",%ld,%ld;",
sdef->sd_offset*8+sdef->sd_type->tp_field->fd_shift,
sdef->sd_type->tp_field->fd_width));
}
else {
- stb_type(sdef->sd_type, 0);
+ stb_type(sdef->sd_type);
adds_db_str(sprint(buf,
",%ld,%ld;",
sdef->sd_offset*8,
break;
case FUNCTION:
addc_db_str('f');
- stb_type(tp->tp_up, 0);
+ stb_type(tp->tp_up);
}
}
create_db_str();
adds_db_str(str);
adds_db_str(":T");
- stb_type(tg->tg_type, 1);
+ stb_type(tg->tg_type);
addc_db_str(';');
C_ms_stb_cst(db_str.base,
N_LSYM,
create_db_str();
adds_db_str(str);
adds_db_str(":t");
- stb_type(tp, 1);
+ stb_type(tp);
addc_db_str(';');
C_ms_stb_cst(db_str.base,
N_LSYM,
switch(kind) {
case FUNCTION:
addc_db_str(df->df_sc == STATIC ? 'f' : 'F');
- stb_type(tp->tp_up, 0);
+ stb_type(tp->tp_up);
addc_db_str(';');
C_ms_stb_pnam(db_str.base, N_FUN, 1 /* proclevel */, str);
break;
(df->df_sc == REGISTER && df->df_address >= 0)) {
/* value parameter */
addc_db_str('p');
- stb_type(tp, 0);
+ stb_type(tp);
addc_db_str(';');
C_ms_stb_cst(db_str.base, N_PSYM, 0, df->df_address);
}
else {
addc_db_str('G');
}
- stb_type(tp, 0);
+ stb_type(tp);
addc_db_str(';');
if (df->df_sc == STATIC && df->df_level >= L_LOCAL) {
C_ms_stb_dlb(db_str.base, N_LCSYM, 0, (label) df->df_address, (arith) 0);
}
}
else { /* local variable */
- stb_type(tp, 1); /* assign type num to avoid
+ stb_type(tp); /* assign type num to avoid
difficult to parse string */
addc_db_str(';');
C_ms_stb_cst(db_str.base, N_LSYM, 0, df->df_address);