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