in SkipToNewLine(), check for TOKSEP; fixed problem with volatile
This commit is contained in:
parent
3ddb8e24b7
commit
0267340564
2 changed files with 57 additions and 74 deletions
|
@ -38,6 +38,7 @@ char *symbol2str();
|
||||||
char *long2str();
|
char *long2str();
|
||||||
arith NewLocal(); /* util.c */
|
arith NewLocal(); /* util.c */
|
||||||
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
|
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
|
||||||
|
extern int err_occurred; /* error.c */
|
||||||
|
|
||||||
/* EVAL() is the main expression-tree evaluator, which turns
|
/* EVAL() is the main expression-tree evaluator, which turns
|
||||||
any legal expression tree into EM code. Parameters:
|
any legal expression tree into EM code. Parameters:
|
||||||
|
@ -71,11 +72,9 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
label true_label, false_label;
|
label true_label, false_label;
|
||||||
{
|
{
|
||||||
int vol = (code != TRUE && recurqual(expr->ex_type, TQ_VOLATILE));
|
int vol = (code != TRUE && recurqual(expr->ex_type, TQ_VOLATILE));
|
||||||
register int gencode = ((code == TRUE
|
register int gencode = code == TRUE;
|
||||||
&& (expr->ex_type->tp_size > 0
|
|
||||||
|| expr->ex_type->tp_fund == FUNCTION))
|
|
||||||
|| vol);
|
|
||||||
|
|
||||||
|
if (err_occurred) return;
|
||||||
switch (expr->ex_class) {
|
switch (expr->ex_class) {
|
||||||
case Value: /* just a simple value */
|
case Value: /* just a simple value */
|
||||||
if (gencode) {
|
if (gencode) {
|
||||||
|
@ -88,6 +87,10 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
}
|
}
|
||||||
else load_val(expr, val);
|
else load_val(expr, val);
|
||||||
}
|
}
|
||||||
|
else if (vol) {
|
||||||
|
load_val(expr, val);
|
||||||
|
C_asp(ATW(expr->ex_type->tp_size));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case String: /* a string constant */
|
case String: /* a string constant */
|
||||||
if (gencode) {
|
if (gencode) {
|
||||||
|
@ -117,13 +120,6 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
register struct expr *right = expr->OP_RIGHT;
|
register struct expr *right = expr->OP_RIGHT;
|
||||||
register struct type *tp = expr->OP_TYPE;
|
register struct type *tp = expr->OP_TYPE;
|
||||||
|
|
||||||
if (tp->tp_fund == ERRONEOUS || (expr->ex_flags & EX_ERROR)) {
|
|
||||||
/* stop immediately */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tp->tp_fund == VOID)
|
|
||||||
gencode = 0;
|
|
||||||
|
|
||||||
switch (oper) {
|
switch (oper) {
|
||||||
case '+':
|
case '+':
|
||||||
/* We have the following possibilities :
|
/* We have the following possibilities :
|
||||||
|
@ -353,20 +349,19 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '=': {
|
case '=':
|
||||||
int newcode = tp->tp_size > 0; /* CJ */
|
|
||||||
#ifndef NOBITFIELD
|
#ifndef NOBITFIELD
|
||||||
if (left->ex_type->tp_fund == FIELD) {
|
if (left->ex_type->tp_fund == FIELD) {
|
||||||
eval_field(expr, gencode);
|
eval_field(expr, gencode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif NOBITFIELD
|
#endif NOBITFIELD
|
||||||
EVAL(right, RVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(right, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
if (gencode && val == RVAL)
|
if (gencode && val == RVAL)
|
||||||
C_dup(ATW(tp->tp_size));
|
C_dup(ATW(tp->tp_size));
|
||||||
if (left->ex_class != Value) {
|
if (left->ex_class != Value) {
|
||||||
EVAL(left, LVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
if (newcode && gencode && val == LVAL) {
|
if (gencode && val == LVAL) {
|
||||||
arith tmp = LocalPtrVar();
|
arith tmp = LocalPtrVar();
|
||||||
C_dup(pointer_size);
|
C_dup(pointer_size);
|
||||||
StoreLocal(tmp, pointer_size);
|
StoreLocal(tmp, pointer_size);
|
||||||
|
@ -374,16 +369,14 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
LoadLocal(tmp, pointer_size);
|
LoadLocal(tmp, pointer_size);
|
||||||
FreeLocal(tmp);
|
FreeLocal(tmp);
|
||||||
}
|
}
|
||||||
else if (newcode)
|
else store_block(tp->tp_size, tp->tp_align);
|
||||||
store_block(tp->tp_size, tp->tp_align);
|
|
||||||
}
|
}
|
||||||
else if (newcode) {
|
else {
|
||||||
store_val(&(left->EX_VALUE), left->ex_type);
|
store_val(&(left->EX_VALUE), left->ex_type);
|
||||||
if (gencode && val == LVAL) {
|
if (gencode && val == LVAL) {
|
||||||
EVAL(left, LVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PLUSAB:
|
case PLUSAB:
|
||||||
case MINAB:
|
case MINAB:
|
||||||
|
@ -402,15 +395,15 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
{
|
{
|
||||||
arith tmp = 0;
|
arith tmp = 0;
|
||||||
int compl; /* Complexity of left operand */
|
int compl; /* Complexity of left operand */
|
||||||
int newcode = left->ex_type->tp_size > 0; /* CJ */
|
|
||||||
int right_done = 0;
|
int right_done = 0;
|
||||||
|
int dupval;
|
||||||
#ifndef NOBITFIELD
|
#ifndef NOBITFIELD
|
||||||
if (left->ex_type->tp_fund == FIELD) {
|
if (left->ex_type->tp_fund == FIELD) {
|
||||||
eval_field(expr, gencode);
|
eval_field(expr, gencode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif NOBITFIELD
|
#endif NOBITFIELD
|
||||||
if (newcode && left->ex_class == Value) {
|
if (left->ex_class == Value) {
|
||||||
compl = 0; /* Value */
|
compl = 0; /* Value */
|
||||||
}
|
}
|
||||||
else if (left->ex_depth == 1 &&
|
else if (left->ex_depth == 1 &&
|
||||||
|
@ -428,61 +421,54 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
(oper == PLUSAB || oper == TIMESAB ||
|
(oper == PLUSAB || oper == TIMESAB ||
|
||||||
oper == ANDAB || oper == XORAB || oper == ORAB)) {
|
oper == ANDAB || oper == XORAB || oper == ORAB)) {
|
||||||
right_done = 1;
|
right_done = 1;
|
||||||
EVAL(right, RVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(right, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
}
|
}
|
||||||
if (compl == 0) {
|
if (compl == 0) {
|
||||||
load_val(left, RVAL);
|
load_val(left, RVAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (compl == 1) {
|
if (compl == 1) {
|
||||||
EVAL(left, RVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(left, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EVAL(left, LVAL, newcode, NO_LABEL, NO_LABEL);
|
EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
if (newcode) {
|
tmp = LocalPtrVar();
|
||||||
tmp = LocalPtrVar();
|
C_dup(pointer_size);
|
||||||
C_dup(pointer_size);
|
StoreLocal(tmp, pointer_size);
|
||||||
StoreLocal(tmp, pointer_size);
|
C_loi(left->ex_type->tp_size);
|
||||||
|
}
|
||||||
|
if (gencode && (oper == POSTINCR ||
|
||||||
|
oper == POSTDECR))
|
||||||
|
C_dup(ATW(left->ex_type->tp_size));
|
||||||
|
conversion(left->ex_type, tp);
|
||||||
|
if (! right_done) {
|
||||||
|
EVAL(right, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
|
}
|
||||||
|
dupval = gencode && oper != POSTINCR &&
|
||||||
|
oper != POSTDECR;
|
||||||
|
assop(tp, oper);
|
||||||
|
conversion(tp, left->ex_type);
|
||||||
|
if (compl == 0) {
|
||||||
|
store_val(&(left->EX_VALUE),
|
||||||
|
left->ex_type);
|
||||||
|
if (dupval) load_val(left, RVAL);
|
||||||
|
}
|
||||||
|
else if (compl == 1) {
|
||||||
|
EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
|
C_sti(left->ex_type->tp_size);
|
||||||
|
if (dupval) {
|
||||||
|
EVAL(left, LVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
C_loi(left->ex_type->tp_size);
|
C_loi(left->ex_type->tp_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newcode) {
|
else {
|
||||||
if (gencode && (oper == POSTINCR ||
|
LoadLocal(tmp, pointer_size);
|
||||||
oper == POSTDECR))
|
C_sti(left->ex_type->tp_size);
|
||||||
C_dup(ATW(left->ex_type->tp_size));
|
if (dupval) {
|
||||||
conversion(left->ex_type, tp);
|
|
||||||
}
|
|
||||||
if (! right_done) {
|
|
||||||
EVAL(right, RVAL, newcode, NO_LABEL, NO_LABEL);
|
|
||||||
}
|
|
||||||
if (newcode) {
|
|
||||||
int dupval = gencode && oper != POSTINCR &&
|
|
||||||
oper != POSTDECR;
|
|
||||||
assop(tp, oper);
|
|
||||||
conversion(tp, left->ex_type);
|
|
||||||
if (compl == 0) {
|
|
||||||
store_val(&(left->EX_VALUE),
|
|
||||||
left->ex_type);
|
|
||||||
if (dupval) load_val(left, RVAL);
|
|
||||||
}
|
|
||||||
else if (compl == 1) {
|
|
||||||
EVAL(left, LVAL,1, NO_LABEL, NO_LABEL);
|
|
||||||
C_sti(left->ex_type->tp_size);
|
|
||||||
if (dupval) {
|
|
||||||
EVAL(left, LVAL, 1, NO_LABEL,
|
|
||||||
NO_LABEL);
|
|
||||||
C_loi(left->ex_type->tp_size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LoadLocal(tmp, pointer_size);
|
LoadLocal(tmp, pointer_size);
|
||||||
C_sti(left->ex_type->tp_size);
|
C_loi(left->ex_type->tp_size);
|
||||||
if (dupval) {
|
|
||||||
LoadLocal(tmp, pointer_size);
|
|
||||||
C_loi(left->ex_type->tp_size);
|
|
||||||
}
|
|
||||||
FreeLocal(tmp);
|
|
||||||
}
|
}
|
||||||
|
FreeLocal(tmp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -509,14 +495,12 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
while ( ex->ex_class == Oper &&
|
while ( ex->ex_class == Oper &&
|
||||||
ex->OP_OPER == PARCOMMA
|
ex->OP_OPER == PARCOMMA
|
||||||
) {
|
) {
|
||||||
arith size = ex->OP_RIGHT->ex_type->tp_size;
|
EVAL(ex->OP_RIGHT, RVAL, TRUE,
|
||||||
EVAL(ex->OP_RIGHT, RVAL, size > 0,
|
|
||||||
NO_LABEL, NO_LABEL);
|
NO_LABEL, NO_LABEL);
|
||||||
ParSize += ATW(size);
|
ParSize += ATW(ex->OP_RIGHT->ex_type->tp_size);
|
||||||
ex = ex->OP_LEFT;
|
ex = ex->OP_LEFT;
|
||||||
}
|
}
|
||||||
EVAL(ex, RVAL, ex->ex_type->tp_size > 0,
|
EVAL(ex, RVAL, TRUE, NO_LABEL, NO_LABEL);
|
||||||
NO_LABEL, NO_LABEL);
|
|
||||||
ParSize += ATW(ex->ex_type->tp_size);
|
ParSize += ATW(ex->ex_type->tp_size);
|
||||||
}
|
}
|
||||||
if (ISNAME(left)) {
|
if (ISNAME(left)) {
|
||||||
|
@ -664,8 +648,6 @@ EVAL(expr, val, code, true_label, false_label)
|
||||||
crash("(EVAL) bad expression class");
|
crash("(EVAL) bad expression class");
|
||||||
}
|
}
|
||||||
if (expr->ex_flags & EX_VOLATILE || vol) C_nop();
|
if (expr->ex_flags & EX_VOLATILE || vol) C_nop();
|
||||||
if (vol) C_asp(expr->ex_type->tp_size);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compare() serves as an auxiliary function of EVAL */
|
/* compare() serves as an auxiliary function of EVAL */
|
||||||
|
@ -830,8 +812,6 @@ assop(type, oper)
|
||||||
C_cuu();
|
C_cuu();
|
||||||
C_ads(pointer_size);
|
C_ads(pointer_size);
|
||||||
break;
|
break;
|
||||||
case ERRONEOUS:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
crash("(assop) bad type %s\n", symbol2str(type->tp_fund));
|
crash("(assop) bad type %s\n", symbol2str(type->tp_fund));
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,9 @@ SkipToNewLine()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (ch == TOKSEP && InputLevel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!is_wsp(ch))
|
if (!is_wsp(ch))
|
||||||
garbage = 1;
|
garbage = 1;
|
||||||
|
|
Loading…
Reference in a new issue