Make rcexpr0() route into rcexpr1(), doesn't add STRASG node yet, need to fix
authorNick Downing <downing.nick@gmail.com>
Fri, 10 Feb 2017 10:41:03 +0000 (21:41 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 10 Feb 2017 10:54:07 +0000 (21:54 +1100)
c00.c
c01.c
c04.c
c11.c
ccom.h

diff --git a/c00.c b/c00.c
index 497b1dd..1a57c8b 100644 (file)
--- a/c00.c
+++ b/c00.c
@@ -701,8 +701,24 @@ advanc:
                cs = (struct nmlist *)Tblock(sizeof(struct nmlist));
                cs->hclass = STATIC;
                cs->hoffset = cval;
+#if 1 /* one-pass version */
+ /* really should change this to use nblock and fill in nmlist above better */
+               *cp0 = (union tree *)Tblock(sizeof(struct tname));
+               (*cp0)->n.op = NAME;
+               (*cp0)->n.type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR;
+               (*cp0)->n.subsp = &nchstr;
+               (*cp0)->n.strp = (union str *)NULL;
+               (*cp0)->n.tr1 = (union tree *)cs;
+               (*cp0)->n.class = STATIC;
+               (*cp0)->n.regno = 0;
+               (*cp0)->n.offset = 0;
+               (*cp0)->n.nloc = cval;
+               cp0++;
+#else
                *cp0++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr,
                  (union str *)NULL, (union tree *)cs, TNULL);
+#endif
+ /*printf("string %p\n", cp0[-1]);*/
 
        tand:
                if(cp0>=cmst+CMSIZ) {
diff --git a/c01.c b/c01.c
index d29dca3..b2c602a 100644 (file)
--- a/c01.c
+++ b/c01.c
@@ -629,10 +629,12 @@ union tree *nblock(ds) register struct nmlist *ds; {
        union tree *tp;
        if (ds->hclass == EXTERN) {
                tp = (union tree *)Tblock(sizeof(struct xtname));
+ /*fprintf(stderr, "nblock xtname %p\n", tp);*/
                tp->x.name = ds->name;
        }
        else {
                tp = (union tree *)Tblock(sizeof(struct tname));
+ /*fprintf(stderr, "nblock tname %p\n", tp);*/
                tp->n.nloc = ds->hoffset;
        }
        tp->n.op = NAME;
diff --git a/c04.c b/c04.c
index 40d4d89..e39dbae 100644 (file)
--- a/c04.c
+++ b/c04.c
@@ -11,6 +11,7 @@
 #define _va_start(argp, arg) va_start(argp)
 #endif
 #include "c0.h"
+#include "c1.h" /* rcexpr0() one-pass version */
 
 /*
  * Reduce the degree-of-reference by one.
@@ -45,6 +46,9 @@ void cbranch0(t, lbl, cond) union tree *t; int lbl; int cond; {
  * Write out a tree0.
  */
 void rcexpr0(tp) register union tree *tp; {
+#if 1 /* one-pass version */
+       long outloc;
+#endif
        /*
         * Special optimization
         */
@@ -57,8 +61,23 @@ void rcexpr0(tp) register union tree *tp; {
                        return;
                }
        }
+#if 1 /* one-pass version */
+ /* note: we need to put STRASG crap in */
+       regpanic = 0;
+       if (setjmp(jmpbuf)) {
+               regpanic = 10;
+               fseek(/*stdout*/temp_fp[temp_fi], outloc, 0);
+       }
+       nstack = 0;
+       panicposs = 0;
+       tp = optim(tp);
+       if (regpanic==0 && panicposs)
+               outloc = ftell(/*stdout*/temp_fp[temp_fi]);
+       rcexpr1(tp, efftab, 0);
+#else
        treeout(tp, 0);
        outcode("BN", EXPR, line);
+#endif
 }
 
 void treeout(tp, isstruct) register union tree *tp; int isstruct; {
diff --git a/c11.c b/c11.c
index f6c6f61..c12c243 100644 (file)
--- a/c11.c
+++ b/c11.c
@@ -45,6 +45,7 @@ void pname(p, flag) register union tree *p; int flag; {
        register int i;
 
 loop:
+ /*fprintf(stderr, "pname %p %d\n", p, p->t.op);*/
        switch(p->t.op) {
 
        case LCON:
@@ -965,13 +966,13 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
                regpanic = 0;
                if (setjmp(jmpbuf)) {
                        regpanic = 10;
-                       fseek(stdout, outloc, 0);
+                       fseek(/*stdout*/temp_fp[temp_fi], outloc, 0);
                }
                nstack = 0;
                panicposs = 0;
                *sp = tp = optim(*sp);
                if (regpanic==0 && panicposs)
-                       outloc = ftell(stdout);
+                       outloc = ftell(/*stdout*/temp_fp[temp_fi]);
                if (op==CBRANCH)
                        cbranch1(tp, lbl, cond, 0);
                else if (op==EXPR)
diff --git a/ccom.h b/ccom.h
index 1d012ab..d4d42a1 100644 (file)
--- a/ccom.h
+++ b/ccom.h
@@ -165,7 +165,7 @@ struct swtab {
 #define        SFCON   24
 #define        LCON    25
 #define        SLCON   26
-#define        NULLOP0 29              /* pass 0 only */
+#define        NULLOP0 0/*29*/         /* pass 0 only */
 #define        NULLOP  218     /* interface version */
 
 #define        AUTOI   27              /* pass 1 only */