improved handling of , (comma) operator and some more Minix squeezing
This commit is contained in:
parent
788788edc0
commit
4a5a463e44
5 changed files with 48 additions and 43 deletions
|
@ -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
|
||||
|
|
|
@ -464,16 +464,8 @@ 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) {
|
||||
if ((*expp)->ex_class == Oper) {
|
||||
switch((*expp)->OP_OPER) {
|
||||
case '<':
|
||||
case '>':
|
||||
case LESSEQ:
|
||||
|
@ -483,11 +475,15 @@ is_test_op(oper)
|
|||
case '!':
|
||||
case AND:
|
||||
case OR: /* && and || also impose a test */
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
/* It is already a test */
|
||||
return;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
case ',':
|
||||
opnd2test(&((*expp)->OP_RIGHT), oper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ch3bin(expp, NOTEQUAL, intexpr((arith)0, INT));
|
||||
}
|
||||
|
||||
any2opnd(expp, oper)
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
||||
suitable_sz(sz, al)
|
||||
arith sz;
|
||||
int al;
|
||||
{
|
||||
return ((int)sz % (int)word_size == 0 && al % word_align == 0) ||
|
||||
(
|
||||
word_size % sz == 0 &&
|
||||
(al >= (int)sz || al >= word_align)
|
||||
/* Lots of Irritating Stupid Parentheses */
|
||||
);
|
||||
}
|
||||
|
||||
store_block(sz, al)
|
||||
arith sz;
|
||||
int al;
|
||||
{
|
||||
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_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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue