adapted to print(3L) module

This commit is contained in:
erikb 1986-04-03 14:32:56 +00:00
parent 725d3fa6ea
commit 4c75213caa
11 changed files with 87 additions and 109 deletions

View file

@ -33,7 +33,6 @@ decspecs.c
decspecs.str decspecs.str
def.str def.str
domacro.c domacro.c
doprnt.c
dumpidf.c dumpidf.c
error.c error.c
eval.c eval.c

View file

@ -12,9 +12,10 @@ SYSLIB = /user1/erikb/em/lib/libsystem.a
EMKLIB = /user1/erikb/em/lib/libemk.a EMKLIB = /user1/erikb/em/lib/libemk.a
EMELIB = /user1/erikb/em/lib/libeme.a EMELIB = /user1/erikb/em/lib/libeme.a
STRLIB = /user1/erikb/em/lib/libstr.a STRLIB = /user1/erikb/em/lib/libstr.a
PRTLIB = /user1/erikb/em/lib/libprint.a
EMMESLIB = /user1/erikb/em/lib/libem_mes.a EMMESLIB = /user1/erikb/em/lib/libem_mes.a
LIBS = $(EMMESLIB) $(EMKLIB) $(STRLIB) $(SYSLIB) LIBS = $(EMMESLIB) $(EMKLIB) $(PRTLIB) $(STRLIB) $(SYSLIB)
ELIBS = $(EMMESLIB) $(EMELIB) $(STRLIB) $(SYSLIB) ELIBS = $(EMMESLIB) $(EMELIB) $(PRTLIB) $(STRLIB) $(SYSLIB)
LIB_INCLUDES = /user1/erikb/em/h LIB_INCLUDES = /user1/erikb/em/h
# Where to install the compiler and its driver # Where to install the compiler and its driver
@ -47,7 +48,7 @@ COBJ = main.o idf.o declarator.o decspecs.o struct.o \
input.o domacro.o replace.o init.o options.o \ input.o domacro.o replace.o init.o options.o \
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \ scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
switch.o storage.o ival.o conversion.o \ switch.o storage.o ival.o conversion.o \
blocks.o dataflow.o doprnt.o blocks.o dataflow.o
# Objects of other generated C files # Objects of other generated C files
GOBJ = char.o symbol2str.o next.o GOBJ = char.o symbol2str.o next.o
@ -62,8 +63,7 @@ GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \ idepth.h idfsize.h ifdepth.h inputtype.h inumlength.h lapbuf.h \
maxincl.h myalloc.h nobitfield.h nopp.h \ maxincl.h myalloc.h nobitfield.h nopp.h \
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \ nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
strsize.h target_sizes.h textsize.h use_tmp.h \ strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h
ssize.h spec_arith.h
# Other generated files, for 'make clean' only # Other generated files, for 'make clean' only
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \ GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
@ -191,15 +191,15 @@ sim: cfiles
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC) $(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: LLlex.h Lpars.h alloc.h arith.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nopp.h spec_arith.h specials.h target_sizes.h tokenname.h type.h use_tmp.h ssize.h main.o: LLlex.h Lpars.h alloc.h arith.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nopp.h spec_arith.h specials.h target_sizes.h tokenname.h type.h use_tmp.h
idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h
declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h spec_arith.h type.h decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h spec_arith.h type.h
struct.o: LLlex.h Lpars.h align.h arith.h assert.h botch_free.h debug.h def.h field.h idf.h level.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h storage.h struct.h type.h struct.o: LLlex.h Lpars.h align.h arith.h assert.h botch_free.h debug.h def.h field.h idf.h level.h nobitfield.h nopp.h sizes.h spec_arith.h stack.h storage.h struct.h type.h
expr.o: LLlex.h Lpars.h alloc.h arith.h botch_free.h declar.h decspecs.h def.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h level.h expr.o: LLlex.h Lpars.h alloc.h arith.h botch_free.h declar.h decspecs.h def.h expr.h idf.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h struct.h type.h ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h struct.h type.h
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h
cstoper.o: Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h assert.h cstoper.o: Lpars.h arith.h assert.h debug.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h
alloc.o: alloc.h assert.h debug.h myalloc.h alloc.o: alloc.h assert.h debug.h myalloc.h
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h
@ -227,7 +227,6 @@ ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h expr.h field.h id
conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h conversion.o: Lpars.h arith.h nobitfield.h sizes.h spec_arith.h type.h
blocks.o: arith.h atw.h sizes.h spec_arith.h blocks.o: arith.h atw.h sizes.h spec_arith.h
dataflow.o: dataflow.h dataflow.o: dataflow.h
doprnt.o: ssize.h
tokenfile.o: Lpars.h tokenfile.o: Lpars.h
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h storage.h type.h

View file

@ -122,10 +122,6 @@
#undef NOBITFIELD 1 /* implement bitfields */ #undef NOBITFIELD 1 /* implement bitfields */
!File: ssize.h
#define SSIZE 1024 /* string-buffer size for print routines */
!File: spec_arith.h !File: spec_arith.h
/* describes internal compiler arithmetics */ /* describes internal compiler arithmetics */
#undef SPECIAL_ARITHMETICS /* something different from native long */ #undef SPECIAL_ARITHMETICS /* something different from native long */

View file

@ -152,7 +152,7 @@ mem_stat()
extern char options[]; extern char options[];
if (options['m']) if (options['m'])
printf("Total nr of bytes allocated: %d\n", print("Total nr of bytes allocated: %d\n",
sys_break(0) - firstfreeb); sys_break(0) - firstfreeb);
} }
#endif DEBUG #endif DEBUG

