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
def.str
domacro.c
doprnt.c
dumpidf.c
error.c
eval.c

View file

@ -12,9 +12,10 @@ SYSLIB = /user1/erikb/em/lib/libsystem.a
EMKLIB = /user1/erikb/em/lib/libemk.a
EMELIB = /user1/erikb/em/lib/libeme.a
STRLIB = /user1/erikb/em/lib/libstr.a
PRTLIB = /user1/erikb/em/lib/libprint.a
EMMESLIB = /user1/erikb/em/lib/libem_mes.a
LIBS = $(EMMESLIB) $(EMKLIB) $(STRLIB) $(SYSLIB)
ELIBS = $(EMMESLIB) $(EMELIB) $(STRLIB) $(SYSLIB)
LIBS = $(EMMESLIB) $(EMKLIB) $(PRTLIB) $(STRLIB) $(SYSLIB)
ELIBS = $(EMMESLIB) $(EMELIB) $(PRTLIB) $(STRLIB) $(SYSLIB)
LIB_INCLUDES = /user1/erikb/em/h
# 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 \
scan.o skip.o stack.o type.o ch7mon.o label.o eval.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
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 \
maxincl.h myalloc.h nobitfield.h nopp.h \
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
strsize.h target_sizes.h textsize.h use_tmp.h \
ssize.h spec_arith.h
strsize.h target_sizes.h textsize.h use_tmp.h spec_arith.h
# Other generated files, for 'make clean' only
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
@ -191,15 +191,15 @@ sim: cfiles
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
#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
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
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
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
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
@ -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
blocks.o: arith.h atw.h sizes.h spec_arith.h
dataflow.o: dataflow.h
doprnt.o: ssize.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
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 */
!File: ssize.h
#define SSIZE 1024 /* string-buffer size for print routines */
!File: spec_arith.h
/* describes internal compiler arithmetics */
#undef SPECIAL_ARITHMETICS /* something different from native long */

View file

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

View file

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

View file

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

View file

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

View file

@ -88,7 +88,7 @@ hash_stat()
if (options['h']) {
int i;
printf("Hash table tally:\n");
print("Hash table tally:\n");
for (i = 0; i < HASHSIZE; i++) {
struct idf *notch = idf_hashtable[i];
int cnt = 0;
@ -97,9 +97,9 @@ hash_stat()
cnt++;
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
@ -139,9 +139,9 @@ gen_idf()
*/
static int name_cnt;
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);
return str2idf(buff);
}

View file

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

View file

@ -210,7 +210,7 @@ unstack_world()
#ifdef DEBUG
if (options['a']) {
printf("\"%s\", %s, %s, %s\n",
print("\"%s\", %s, %s, %s\n",
idf->id_text,
(def->df_alloc == 0) ? "no alloc" :
(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;
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)) {
/* a K & R test */
if (idf->id_struct && idf->id_struct->tg_level == level
) {
warning("%s is also a struct/union tag",
idf->id_text);
}
if (idf->id_struct && idf->id_struct->tg_level == level)
warning("%s is also a struct/union tag", idf->id_text);
}
if (stp->tp_fund == STRUCT) {
#ifndef NOBITFIELD
if (fd == 0) { /* no field width specified */
#endif NOBITFIELD
offset = align(*szp, tp->tp_align);
field_busy = 0;
#ifndef NOBITFIELD
}
else {
/* 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);
}
#else NOBITFIELD
offset = align(*szp, tp->tp_align);
field_busy = 0;
#endif NOBITFIELD
}
else { /* (stp->tp_fund == UNION) */
@ -138,9 +128,8 @@ add_sel(stp, tp, idf, sdefpp, szp, fd) /* this is horrible */
newsdef->sd_offset = offset;
#ifndef NOBITFIELD
if (tp->tp_fund == FIELD) {
if (tp->tp_fund == FIELD)
tp->tp_field->fd_sdef = newsdef;
}
#endif NOBITFIELD
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) {
arith sel_size = size_of_type(tp, "member");
if (*szp < sel_size) {
if (*szp < sel_size)
*szp = sel_size;
}
stp->tp_align = lcm(stp->tp_align, tp->tp_align);
}
}