changed code for loops a bit, and fixed an error in MkCoercion

This commit is contained in:
ceriel 1987-08-19 18:07:41 +00:00
parent 19b0c2a0b0
commit 0983b7700f
3 changed files with 9 additions and 14 deletions

View file

@ -63,12 +63,10 @@ MkCoercion(pnd, tp)
if (nd_tp->tp_fund == T_STRING) return; if (nd_tp->tp_fund == T_STRING) return;
nd_tp = BaseType(nd_tp); nd_tp = BaseType(nd_tp);
if (nd->nd_class == Value) { if (nd->nd_class == Value) {
if (nd_tp->tp_fund == T_REAL && tp->tp_fund != T_REAL) goto Out;
switch(tp->tp_fund) { switch(tp->tp_fund) {
case T_REAL: case T_REAL:
if (nd_tp->tp_fund == T_REAL) {
break; break;
}
goto Out;
case T_SUBRANGE: case T_SUBRANGE:
if (! chk_bounds(tp->sub_lb, nd->nd_INT, if (! chk_bounds(tp->sub_lb, nd->nd_INT,
BaseType(tp)->tp_fund) || BaseType(tp)->tp_fund) ||
@ -92,8 +90,7 @@ MkCoercion(pnd, tp)
case T_INTORCARD: case T_INTORCARD:
case T_CARDINAL: case T_CARDINAL:
case T_POINTER: case T_POINTER:
if ((nd_tp->tp_fund == T_INTEGER && if ((nd_tp->tp_fund == T_INTEGER && nd->nd_INT < 0) ||
nd->nd_INT < 0) ||
(nd->nd_INT & ~full_mask[(int)(tp->tp_size)])) { (nd->nd_INT & ~full_mask[(int)(tp->tp_size)])) {
node_warning(nd, node_warning(nd,
W_ORDINARY, W_ORDINARY,

View file

@ -69,6 +69,8 @@ retained.
make INTEGER ranges symmetric, t.i., MIN(INTEGER) = - MAX(INTEGER). make INTEGER ranges symmetric, t.i., MIN(INTEGER) = - MAX(INTEGER).
This is useful for interpreters that use the "real" MIN(INTEGER) to This is useful for interpreters that use the "real" MIN(INTEGER) to
indicate "undefined". indicate "undefined".
.IP \fB-R\fR
disable all range checks.
.LP .LP
.SH FILES .SH FILES
.IR ~em/lib/em_m2 : .IR ~em/lib/em_m2 :

View file

@ -501,9 +501,6 @@ WalkStat(nd, exit_label)
W_ORDINARY, W_ORDINARY,
"zero stepsize in FOR loop"); "zero stepsize in FOR loop");
} }
if (stepsize < 0) {
stepsize = -stepsize;
}
fnd = left->nd_right; fnd = left->nd_right;
if (good_forvar) { if (good_forvar) {
bstp = BaseType(nd->nd_type); bstp = BaseType(nd->nd_type);
@ -523,6 +520,7 @@ WalkStat(nd, exit_label)
ForLoopVarExpr(nd); ForLoopVarExpr(nd);
} }
else { else {
stepsize = -stepsize;
C_zlt(l2); C_zlt(l2);
ForLoopVarExpr(nd); ForLoopVarExpr(nd);
C_lol(tmp); C_lol(tmp);
@ -531,8 +529,6 @@ WalkStat(nd, exit_label)
if (stepsize) { if (stepsize) {
C_loc(stepsize); C_loc(stepsize);
C_dvu(int_size); C_dvu(int_size);
C_loc((arith) 1);
C_adu(int_size);
} }
C_stl(tmp); C_stl(tmp);
nd->nd_def->df_flags |= D_FORLOOP; nd->nd_def->df_flags |= D_FORLOOP;
@ -540,13 +536,13 @@ WalkStat(nd, exit_label)
} }
WalkNode(right, exit_label); WalkNode(right, exit_label);
nd->nd_def->df_flags &= ~D_FORLOOP; nd->nd_def->df_flags &= ~D_FORLOOP;
if (stepsize && good_forvar) { if (good_forvar && stepsize) {
C_lol(tmp);
C_zeq(l2);
C_lol(tmp); C_lol(tmp);
C_loc((arith) 1); C_loc((arith) 1);
C_sbu(int_size); C_sbu(int_size);
C_stl(tmp); C_stl(tmp);
C_lol(tmp);
C_zeq(l2);
C_loc(left->nd_INT); C_loc(left->nd_INT);
ForLoopVarExpr(nd); ForLoopVarExpr(nd);
C_adu(int_size); C_adu(int_size);