View file

@ -20,15 +20,14 @@ DfaStartFunction(nm)
DfaEndFunction() DfaEndFunction()
{ {
if (NumberOfCalls == 0) { if (NumberOfCalls == 0)
printf("DFA: %s: --none--\n", CurrentFunction); print("DFA: %s: --none--\n", CurrentFunction);
}
} }
DfaCallFunction(s) DfaCallFunction(s)
char *s; char *s;
{ {
printf("DFA: %s: %s\n", CurrentFunction, s); print("DFA: %s: %s\n", CurrentFunction, s);
++NumberOfCalls; ++NumberOfCalls;
} }
#endif DATAFLOW #endif DATAFLOW

View file

@ -29,7 +29,7 @@
extern char options[]; extern char options[];
extern char *sprintf(); extern char *sprint();
extern struct idf *idf_hashtable[]; extern struct idf *idf_hashtable[];
extern char *symbol2str(), *type2str(), *next_transient(); extern char *symbol2str(), *type2str(), *next_transient();
@ -42,13 +42,13 @@ static
newline() { newline() {
int dl = dumplevel; int dl = dumplevel;
printf("\n"); print("\n");
while (dl >= 2) { while (dl >= 2) {
printf("\t"); print("\t");
dl -= 2; dl -= 2;
} }
if (dl) if (dl)
printf(" "); print(" ");
} }
dumpidftab(msg, opt) dumpidftab(msg, opt)
@ -62,7 +62,7 @@ dumpidftab(msg, opt)
*/ */
int i; int i;
printf(">>> DUMPIDF, %s (start)", msg); print(">>> DUMPIDF, %s (start)", msg);
dumpstack(); dumpstack();
for (i = 0; i < HASHSIZE; i++) { for (i = 0; i < HASHSIZE; i++) {
struct idf *notch = idf_hashtable[i]; struct idf *notch = idf_hashtable[i];
@ -73,7 +73,7 @@ dumpidftab(msg, opt)
} }
} }
newline(); newline();
printf(">>> DUMPIDF, %s (end)\n", msg); print(">>> DUMPIDF, %s (end)\n", msg);
} }
dumpstack() { dumpstack() {
@ -85,14 +85,14 @@ dumpstack() {
struct stack_entry *se = stl->sl_entry; struct stack_entry *se = stl->sl_entry;
newline(); newline();
printf("%3d: ", stl->sl_level); print("%3d: ", stl->sl_level);
while (se) { while (se) {
printf("%s ", se->se_idf->id_text); print("%s ", se->se_idf->id_text);
se = se->next; se = se->next;
} }
stl = stl->sl_previous; stl = stl->sl_previous;
} }
printf("\n"); print("\n");
} }
dumpidf(idf, opt) dumpidf(idf, opt)
@ -109,43 +109,43 @@ dumpidf(idf, opt)
if ((opt&1) && idf->id_macro) { if ((opt&1) && idf->id_macro) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
printf(" macro"); print(" macro");
} }
#endif NOPP #endif NOPP
if ((opt&2) && idf->id_reserved) { if ((opt&2) && idf->id_reserved) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
printf(" reserved: %d;", idf->id_reserved); print(" reserved: %d;", idf->id_reserved);
} }
if (idf->id_def && ((opt&4) || idf->id_def->df_level)) { if (idf->id_def && ((opt&4) || idf->id_def->df_level)) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
dumpdefs(idf->id_def, opt); dumpdefs(idf->id_def, opt);
} }
if (idf->id_sdef) { if (idf->id_sdef) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
dumpsdefs(idf->id_sdef, selector); dumpsdefs(idf->id_sdef, selector);
} }
if (idf->id_struct) { if (idf->id_struct) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
dumptags(idf->id_struct); dumptags(idf->id_struct);
} }
if (idf->id_enum) { if (idf->id_enum) {
if (!started++) { if (!started++) {
newline(); newline();
printf("%s:", idf->id_text); print("%s:", idf->id_text);
} }
dumptags(idf->id_enum); dumptags(idf->id_enum);
} }
@ -157,7 +157,7 @@ dumpdefs(def, opt)
dumplevel++; dumplevel++;
while (def && ((opt&4) || def->df_level)) { while (def && ((opt&4) || def->df_level)) {
newline(); newline();
printf("L%d: %s %s%s%s%s%s %lo;", print("L%d: %s %s%s%s%s%s %lo;",
def->df_level, def->df_level,
symbol2str(def->df_sc), symbol2str(def->df_sc),
(def->df_register != REG_NONE) ? "reg " : "", (def->df_register != REG_NONE) ? "reg " : "",
@ -181,7 +181,7 @@ dumptags(tag)
register int fund = tp->tp_fund; register int fund = tp->tp_fund;
newline(); newline();
printf("L%d: %s %s", print("L%d: %s %s",
tag->tg_level, tag->tg_level,
fund == STRUCT ? "struct" : fund == STRUCT ? "struct" :
fund == UNION ? "union" : fund == UNION ? "union" :
@ -189,12 +189,12 @@ dumptags(tag)
tp->tp_idf->id_text tp->tp_idf->id_text
); );
if (is_struct_or_union(fund)) { if (is_struct_or_union(fund)) {
printf(" {"); print(" {");
dumpsdefs(tp->tp_sdef, field); dumpsdefs(tp->tp_sdef, field);
newline(); newline();
printf("}"); print("}");
} }
printf(";"); print(";");
tag = tag->next; tag = tag->next;
} }
dumplevel--; dumplevel--;
@ -214,16 +214,16 @@ dumpsdefs(sdef, sdk)
dumplevel++; dumplevel++;
while (sdef) { while (sdef) {
newline(); newline();
printf("L%d: ", sdef->sd_level); print("L%d: ", sdef->sd_level);
#ifndef NOBITFIELD #ifndef NOBITFIELD
if (sdk == selector) if (sdk == selector)
#endif NOBITFIELD #endif NOBITFIELD
printf("selector %s at offset %lu in %s;", print("selector %s at offset %lu in %s;",
type2str(sdef->sd_type), type2str(sdef->sd_type),
sdef->sd_offset, type2str(sdef->sd_stype) sdef->sd_offset, type2str(sdef->sd_stype)
); );
#ifndef NOBITFIELD #ifndef NOBITFIELD
else printf("field %s at offset %lu;", else print("field %s at offset %lu;",
type2str(sdef->sd_type), sdef->sd_offset type2str(sdef->sd_type), sdef->sd_offset
); );
#endif NOBITFIELD #endif NOBITFIELD
@ -243,35 +243,35 @@ type2str(tp)
buf[0] = '\0'; buf[0] = '\0';
if (!tp) { if (!tp) {
sprintf(buf, "<NILTYPE>"); sprint(buf, "<NILTYPE>");
return buf; return buf;
} }
sprintf(buf, "(@%lx, #%ld, &%d) ", sprint(buf, "(@%lx, #%ld, &%d) ",
tp, (long)tp->tp_size, tp->tp_align); tp, (long)tp->tp_size, tp->tp_align);
while (ops) { while (ops) {
switch (tp->tp_fund) { switch (tp->tp_fund) {
case POINTER: case POINTER:
sprintf(buf, "%spointer to ", buf); sprint(buf, "%spointer to ", buf);
break; break;
case ARRAY: case ARRAY:
sprintf(buf, "%sarray [%ld] of ", buf, tp->tp_size); sprint(buf, "%sarray [%ld] of ", buf, tp->tp_size);
break; break;
case FUNCTION: case FUNCTION:
sprintf(buf, "%sfunction yielding ", buf); sprint(buf, "%sfunction yielding ", buf);
break; break;
default: default:
sprintf(buf, "%s%s%s", buf, sprint(buf, "%s%s%s", buf,
tp->tp_unsigned ? "unsigned " : "", tp->tp_unsigned ? "unsigned " : "",
symbol2str(tp->tp_fund) symbol2str(tp->tp_fund)
); );
if (tp->tp_idf) if (tp->tp_idf)
sprintf(buf, "%s %s", buf, sprint(buf, "%s %s", buf,
tp->tp_idf->id_text); tp->tp_idf->id_text);
#ifndef NOBITFIELD #ifndef NOBITFIELD
if (tp->tp_field) { if (tp->tp_field) {
struct field *fd = tp->tp_field; struct field *fd = tp->tp_field;
sprintf(buf, "%s [s=%ld,w=%ld]", buf, sprint(buf, "%s [s=%ld,w=%ld]", buf,
fd->fd_shift, fd->fd_width); fd->fd_shift, fd->fd_width);
} }
#endif NOBITFIELD #endif NOBITFIELD
@ -302,8 +302,8 @@ print_expr(msg, expr)
message msg. message msg.
*/ */
if (options['x']) { if (options['x']) {
printf("\n%s: ", msg); print("\n%s: ", msg);
printf("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n"); print("(L=line, T=type, r/lV=r/lvalue, F=flags, D=depth)\n");
p1_expr(0, expr); p1_expr(0, expr);
} }
} }
@ -315,10 +315,10 @@ p1_expr(lvl, expr)
p1_indent(lvl); p1_indent(lvl);
if (!expr) { if (!expr) {
printf("NILEXPR\n"); print("NILEXPR\n");
return; return;
} }
printf("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ", print("expr: L=%u, T=%s, %cV, F=%03o, D=%d, %s: ",
expr->ex_line, expr->ex_line,
type2str(expr->ex_type), type2str(expr->ex_type),
expr->ex_lvalue ? 'l' : 'r', expr->ex_lvalue ? 'l' : 'r',
@ -335,52 +335,52 @@ p1_expr(lvl, expr)
case Value: case Value:
switch (expr->VL_CLASS) { switch (expr->VL_CLASS) {
case Const: case Const:
printf("(Const) "); print("(Const) ");
break; break;
case Name: case Name:
printf("(Name) %s + ", expr->VL_IDF->id_text); print("(Name) %s + ", expr->VL_IDF->id_text);
break; break;
case Label: case Label:
printf("(Label) .%lu + ", expr->VL_LBL); print("(Label) .%lu + ", expr->VL_LBL);
break; break;
default: default:
printf("(Unknown) "); print("(Unknown) ");
break; break;
} }
printf(expr->ex_type->tp_unsigned ? "%lu\n" : "%ld\n", print(expr->ex_type->tp_unsigned ? "%lu\n" : "%ld\n",
expr->VL_VALUE); expr->VL_VALUE);
break; break;
case String: case String:
{ {
char bts2str(); char bts2str();
printf( print(
"%s\n", "%s\n",
bts2str(expr->SG_VALUE, expr->SG_LEN, next_transient()) bts2str(expr->SG_VALUE, expr->SG_LEN, next_transient())
); );
break; break;
} }
case Float: case Float:
printf("%s\n", expr->FL_VALUE); print("%s\n", expr->FL_VALUE);
break; break;
case Oper: case Oper:
o = &expr->ex_object.ex_oper; o = &expr->ex_object.ex_oper;
printf("\n"); print("\n");
p1_expr(lvl+1, o->op_left); p1_expr(lvl+1, o->op_left);
p1_indent(lvl); printf("%s\n", symbol2str(o->op_oper)); p1_indent(lvl); print("%s\n", symbol2str(o->op_oper));
p1_expr(lvl+1, o->op_right); p1_expr(lvl+1, o->op_right);
break; break;
case Type: case Type:
printf("\n"); print("\n");
break; break;
default: default:
printf("UNKNOWN CLASS\n"); print("UNKNOWN CLASS\n");
break; break;
} }
} }
p1_indent(lvl) { p1_indent(lvl) {
while (lvl--) while (lvl--)
printf(" "); print(" ");
} }
#endif DEBUG #endif DEBUG

View file

@ -209,9 +209,9 @@ _error(class, expr, fmt, argv)
} }
if (fn) if (fn)
fprintf(ERROUT, "\"%s\", line %u: ", fn, ln); fprint(ERROUT, "\"%s\", line %u: ", fn, ln);
if (remark) if (remark)
fprintf(ERROUT, "%s ", remark); fprint(ERROUT, "%s ", remark);
doprnt(ERROUT, fmt, argv); /* contents of error */ doprnt(ERROUT, fmt, argv); /* contents of error */
fprintf(ERROUT, "\n"); fprint(ERROUT, "\n");
} }

