summaryrefslogtreecommitdiff
path: root/src/icont
diff options
context:
space:
mode:
Diffstat (limited to 'src/icont')
-rw-r--r--src/icont/Makefile4
-rw-r--r--src/icont/lcode.c627
-rw-r--r--src/icont/lglob.c5
-rw-r--r--src/icont/link.c17
-rw-r--r--src/icont/lmem.c16
-rw-r--r--src/icont/tcode.c29
-rw-r--r--src/icont/tglobals.h4
-rw-r--r--src/icont/tproto.h10
-rw-r--r--src/icont/tsym.c80
-rw-r--r--src/icont/tunix.c34
10 files changed, 30 insertions, 796 deletions
diff --git a/src/icont/Makefile b/src/icont/Makefile
index 8f15f9d..db0927f 100644
--- a/src/icont/Makefile
+++ b/src/icont/Makefile
@@ -22,7 +22,7 @@ icont: $(OBJS) $(COBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o icont $(OBJS) $(COBJS)
cp icont ../../bin
strip ../../bin/icont$(EXE)
- (cd ../../bin; rm -f icon; ln -s icont icon)
+ (cd ../../bin; rm -f icon icon.exe; ln -s icont icon)
$(OBJS): $(HFILES) tproto.h
@@ -45,7 +45,7 @@ tree.o: tree.h
tsym.o: tglobals.h tsym.h ttoken.h lfile.h keyword.h ../h/kdefs.h
# linker files
-$(LINKR): link.h lfile.h ../h/rt.h ../h/sys.h ../h/monitor.h \
+$(LINKR): link.h lfile.h ../h/rt.h ../h/sys.h \
../h/rstructs.h ../h/rmacros.h ../h/rexterns.h
link.o: tglobals.h hdr.h ../h/header.h
diff --git a/src/icont/lcode.c b/src/icont/lcode.c
index a1481f1..a1c7a57 100644
--- a/src/icont/lcode.c
+++ b/src/icont/lcode.c
@@ -38,15 +38,6 @@ static void outblock (char *addr,int count);
static void setfile (void);
static void wordout (word oword);
-#ifdef FieldTableCompression
- static void charout (unsigned char oint);
- static void shortout (short oint);
-#endif /* FieldTableCompression */
-
-#ifdef DeBugLinker
- static void dumpblock (char *addr,int count);
-#endif /* DeBugLinker */
-
word pc = 0; /* simulated program counter */
#define outword(n) wordout((word)(n))
@@ -243,71 +234,22 @@ void gencode()
case Op_Lab:
lab = getlab();
newline();
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "L%d:\n", lab);
- #endif /* DeBugLinker */
backpatch(lab);
break;
case Op_Line:
- /*
- * Line number change.
- * All the interesting stuff happens in Op_Colm now.
- */
lineno = getdec();
-
- #ifndef SrcColumnInfo
- /*
- * Enter the value in the line number table
- * that is stored in the icode file and used during error
- * handling and execution monitoring. One can generate a VM
- * instruction for these changes, but since the numbers are not
- * saved and restored during backtracking, it is more accurate
- * to check for line number changes in-line in the interpreter.
- * Fortunately, the in-line check is about as fast as executing
- * Op_Line instructions. All of this is complicated by the use
- * of Op_Line to generate Noop instructions when enabled by the
- * LineCodes #define.
- *
- * If SrcColumnInfo is required, this code is duplicated,
- * with changes, in the Op_Colm case below.
- */
- if (lnfree >= &lntable[nsize])
- lntable = (struct ipc_line *)trealloc(lntable,&lnfree,&nsize,
- sizeof(struct ipc_line), 1, "line number table");
- lnfree->ipc = pc;
- lnfree->line = lineno;
- lnfree++;
- #endif /* SrcColumnInfo */
-
- /*
- * Could generate an Op_Line for monitoring, but don't anymore:
- *
- * lemitn(op, (word)lineno, name);
- */
-
newline();
-
- #ifdef LineCodes
- #ifndef EventMon
- lemit(Op_Noop,"noop");
- #endif /* EventMon */
- #endif /* LineCodes */
-
break;
case Op_Colm: /* always recognize, maybe ignore */
-
colmno = getdec();
- #ifdef SrcColumnInfo
- if (lnfree >= &lntable[nsize])
- lntable = (struct ipc_line *)trealloc(lntable,&lnfree,&nsize,
- sizeof(struct ipc_line), 1, "line number table");
- lnfree->ipc = pc;
- lnfree->line = lineno + (colmno << 16);
- lnfree++;
- #endif /* SrcColumnInfo */
+ if (lnfree >= &lntable[nsize])
+ lntable = (struct ipc_line *)trealloc(lntable,&lnfree,&nsize,
+ sizeof(struct ipc_line), 1, "line number table");
+ lnfree->ipc = pc;
+ lnfree->line = lineno + (colmno << 16);
+ lnfree++;
break;
case Op_Mark:
@@ -368,10 +310,6 @@ void gencode()
implicit = gp->g_flag & F_ImpError;
nargs = gp->g_nargs;
align();
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\n# procedure %s\n", &lsspace[lsfree]);
- #endif /* DeBugLinker */
}
else {
/*
@@ -488,12 +426,6 @@ static void lemit(op, name)
int op;
char *name;
{
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\t\t\t\t# %s\n", (long)pc, op, name);
- #endif /* DeBugLinker */
-
outop(op);
}
@@ -503,11 +435,6 @@ char *name;
{
misalign();
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\tL%d\t\t\t# %s\n", (long)pc, op, lab, name);
- #endif /* DeBugLinker */
-
if (lab >= maxlabels)
labels = (word *) trealloc(labels, NULL, &maxlabels, sizeof(word),
lab - maxlabels + 1, "labels");
@@ -526,13 +453,6 @@ word n;
char *name;
{
misalign();
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\t%ld\t\t\t# %s\n", (long)pc, op, (long)n,
- name);
- #endif /* DeBugLinker */
-
outop(op);
outword(n);
}
@@ -544,20 +464,7 @@ word loc;
char *name;
{
misalign();
-
loc -= pc + ((IntBits/ByteBits) + WordSize);
-
- #ifdef DeBugLinker
- if (Dflag) {
- if (loc >= 0)
- fprintf(dbgfile, "%ld:\t%d\t*+%ld\t\t\t# %s\n",(long) pc, op,
- (long)loc, name);
- else
- fprintf(dbgfile, "%ld:\t%d\t*-%ld\t\t\t# %s\n",(long) pc, op,
- (long)-loc, name);
- }
- #endif /* DeBugLinker */
-
outop(op);
outword(loc);
}
@@ -568,13 +475,6 @@ word offset;
char *name;
{
misalign();
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\t%d,S+%ld\t\t\t# %s\n", (long)pc, op, n,
- (long)offset, name);
- #endif /* DeBugLinker */
-
outop(op);
outword(n);
outword(offset);
@@ -593,12 +493,6 @@ long i;
char *name;
{
misalign();
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile,"%ld:\t%d\t%ld\t\t\t# %s\n",(long)pc,op,(long)i,name);
- #endif /* DeBugLinker */
-
outop(op);
outword(i);
}
@@ -628,23 +522,12 @@ register int k;
x.f = lctable[k].c_val.rval;
#endif /* Double */
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile,"%ld:\t%d\t\t\t\t# real(%g)",(long)pc,T_Real, x.f);
- dumpblock(x.ovly,sizeof(double));
- }
- #endif /* DeBugLinker */
-
outword(T_Real);
#ifdef Double
#if WordBits != 64
/* fill out real block with an empty word */
outword(0);
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile,"\t0\t\t\t\t\t# padding\n");
- #endif /* DeBugLinker */
#endif /* WordBits != 64 */
#endif /* Double */
@@ -664,23 +547,9 @@ register int k;
if (Testb(i, csbuf))
j++;
}
-
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile, "%ld:\t%d\n",(long) pc, T_Cset);
- fprintf(dbgfile, "\t%d\n",j);
- }
- #endif /* DeBugLinker */
-
outword(T_Cset);
outword(j); /* cset size */
outblock((char *)csbuf,sizeof(csbuf));
-
- #ifdef DeBugLinker
- if (Dflag)
- dumpblock((char *)csbuf,CsetSize);
- #endif /* DeBugLinker */
-
}
}
@@ -699,19 +568,6 @@ int nargs, ndyn, nstat, fstat;
size = (9*WordSize) + (2*WordSize) * (abs(nargs)+ndyn+nstat);
p = &lsspace[name];
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile, "%ld:\t%d\n", (long)pc, T_Proc); /* type code */
- fprintf(dbgfile, "\t%d\n", size); /* size of block */
- fprintf(dbgfile, "\tZ+%ld\n",(long)(pc+size)); /* entry point */
- fprintf(dbgfile, "\t%d\n", nargs); /* # arguments */
- fprintf(dbgfile, "\t%d\n", ndyn); /* # dynamic locals */
- fprintf(dbgfile, "\t%d\n", nstat); /* # static locals */
- fprintf(dbgfile, "\t%d\n", fstat); /* first static */
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n", /* name of procedure */
- (int)strlen(p), (long)(name), p);
- }
- #endif /* DeBugLinker */
outword(T_Proc);
outword(size);
@@ -732,13 +588,6 @@ int nargs, ndyn, nstat, fstat;
if (lltable[i].l_flag & F_Argument) {
s_indx = lltable[i].l_name;
p = &lsspace[s_indx];
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n", (int)strlen(p),
- (long)s_indx, p);
- #endif /* DeBugLinker */
-
outword(strlen(p));
outword(s_indx);
}
@@ -751,13 +600,6 @@ int nargs, ndyn, nstat, fstat;
if (lltable[i].l_flag & F_Dynamic) {
s_indx = lltable[i].l_name;
p = &lsspace[s_indx];
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n", (int)strlen(p),
- (long)s_indx, p);
- #endif /* DeBugLinker */
-
outword(strlen(p));
outword(s_indx);
}
@@ -770,13 +612,6 @@ int nargs, ndyn, nstat, fstat;
if (lltable[i].l_flag & F_Static) {
s_indx = lltable[i].l_name;
p = &lsspace[s_indx];
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n", (int)strlen(p),
- (long)s_indx, p);
- #endif /* DeBugLinker */
-
outword(strlen(p));
outword(s_indx);
}
@@ -802,36 +637,11 @@ void gentables()
*/
align();
hdr.Records = pc;
-
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile, "\n\n# global tables\n");
- fprintf(dbgfile, "\n%ld:\t%d\t\t\t\t# record blocks\n",
- (long)pc, nrecords);
- }
- #endif /* DeBugLinker */
-
outword(nrecords);
for (gp = lgfirst; gp != NULL; gp = gp->g_next) {
if ((gp->g_flag & F_Record) && gp->g_procid > 0) {
s = &lsspace[gp->g_name];
gp->g_pc = pc;
-
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile, "%ld:\n", pc);
- fprintf(dbgfile, "\t%d\n", T_Proc);
- fprintf(dbgfile, "\t%d\n", RkBlkSize(gp));
- fprintf(dbgfile, "\t_mkrec\n");
- fprintf(dbgfile, "\t%d\n", gp->g_nargs);
- fprintf(dbgfile, "\t-2\n");
- fprintf(dbgfile, "\t%d\n", gp->g_procid);
- fprintf(dbgfile, "\t1\n");
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n", (int)strlen(s),
- (long)gp->g_name, s);
- }
- #endif /* DeBugLinker */
-
outword(T_Proc); /* type code */
outword(RkBlkSize(gp));
outword(0); /* entry point (filled in by interp)*/
@@ -860,12 +670,6 @@ void gentables()
fflush(stderr);
exit(1);
}
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t%d\tS+%ld\t\t\t# %s\n",
- (int)strlen(&lsspace[fp->f_name]),
- fp->f_name, &lsspace[fp->f_name]);
- #endif /* DeBugLinker */
outword(strlen(&lsspace[fp->f_name]));
outword(fp->f_name);
foundit++;
@@ -885,265 +689,25 @@ void gentables()
}
}
- #ifndef FieldTableCompression
-
/*
* Output record/field table (not compressed).
*/
hdr.Ftab = pc;
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile,"\n%ld:\t\t\t\t\t# record/field table\n",(long)pc);
- #endif /* DeBugLinker */
-
for (fp = lffirst; fp != NULL; fp = fp->f_nextentry) {
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t\t\t\t\t# %s\n", (long)pc,
- &lsspace[fp->f_name]);
- #endif /* DeBugLinker */
rp = fp->f_rlist;
for (i = 1; i <= nrecords; i++) {
while (rp != NULL && rp->r_gp->g_procid < 0)
rp = rp->r_link; /* skip unreferenced constructor */
if (rp != NULL && rp->r_gp->g_procid == i) {
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t%d\n", rp->r_fnum);
- #endif /* DeBugLinker */
outop(rp->r_fnum);
rp = rp->r_link;
}
else {
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "\t-1\n");
- #endif /* DeBugLinker */
outop(-1);
}
- #ifdef DeBugLinker
- if (Dflag && (i == nrecords || (i & 03) == 0))
- putc('\n', dbgfile);
- #endif /* DeBugLinker */
}
}
- #else /* FieldTableCompression */
-
- /*
- * Output record/field table (compressed).
- * This code has not been tested recently.
- */
- {
- int counter = 0, f_num, first, begin, end, entries;
- int *f_fo, *f_row, *f_tabp;
- char *f_bm;
- int pointer, first_avail = 0, inserted, bytes;
- hdr.Fo = pc;
-
- /*
- * Compute the field width required for this binary;
- * it is determined by the maximum # of fields in any one record.
- */
- long ct = 0;
- for (gp = lgfirst; gp != NULL; gp = gp->g_next)
- if ((gp->g_flag & F_Record) && gp->g_procid > 0)
- if (gp->g_nargs > ct) ct=gp->g_nargs;
- if (ct > 65535L) hdr.FtabWidth = 4;
- else if (ct > 254) hdr.FtabWidth = 2; /* 255 is (not present) */
- else hdr.FtabWidth = 1;
-
- /* Find out how many field names there are. */
- hdr.Nfields = 0;
- for (fp = lffirst; fp != NULL; fp = fp->f_nextentry)
- hdr.Nfields++;
-
- entries = hdr.Nfields * nrecords / 4 + 1;
- f_tabp = malloc (entries * sizeof (int));
- for (i = 0; i < entries; i++)
- f_tabp[i] = -1;
- f_fo = malloc (hdr.Nfields * sizeof (int));
-
- bytes = nrecords / 8;
- if (nrecords % 8 != 0)
- bytes++;
- f_bm = calloc (hdr.Nfields, bytes);
- f_row = malloc (nrecords * sizeof (int));
- f_num = 0;
-
- for (fp = lffirst; fp != NULL; fp = fp->f_nextentry) {
- rp = fp->f_rlist;
- first = 1;
- for (i = 0; i < nrecords; i++) {
- while (rp != NULL && rp->r_gp->g_procid < 0)
- rp = rp->r_link; /* skip unreferenced constructor */
- if (rp != NULL && rp->r_gp->g_procid == i + 1) {
- if (first) {
- first = 0;
- begin = end = i;
- }
- else
- end = i;
- f_row[i] = rp->r_fnum;
- rp = rp->r_link;
- }
- else {
- f_row[i] = -1;
- }
- }
-
- inserted = 0;
- pointer = first_avail;
- while (!inserted) {
- inserted = 1;
- for (i = begin; i <= end; i++) {
- if (pointer + (end - begin) >= entries) {
- int j;
- int old_entries = entries;
- entries *= 2;
- f_tabp = realloc (f_tabp, entries * sizeof (int));
- for (j = old_entries; j < entries; j++)
- f_tabp[j] = -1;
- }
- if (f_row[i] != -1)
- if (f_tabp[pointer + (i - begin)] != -1) {
- inserted = 0;
- break;
- }
- }
- pointer++;
- }
- pointer--;
-
- /* Create bitmap */
- for (i = 0; i < nrecords; i++) {
- int index = f_num * bytes + i / 8;
- /* Picks out byte within bitmap row */
- if (f_row[i] != -1) {
- f_bm[index] |= 01;
- }
- if (i % 8 != 7)
- f_bm [index] <<= 1;
- }
-
- if (nrecords%8)
- f_bm[(f_num + 1) * bytes - 1] <<= 7 - (nrecords % 8);
-
- f_fo[f_num++] = pointer - begin;
- /* So that f_fo[] points to the first bit */
-
- for (i = begin; i <= end; i++)
- if (f_row[i] != -1)
- f_tabp[pointer + (i - begin)] = f_row[i];
- if (pointer + (end - begin) >= counter)
- counter = pointer + (end - begin + 1);
- while ((f_tabp[first_avail] != -1) && (first_avail <= counter))
- first_avail++;
- }
-
- /* Write out the arrays. */
- #ifdef DeBugLinker
- if (Dflag)
- fprintf (dbgfile, "\n%ld:\t\t\t\t\t# field offset array\n",
- (long)pc);
- #endif /* DeBugLinker */
-
- /*
- * Compute largest value stored in fo array
- */
- {
- word maxfo = 0;
- for (i = 0; i < hdr.Nfields; i++) {
- if (f_fo[i] > maxfo) maxfo = f_fo[i];
- }
- if (maxfo < 254)
- hdr.FoffWidth = 1;
- else if (maxfo < 65535L)
- hdr.FoffWidth = 2;
- else
- hdr.FoffWidth = 4;
- }
-
- for (i = 0; i < hdr.Nfields; i++) {
- #ifdef DeBugLinker
- if (Dflag)
- fprintf (dbgfile, "\t%d\n", f_fo[i]);
- #endif /* DeBugLinker */
- if (hdr.FoffWidth == 1) {
- outchar(f_fo[i]);
- }
- else if (hdr.FoffWidth == 2)
- outshort(f_fo[i]);
- else
- outop (f_fo[i]);
- }
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf (dbgfile, "\n%ld:\t\t\t\t\t# Bit maps array\n",
- (long)pc);
- #endif /* DeBugLinker */
-
- for (i = 0; i < hdr.Nfields; i++) {
- #ifdef DeBugLinker
- if (Dflag) {
- int ct, index = i * bytes;
- unsigned char this_bit = 0200;
-
- fprintf (dbgfile, "\t");
- for (ct = 0; ct < nrecords; ct++) {
- if ((f_bm[index] | this_bit) == f_bm[index])
- fprintf (dbgfile, "1");
- else
- fprintf (dbgfile, "0");
-
- if (ct % 8 == 7) {
- fprintf (dbgfile, " ");
- index++;
- this_bit = 0200;
- }
- else
- this_bit >>= 1;
- }
- fprintf (dbgfile, "\n");
- }
- #endif /* DeBugLinker */
- for (pointer = i * bytes; pointer < (i + 1) * bytes; pointer++) {
- outchar (f_bm[pointer]);
- }
- }
-
- align();
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf (dbgfile, "\n%ld:\t\t\t\t\t# record/field array\n",
- (long)pc);
- #endif /* DeBugLinker */
-
- hdr.Ftab = pc;
- for (i = 0; i < counter; i++) {
- #ifdef DeBugLinker
- if (Dflag)
- fprintf (dbgfile, "\t%d\t%d\n", i, f_tabp[i]);
- #endif /* DeBugLinker */
- if (hdr.FtabWidth == 1)
- outchar(f_tabp[i]);
- else if (hdr.FtabWidth == 2)
- outshort(f_tabp[i]);
- else
- outop (f_tabp[i]);
- }
-
- /* Free memory allocated by Jigsaw. */
- free (f_fo);
- free (f_bm);
- free (f_tabp);
- free (f_row);
- }
-
- #endif /* FieldTableCompression */
-
/*
* Output descriptors for field names.
*/
@@ -1151,13 +715,6 @@ void gentables()
hdr.Fnames = pc;
for (fp = lffirst; fp != NULL; fp = fp->f_nextentry) {
s = &lsspace[fp->f_name];
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\tS+%ld\t\t\t# %s\n",
- (long)pc, (int)strlen(s), (long)fp->f_name, s);
- #endif /* DeBugLinker */
-
outword(strlen(s)); /* name of field: length & offset */
outword(fp->f_name);
}
@@ -1168,38 +725,18 @@ void gentables()
hdr.Globals = pc;
for (gp = lgfirst; gp != NULL; gp = gp->g_next) {
if (gp->g_flag & F_Builtin) { /* function */
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%06lo\t%d\t\t\t# %s\n",
- (long)pc, (long)D_Proc, -gp->g_procid, &lsspace[gp->g_name]);
- #endif /* DeBugLinker */
outword(D_Proc);
outword(-gp->g_procid);
}
else if (gp->g_flag & F_Proc) { /* Icon procedure */
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%06lo\tZ+%ld\t\t\t# %s\n",
- (long)pc,(long)D_Proc, (long)gp->g_pc, &lsspace[gp->g_name]);
- #endif /* DeBugLinker */
outword(D_Proc);
outword(gp->g_pc);
}
else if (gp->g_flag & F_Record) { /* record constructor */
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%06lo\tZ+%ld\t\t\t# %s\n", (long) pc,
- (long)D_Proc, (long)gp->g_pc, &lsspace[gp->g_name]);
- #endif /* DeBugLinker */
outword(D_Proc);
outword(gp->g_pc);
}
else { /* simple global variable */
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%06lo\t0\t\t\t# %s\n",(long)pc,
- (long)D_Null, &lsspace[gp->g_name]);
- #endif /* DeBugLinker */
outword(D_Null);
outword(0);
}
@@ -1210,14 +747,6 @@ void gentables()
*/
hdr.Gnames = pc;
for (gp = lgfirst; gp != NULL; gp = gp->g_next) {
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t%d\tS+%ld\t\t\t# %s\n",
- (long)pc, (int)strlen(&lsspace[gp->g_name]), (long)(gp->g_name),
- &lsspace[gp->g_name]);
- #endif /* DeBugLinker */
-
outword(strlen(&lsspace[gp->g_name]));
outword(gp->g_name);
}
@@ -1227,12 +756,6 @@ void gentables()
*/
hdr.Statics = pc;
for (i = lstatics; i > 0; i--) {
-
- #ifdef DeBugLinker
- if (Dflag)
- fprintf(dbgfile, "%ld:\t0\t0\n", (long)pc);
- #endif /* DeBugLinker */
-
outword(D_Null);
outword(0);
}
@@ -1249,20 +772,6 @@ void gentables()
outfile) < 0)
quit("cannot write icode file");
- #ifdef DeBugLinker
- if (Dflag) {
- int k = 0;
- struct ipc_fname *ptr;
- for (ptr = fnmtbl; ptr < fnmfree; ptr++) {
- fprintf(dbgfile, "%ld:\t%03d\tS+%03d\t\t\t# %s\n",
- (long)(pc + k), ptr->ipc, ptr->fname, &lsspace[ptr->fname]);
- k = k + 8;
- }
- putc('\n', dbgfile);
- }
-
- #endif /* DeBugLinker */
-
pc += (char *)fnmfree - (char *)fnmtbl;
hdr.linenums = pc;
@@ -1270,47 +779,8 @@ void gentables()
outfile) < 0)
quit("cannot write icode file");
- #ifdef DeBugLinker
- if (Dflag) {
- int k = 0;
- struct ipc_line *ptr;
- for (ptr = lntable; ptr < lnfree; ptr++) {
- fprintf(dbgfile, "%ld:\t%03d\t%03d\n", (long)(pc + k),
- ptr->ipc, ptr->line);
- k = k + 8;
- }
- putc('\n', dbgfile);
- }
-
- #endif /* DeBugLinker */
-
pc += (char *)lnfree - (char *)lntable;
-
hdr.Strcons = pc;
- #ifdef DeBugLinker
- if (Dflag) {
- int c, j, k;
- j = k = 0;
- for (s = lsspace; s < &lsspace[lsfree]; ) {
- fprintf(dbgfile, "%ld:\t%03o", (long)(pc + k), *s++ & 0377);
- k = k + 8;
- for (i = 7; i > 0; i--) {
- if (s >= &lsspace[lsfree])
- fprintf(dbgfile," ");
- else
- fprintf(dbgfile, " %03o", *s++ & 0377);
- }
- fprintf(dbgfile, " ");
- for (i = 0; i < 8; i++)
- if (j < lsfree) {
- c = lsspace[j++];
- putc(isprint(c & 0377) ? c : ' ', dbgfile);
- }
- putc('\n', dbgfile);
- }
- }
-
- #endif /* DeBugLinker */
if (longwrite(lsspace, (long)lsfree, outfile) < 0)
quit("cannot write icode file");
@@ -1324,25 +794,6 @@ void gentables()
strcpy((char *)hdr.config,IVersion);
hdr.trace = trace;
-
- #ifdef DeBugLinker
- if (Dflag) {
- fprintf(dbgfile, "\n");
- fprintf(dbgfile, "size: %ld\n", (long)hdr.hsize);
- fprintf(dbgfile, "trace: %ld\n", (long)hdr.trace);
- fprintf(dbgfile, "records: %ld\n", (long)hdr.Records);
- fprintf(dbgfile, "ftab: %ld\n", (long)hdr.Ftab);
- fprintf(dbgfile, "fnames: %ld\n", (long)hdr.Fnames);
- fprintf(dbgfile, "globals: %ld\n", (long)hdr.Globals);
- fprintf(dbgfile, "gnames: %ld\n", (long)hdr.Gnames);
- fprintf(dbgfile, "statics: %ld\n", (long)hdr.Statics);
- fprintf(dbgfile, "strcons: %ld\n", (long)hdr.Strcons);
- fprintf(dbgfile, "filenms: %ld\n", (long)hdr.Filenms);
- fprintf(dbgfile, "linenums: %ld\n", (long)hdr.linenums);
- fprintf(dbgfile, "config: %s\n", hdr.config);
- }
- #endif /* DeBugLinker */
-
fseek(outfile, hdrsize, 0);
if (longwrite((char *)&hdr, (long)sizeof(hdr), outfile) < 0)
quit("cannot write icode file");
@@ -1407,40 +858,6 @@ int oint;
codep += IntBits/ByteBits;
pc += IntBits/ByteBits;
}
-
-#ifdef FieldTableCompression
-/*
- * charout(i) outputs i as an unsigned char that is used by the runtime system
- */
-static void charout(unsigned char ochar)
- {
- CodeCheck(1);
- *codep++ = (unsigned char)ochar;
- pc++;
- }
-/*
- * shortout(i) outputs i as a short that is used by the runtime system
- * IntBits/ByteBits bytes must be moved from &word[0] to &codep[0].
- */
-static void shortout(short oint)
- {
- int i;
- union {
- short i;
- char c[2];
- } u;
-
- CodeCheck(2);
- u.i = oint;
-
- for (i = 0; i < 2; i++)
- codep[i] = u.c[i];
-
- codep += 2;
- pc += 2;
- }
-#endif /* FieldTableCompression */
-
/*
* wordout(i) outputs i as a word that is used by the runtime system
@@ -1478,25 +895,6 @@ int count;
*codep++ = *addr++;
}
-#ifdef DeBugLinker
- /*
- * dumpblock(a,i) dump contents of i bytes at address a, used only
- * in conjunction with -L.
- */
- static void dumpblock(addr, count)
- char *addr;
- int count;
- {
- int i;
- for (i = 0; i < count; i++) {
- if ((i & 7) == 0)
- fprintf(dbgfile,"\n\t");
- fprintf(dbgfile," %03o",(0377 & (unsigned)addr[i]));
- }
- putc('\n',dbgfile);
- }
- #endif /* DeBugLinker */
-
/*
* flushcode - write buffered code to the output file.
*/
@@ -1549,16 +947,3 @@ int lab;
}
labels[lab] = pc;
}
-
-#ifdef DeBugLinker
- void idump(s) /* dump code region */
- char *s;
- {
- int *c;
-
- fprintf(stderr,"\ndump of code region %s:\n",s);
- for (c = (int *)codeb; c < (int *)codep; c++)
- fprintf(stderr,"%ld: %d\n",(long)c, (int)*c);
- fflush(stderr);
- }
- #endif /* DeBugLinker */
diff --git a/src/icont/lglob.c b/src/icont/lglob.c
index 6583b8a..281b8d5 100644
--- a/src/icont/lglob.c
+++ b/src/icont/lglob.c
@@ -25,7 +25,7 @@ void readglob()
{
register word id;
register int n, op;
- int k;
+ int i, k;
int implicit;
char *name;
struct gentry *gp;
@@ -111,7 +111,8 @@ void readglob()
break;
case Op_Link: /* link the named file */
- name = &lsspace[getrest()]; /* get the name and */
+ i = getrest(); /* get name offset -- can move lsspace */
+ name = &lsspace[i]; /* get pointer to name string */
alsolink(name); /* put it on the list of files to link */
newline();
break;
diff --git a/src/icont/link.c b/src/icont/link.c
index 362b257..c68ffae 100644
--- a/src/icont/link.c
+++ b/src/icont/link.c
@@ -19,11 +19,6 @@ static void setexe (char *fname);
FILE *infile; /* input file (.u1 or .u2) */
FILE *outfile; /* interpreter code output file */
-#ifdef DeBugLinker
- FILE *dbgfile; /* debug file */
- static char dbgname[MaxPath]; /* debug file name */
-#endif /* DeBugLinker */
-
struct lfile *llfiles = NULL; /* List of files to link */
char inname[MaxPath]; /* input file name */
@@ -140,18 +135,6 @@ char *outname;
if (ferror(outfile) != 0)
quit("unable to write to icode file");
- #ifdef DeBugLinker
- /*
- * Open the .ux file if debugging is on.
- */
- if (Dflag) {
- makename(dbgname, TargetDir, llfiles->lf_name, ".ux");
- dbgfile = fopen(dbgname, "w");
- if (dbgfile == NULL)
- quitf("cannot create %s", dbgname);
- }
- #endif /* DeBugLinker */
-
/*
* Loop through input files and generate code for each.
*/
diff --git a/src/icont/lmem.c b/src/icont/lmem.c
index 8e091a5..034c4c8 100644
--- a/src/icont/lmem.c
+++ b/src/icont/lmem.c
@@ -96,22 +96,6 @@ void linit()
putglobal(instid("main"), F_Global, 0, 0);
}
-#ifdef DeBugLinker
- /*
- * dumplfiles - print the list of files to link. Used for debugging only.
- */
- void dumplfiles()
- {
- struct lfile *p,*lfls;
-
- fprintf(stderr,"lfiles:\n");
- lfls = llfiles;
- while (p = getlfile(&lfls))
- fprintf(stderr,"'%s'\n",p->lf_name);
- fflush(stderr);
- }
-#endif /* DeBugLinker */
-
/*
* alsolink - create an lfile structure for the named file and add it to the
* end of the list of files (llfiles) to generate link instructions for.
diff --git a/src/icont/tcode.c b/src/icont/tcode.c
index 9a9787c..44839b6 100644
--- a/src/icont/tcode.c
+++ b/src/icont/tcode.c
@@ -118,9 +118,6 @@ register nodeptr t;
loopsp->markcount++;
traverse(Tree0(t)); /* evaluate first alternative */
loopsp->markcount--;
- #ifdef EventMon
- setloc(t);
- #endif /* EventMon */
emit("esusp"); /* and suspend with its result */
emitl("goto", lab+1);
emitlab(lab);
@@ -1020,24 +1017,14 @@ nodeptr n;
static void emitline(n)
nodeptr n;
{
- #ifdef SrcColumnInfo
- /*
- * if either line or column has changed, emit location information
- */
- if (((Col(n) << 16) + Line(n)) != lastlin) {
- lastlin = (Col(n) << 16) + Line(n);
- emitn("line",Line(n));
- emitn("colm",Col(n));
- }
- #else /* SrcColumnInfo */
- /*
- * if line has changed, emit line information
- */
- if (Line(n) != lastlin) {
- lastlin = Line(n);
- emitn("line", lastlin);
- }
- #endif /* SrcColumnInfo */
+ /*
+ * if either line or column has changed, emit location information
+ */
+ if (((Col(n) << 16) + Line(n)) != lastlin) {
+ lastlin = (Col(n) << 16) + Line(n);
+ emitn("line",Line(n));
+ emitn("colm",Col(n));
+ }
}
/*
diff --git a/src/icont/tglobals.h b/src/icont/tglobals.h
index 5568293..5a45ea6 100644
--- a/src/icont/tglobals.h
+++ b/src/icont/tglobals.h
@@ -48,10 +48,6 @@ Global int pponly Init(0); /* -E: preprocess only */
Global int strinv Init(0); /* -f s: allow full string invocation */
Global int verbose Init(1); /* -v n: verbosity of commentary */
-#ifdef DeBugLinker
- Global int Dflag Init(0); /* -L: linker debug (write .ux file) */
-#endif /* DeBugLinker */
-
/*
* Files and related globals.
*/
diff --git a/src/icont/tproto.h b/src/icont/tproto.h
index aaea6c4..e88d426 100644
--- a/src/icont/tproto.h
+++ b/src/icont/tproto.h
@@ -94,13 +94,3 @@ void writecheck (int rc);
void yyerror (int tok,struct node *lval,int state);
int yylex (void);
int yyparse (void);
-
-#ifdef DeBugTrans
- void cdump (void);
- void gdump (void);
- void ldump (void);
-#endif /* DeBugTrans */
-
-#ifdef DeBugLinker
- void idump (char *c);
-#endif /* DeBugLinker */
diff --git a/src/icont/tsym.c b/src/icont/tsym.c
index 1d0f16c..6f9b2a3 100644
--- a/src/icont/tsym.c
+++ b/src/icont/tsym.c
@@ -25,13 +25,6 @@ static struct tgentry *glookup (char *id);
static struct tlentry *llookup (char *id);
static void putglob
(char *id,int id_type, int n_args);
-
-#ifdef DeBugTrans
- void cdump (void);
- void gdump (void);
- void ldump (void);
-#endif /* DeBugTrans */
-
/*
* Keyword table.
@@ -257,79 +250,6 @@ register char *id;
return 0;
}
-#ifdef DeBugTrans
-/*
- * ldump displays local symbol table to stdout.
- */
-
-void ldump()
- {
- register int i;
- register struct tlentry *lptr;
- int n;
-
- if (llast == NULL)
- n = 0;
- else
- n = llast->l_index + 1;
- fprintf(stderr,"Dump of local symbol table (%d entries)\n", n);
- fprintf(stderr," loc blink id (name) flags\n");
- for (i = 0; i < lhsize; i++)
- for (lptr = lhash[i]; lptr != NULL; lptr = lptr->l_blink)
- fprintf(stderr,"%5d %5d %5d %20s %7o\n", lptr->l_index,
- lptr->l_blink, lptr->l_name, lptr->l_name, lptr->l_flag);
- fflush(stderr);
-
- }
-
-/*
- * gdump displays global symbol table to stdout.
- */
-
-void gdump()
- {
- register int i;
- register struct tgentry *gptr;
- int n;
-
- if (glast == NULL)
- n = 0;
- else
- n = glast->g_index + 1;
- fprintf(stderr,"Dump of global symbol table (%d entries)\n", n);
- fprintf(stderr," loc blink id (name) flags nargs\n");
- for (i = 0; i < ghsize; i++)
- for (gptr = ghash[i]; gptr != NULL; gptr = gptr->g_blink)
- fprintf(stderr,"%5d %5d %5d %20s %7o %8d\n", gptr->g_index,
- gptr->g_blink, gptr->g_name, gptr->g_name,
- gptr->g_flag, gptr->g_nargs);
- fflush(stderr);
- }
-
-/*
- * cdump displays constant symbol table to stdout.
- */
-
-void cdump()
- {
- register int i;
- register struct tcentry *cptr;
- int n;
-
- if (clast == NULL)
- n = 0;
- else
- n = clast->c_index + 1;
- fprintf(stderr,"Dump of constant symbol table (%d entries)\n", n);
- fprintf(stderr," loc blink id (name) flags\n");
- for (i = 0; i < lchsize; i++)
- for (cptr = chash[i]; cptr != NULL; cptr = cptr->c_blink)
- fprintf(stderr,"%5d %5d %5d %20s %7o\n", cptr->c_index,
- cptr->c_blink, cptr->c_name, cptr->c_name, cptr->c_flag);
- fflush(stderr);
- }
-#endif /* DeBugTrans */
-
/*
* alcloc allocates a local symbol table entry, fills in fields with
* specified values and returns the new entry.
diff --git a/src/icont/tunix.c b/src/icont/tunix.c
index 9478403..e0388c1 100644
--- a/src/icont/tunix.c
+++ b/src/icont/tunix.c
@@ -103,20 +103,14 @@ int main(int argc, char *argv[]) {
iconxloc = "";
break;
case 'V': /* -V: print version information */
- fprintf(stderr, "%s (%s, %s)\n", Version, Config, __DATE__);
+ fprintf(stderr, "%s (%s %d/%d, %s)\n",
+ Version, Config, IntBits, WordBits, __DATE__);
if (optind == argc)
exit(0);
break;
case 'X': /* -X srcfile: execute single srcfile */
txrun(copyfile, optarg, &argv[optind]);
break; /*NOTREACHED*/
-
- #ifdef DeBugLinker
- case 'L': /* -L: enable linker debugging */
- Dflag = 1;
- break;
- #endif /* DeBugLinker */
-
default:
case 'x': /* -x illegal until after file list */
usage();
@@ -249,8 +243,10 @@ static void execute(char *ofile, char *efile, char *args[]) {
*/
if (efile != NULL) {
close(fileno(stderr));
- if (strcmp(efile, "-") == 0)
- dup(fileno(stdout));
+ if (strcmp(efile, "-") == 0) {
+ if (dup(fileno(stdout)) < 0)
+ quit("could not merge standard output with standard error\n");
+ }
else if (freopen(efile, "w", stderr) == NULL)
quitf("could not redirect stderr to %s\n", efile);
}
@@ -293,11 +289,7 @@ static char *libpath(char *prog, char *envname) {
s = getenv(envname);
if (s != NULL)
- #if CYGWIN
- cygwin_win32_to_posix_path_list(s, buf);
- #else /* CYGWIN */
- strcpy(buf, s);
- #endif /* CYGWIN */
+ strcpy(buf, s);
else
strcpy(buf, ".");
strcat(buf, ":");
@@ -323,21 +315,15 @@ static void txrun(char *(*func)(FILE*, char*), char *source, char *args[]) {
omask = umask(0077); /* remember umask; keep /tmp files private */
/*
- * Invent a file named /tmp/innnnnxx.icn.
+ * Create a temporary file named /tmp/innnnnxx.icn.
*/
srand(time(NULL));
c1 = abet[rand() % (sizeof(abet) - 1)];
c2 = abet[rand() % (sizeof(abet) - 1)];
sprintf(srcfile, "/tmp/i%d%c%c.icn", getpid(), c1, c2);
-
- /*
- * Copy the source code to the temporary file.
- */
f = fopen(srcfile, "w");
if (f == NULL)
quitf("cannot open for writing: %s", srcfile);
- progname = func(f, source);
- fclose(f);
/*
* Derive other names and arrange for cleanup on exit.
@@ -351,8 +337,10 @@ static void txrun(char *(*func)(FILE*, char*), char *source, char *args[]) {
atexit(cleanup);
/*
- * Translate to produce .u1 and .u2 files.
+ * Copy the source file, then translate to produce .u1 and .u2 files.
*/
+ progname = func(f, source);
+ fclose(f);
flist[0] = srcfile;
flist[1] = NULL;
if (trans(flist, SourceDir) > 0)