From 4a5a463e44f621e8ca7ff0cb83ffbc66f44e9232 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 23 Oct 1989 13:50:27 +0000 Subject: [PATCH] improved handling of , (comma) operator and some more Minix squeezing --- lang/cem/cemcom.ansi/LLlex.c | 4 ++++ lang/cem/cemcom.ansi/arith.c | 42 ++++++++++++++++------------------- lang/cem/cemcom.ansi/blocks.c | 37 +++++++++++++++--------------- lang/cem/cemcom.ansi/eval.c | 2 +- lang/cem/cemcom.ansi/main.c | 6 ++++- 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index 1f9be7f5d..70b169340 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -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 diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 01d05d317..a1648f4da 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -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) diff --git a/lang/cem/cemcom.ansi/blocks.c b/lang/cem/cemcom.ansi/blocks.c index 1684995d4..1ac3531ad 100644 --- a/lang/cem/cemcom.ansi/blocks.c +++ b/lang/cem/cemcom.ansi/blocks.c @@ -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 */ diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 19d502d1a..cc4bb4fa8 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -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); diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index e2e59077d..b25f2197b 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -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() -- 2.34.1