View file

@ -88,7 +88,7 @@ hash_stat()
if (options['h']) { if (options['h']) {
int i; int i;
printf("Hash table tally:\n"); print("Hash table tally:\n");
for (i = 0; i < HASHSIZE; i++) { for (i = 0; i < HASHSIZE; i++) {
struct idf *notch = idf_hashtable[i]; struct idf *notch = idf_hashtable[i];
int cnt = 0; int cnt = 0;
@ -97,9 +97,9 @@ hash_stat()
cnt++; cnt++;
notch = notch->next; notch = notch->next;
} }
printf("%d %d\n", i, cnt); print("%d %d\n", i, cnt);
} }
printf("End hash table tally\n"); print("End hash table tally\n");
} }
} }
#endif DEBUG #endif DEBUG
@ -139,9 +139,9 @@ gen_idf()
*/ */
static int name_cnt; static int name_cnt;
char buff[100]; char buff[100];
char *sprintf(); char *sprint();
sprintf(buff, "#%d in %s, line %u", sprint(buff, "#%d in %s, line %u",
++name_cnt, dot.tk_file, dot.tk_line); ++name_cnt, dot.tk_file, dot.tk_line);
return str2idf(buff); return str2idf(buff);
} }

View file

@ -21,7 +21,6 @@
#include "LLlex.h" #include "LLlex.h"
#include "alloc.h" #include "alloc.h"
#include "specials.h" #include "specials.h"
#include "ssize.h"
extern struct tokenname tkidf[], tkother[]; extern struct tokenname tkidf[], tkother[];
extern char *symbol2str(); extern char *symbol2str();
@ -296,12 +295,12 @@ preprocess()
if (strcmp(lastfilenm, dot.tk_file) == 0) { if (strcmp(lastfilenm, dot.tk_file) == 0) {
if (dot.tk_line - lastlineno <= 1) { if (dot.tk_line - lastlineno <= 1) {
lastlineno++; lastlineno++;
printf("\n"); print("\n");
} }
else { else {
lastlineno = dot.tk_line; lastlineno = dot.tk_line;
if (!options['P']) if (!options['P'])
printf("\n#line %ld \"%s\"\n", print("\n#line %ld \"%s\"\n",
lastlineno, lastlineno,
lastfilenm lastfilenm
); );
@ -311,7 +310,7 @@ preprocess()
lastfilenm = dot.tk_file; lastfilenm = dot.tk_file;
lastlineno = dot.tk_line; lastlineno = dot.tk_line;
if (!options['P']) if (!options['P'])
printf("\n#line %ld \"%s\"\n", print("\n#line %ld \"%s\"\n",
lastlineno, lastfilenm); lastlineno, lastfilenm);
} }
} }
@ -319,35 +318,33 @@ preprocess()
if (strcmp(lastfilenm, dot.tk_file) != 0) { if (strcmp(lastfilenm, dot.tk_file) != 0) {
lastfilenm = dot.tk_file; lastfilenm = dot.tk_file;
if (!options['P']) if (!options['P'])
printf("\n#line %ld \"%s\"\n", print("\n#line %ld \"%s\"\n",
lastlineno, lastfilenm); lastlineno, lastfilenm);
} }
switch (DOT) { switch (DOT) {
case IDENTIFIER: case IDENTIFIER:
case TYPE_IDENTIFIER: case TYPE_IDENTIFIER:
printf(dot.tk_idf->id_text); print("%s ", dot.tk_idf->id_text);
printf(" ");
break; break;
case STRING: case STRING:
{ {
char sbuf[SSIZE]; char sbuf[1024]; /* a transient buffer */
char *bts2str(); char *bts2str();
printf("\"%s\" ", print("\"%s\" ", bts2str(dot.tk_bts, dot.tk_len, sbuf));
bts2str(dot.tk_bts, dot.tk_len, sbuf));
break; break;
} }
case INTEGER: case INTEGER:
printf("%ld ", dot.tk_ival); print("%ld ", dot.tk_ival);
break; break;
case FLOATING: case FLOATING:
printf("%s ", dot.tk_fval); print("%s ", dot.tk_fval);
break; break;
case EOI: case EOI:
case EOF: case EOF:
return; return;
default: /* very expensive... */ default: /* very expensive... */
printf("%s ", symbol2str(DOT)); print("%s ", symbol2str(DOT));
} }
} }
} }

