improved handling of , (comma) operator and some more Minix squeezing
authorceriel <none@none>
Mon, 23 Oct 1989 13:50:27 +0000 (13:50 +0000)
committerceriel <none@none>
Mon, 23 Oct 1989 13:50:27 +0000 (13:50 +0000)
lang/cem/cemcom.ansi/LLlex.c
lang/cem/cemcom.ansi/arith.c
lang/cem/cemcom.ansi/blocks.c
lang/cem/cemcom.ansi/eval.c
lang/cem/cemcom.ansi/main.c

index 1f9be7f..70b1693 100644 (file)
@@ -44,6 +44,7 @@ int LexSave = 0;              /* last character read by GetChar       */
 extern arith full_mask[];
 extern arith max_int;
 
+#ifndef        NOPP
 static struct token LexStack[MAX_LL_DEPTH];
 static LexSP = 0;
 
@@ -65,6 +66,7 @@ PopLex()
        ASSERT(LexSP > 0);
        dot = LexStack[--LexSP];
 }
+#endif /* NOPP */
 
 int
 LLlex()
@@ -144,10 +146,12 @@ firstline:
                        if (ch == '#') {
                                /* a control line follows */
                                domacro();
+#ifndef        NOPP
                                if (File_Inserted) {
                                        File_Inserted = 0;
                                        goto firstline;
                                }
+#endif /* NOPP */
                        }
                }
                        /*      We have to loop here, because in
index 01d05d3..a1648f4 100644 (file)
@@ -464,30 +464,26 @@ opnd2test(expp, oper)
        register struct expr **expp;
 {
        opnd2logical(expp, oper);
-       if ((*expp)->ex_class == Oper && is_test_op((*expp)->OP_OPER))
-               { /* It is already a test */ }
-       else
-               ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
-}
-
-int
-is_test_op(oper)
-{
-       switch (oper)   {
-       case '<':
-       case '>':
-       case LESSEQ:
-       case GREATEREQ:
-       case EQUAL:
-       case NOTEQUAL:
-       case '!':
-       case AND:
-       case OR:        /* && and || also impose a test */
-               return 1;
-       default:
-               return 0;
+       if ((*expp)->ex_class == Oper) {
+               switch((*expp)->OP_OPER) {
+               case '<':
+               case '>':
+               case LESSEQ:
+               case GREATEREQ:
+               case EQUAL:
+               case NOTEQUAL:
+               case '!':
+               case AND:
+               case OR:        /* && and || also impose a test */
+                       /* It is already a test */
+                       return;
+               }
+               case ',':
+                       opnd2test(&((*expp)->OP_RIGHT), oper);
+                       return;
+               }
        }
-       /*NOTREACHED*/
+       ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
 }
 
 any2opnd(expp, oper)
index 1684995..1ac3531 100644 (file)
@@ -50,17 +50,24 @@ extern arith NewLocal();
        we only push an object of the size accepted by EM onto the stack,
        while we need a loop to store the stack block into a memory object.
 */
-store_block(sz, al)
+
+suitable_sz(sz, al)
        arith sz;
        int al;
 {
-       if (
-               ((sz == al) && (word_align % al == 0)) ||
+       return  ((int)sz % (int)word_size == 0 && al % word_align == 0) ||
                (
-                       (sz % word_size == 0 || word_size % sz == 0) &&
-                       (al % word_align == 0)
-               )
-       )       /* Lots of Irritating Stupid Parentheses */
+                       word_size % sz == 0 &&
+                       (al >= (int)sz || al >= word_align)
+               /* Lots of Irritating Stupid Parentheses */
+               );
+}
+
+store_block(sz, al)
+       arith sz;
+       int al;
+{
+       if (suitable_sz(sz, al))
                C_sti(sz);
        else {
 #ifndef STB
@@ -98,15 +105,8 @@ load_block(sz, al)
        arith sz;
        int al;
 {
-       arith esz = ATW(sz);    /* effective size == actual # pushed bytes */
 
-       if (
-               ((sz == al) && (word_align % al == 0)) ||
-               (
-                       (sz % word_size == 0 || word_size % sz == 0) &&
-                       (al % word_align == 0)
-               )
-       )       /* Lots of Irritating Stupid Parentheses */
+       if (suitable_sz(sz, al))
                C_loi(sz);
        else {
 #ifndef STB
@@ -117,17 +117,18 @@ load_block(sz, al)
                dst = LocalPtrVar();
 
                StoreLocal(src, pointer_size);
-               C_asp(-esz);            /* allocate stack block */
+               C_asp(-ATW(sz));        /* allocate stack block */
                C_lor((arith)1);        /* push & of stack block as dst */
                StoreLocal(dst, pointer_size);
                copy_loop(sz, src, dst);
                FreeLocal(dst);
                FreeLocal(src);
 #else STB
-               C_asp(-(esz - pointer_size));   /* allocate stack block */
+               arith esz = ATW(sz) - pointer_size;
+               C_asp(-esz);            /* allocate stack block */
                C_lor((arith)1);        /* push & of stack block as dst */
                C_dup(pointer_size);            /* fetch source address */
-               C_adp(esz - pointer_size);
+               C_adp(esz);
                C_loi(pointer_size);
                C_loc(sz);                      /* # bytes to copy      */
                C_cal("__stb");                 /* library copy routine */
index 19d502d..cc4bb4f 100644 (file)
@@ -530,7 +530,7 @@ EVAL(expr, val, code, true_label, false_label)
                        break;
                case ',':
                        EVAL(left, RVAL, FALSE, NO_LABEL, NO_LABEL);
-                       EVAL(right, RVAL, gencode, NO_LABEL, NO_LABEL);
+                       EVAL(right, RVAL, gencode, true_label, false_label);
                        break;
                case '~':
                        EVAL(right, RVAL, gencode, NO_LABEL, NO_LABEL);
index e2e5907..b25f219 100644 (file)
@@ -187,8 +187,10 @@ compile(argc, argv)
        nestlow = -1;
 #ifndef NOPP
        WorkingDir = getwdir(source);
-#endif NOPP
        PushLex();                      /* initialize lex machine */
+#else NOPP
+       GetToken(&ahead);
+#endif NOPP
 
 #ifdef DEBUG
 #ifndef NOPP
@@ -219,7 +221,9 @@ compile(argc, argv)
                        dumpidftab("end of main", options['f'] ? 7 : 0);
 #endif DEBUG
        }
+#ifndef        NOPP
        PopLex();
+#endif /* NOPP */
 }
 
 init()