View file

@ -210,7 +210,7 @@ unstack_world()
#ifdef DEBUG #ifdef DEBUG
if (options['a']) { if (options['a']) {
printf("\"%s\", %s, %s, %s\n", print("\"%s\", %s, %s, %s\n",
idf->id_text, idf->id_text,
(def->df_alloc == 0) ? "no alloc" : (def->df_alloc == 0) ? "no alloc" :
(def->df_alloc == ALLOC_SEEN) ? "alloc seen" : (def->df_alloc == ALLOC_SEEN) ? "alloc seen" :

View file

@ -72,30 +72,17 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
register struct sdef *newsdef; register struct sdef *newsdef;
int lvl = tg->tg_level; int lvl = tg->tg_level;
/*
* char *type2str();
* printf("add_sel: \n stp = %s\n tp = %s\n name = %s\n *szp = %ld\n",
* type2str(stp), type2str(tp), idf->id_text, *szp);
* ASSERT(**sdefpp == 0);
* ASSERT(tg->tg_type == stp);
*/
if (options['R'] && !is_anon_idf(idf)) { if (options['R'] && !is_anon_idf(idf)) {
/* a K & R test */ /* a K & R test */
if (idf->id_struct && idf->id_struct->tg_level == level if (idf->id_struct && idf->id_struct->tg_level == level)
) { warning("%s is also a struct/union tag", idf->id_text);
warning("%s is also a struct/union tag",
idf->id_text);
}
} }
if (stp->tp_fund == STRUCT) { if (stp->tp_fund == STRUCT) {
#ifndef NOBITFIELD #ifndef NOBITFIELD
if (fd == 0) { /* no field width specified */ if (fd == 0) { /* no field width specified */
#endif NOBITFIELD
offset = align(*szp, tp->tp_align); offset = align(*szp, tp->tp_align);
field_busy = 0; field_busy = 0;
#ifndef NOBITFIELD
} }
else { else {
/* if something is wrong, the type of the /* if something is wrong, the type of the
@ -104,6 +91,9 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
*/ */
offset = add_field(szp, fd, &tp, idf, stp); offset = add_field(szp, fd, &tp, idf, stp);
} }
#else NOBITFIELD
offset = align(*szp, tp->tp_align);
field_busy = 0;
#endif NOBITFIELD #endif NOBITFIELD
} }
else { /* (stp->tp_fund == UNION) */ else { /* (stp->tp_fund == UNION) */
@ -138,9 +128,8 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
newsdef->sd_offset = offset; newsdef->sd_offset = offset;
#ifndef NOBITFIELD #ifndef NOBITFIELD
if (tp->tp_fund == FIELD) { if (tp->tp_fund == FIELD)
tp->tp_field->fd_sdef = newsdef; tp->tp_field->fd_sdef = newsdef;
}
#endif NOBITFIELD #endif NOBITFIELD
stack_idf(idf, stack_level_of(lvl)); stack_idf(idf, stack_level_of(lvl));
@ -162,9 +151,8 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
if (stp->tp_fund == UNION) { if (stp->tp_fund == UNION) {
arith sel_size = size_of_type(tp, "member"); arith sel_size = size_of_type(tp, "member");
if (*szp < sel_size) { if (*szp < sel_size)
*szp = sel_size; *szp = sel_size;
}
stp->tp_align = lcm(stp->tp_align, tp->tp_align); stp->tp_align = lcm(stp->tp_align, tp->tp_align);
} }
} }