yet another fix in those tricky FOR-loops
This commit is contained in:
parent
51169956dc
commit
d0b452373b
1 changed files with 8 additions and 7 deletions
|
@ -400,7 +400,7 @@ STATIC
|
||||||
ForLoopVarExpr(nd)
|
ForLoopVarExpr(nd)
|
||||||
register struct node *nd;
|
register struct node *nd;
|
||||||
{
|
{
|
||||||
register struct type *tp;
|
register struct type *tp = nd->nd_type;
|
||||||
|
|
||||||
CodePExpr(nd);
|
CodePExpr(nd);
|
||||||
CodeCoercion(tp, BaseType(tp));
|
CodeCoercion(tp, BaseType(tp));
|
||||||
|
@ -509,23 +509,22 @@ WalkStat(nd, exit_label)
|
||||||
bstp = BaseType(nd->nd_type);
|
bstp = BaseType(nd->nd_type);
|
||||||
uns = bstp->tp_fund != T_INTEGER;
|
uns = bstp->tp_fund != T_INTEGER;
|
||||||
C_dup(int_size);
|
C_dup(int_size);
|
||||||
|
RangeCheck(left->nd_left->nd_type, nd->nd_type);
|
||||||
|
CodeDStore(nd);
|
||||||
CodePExpr(fnd);
|
CodePExpr(fnd);
|
||||||
tmp = NewInt();
|
tmp = NewInt();
|
||||||
C_stl(tmp);
|
C_stl(tmp);
|
||||||
C_lol(tmp);
|
C_lol(tmp);
|
||||||
if (uns) C_cmu(int_size);
|
if (uns) C_cmu(int_size);
|
||||||
else C_cmi(int_size);
|
else C_cmi(int_size);
|
||||||
RangeCheck(bstp, nd->nd_type);
|
|
||||||
if (left->nd_INT >= 0) {
|
if (left->nd_INT >= 0) {
|
||||||
C_zgt(l2);
|
C_zgt(l2);
|
||||||
CodeDStore(nd);
|
|
||||||
C_lol(tmp);
|
C_lol(tmp);
|
||||||
ForLoopVarExpr(nd);
|
ForLoopVarExpr(nd);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
C_zlt(l2);
|
C_zlt(l2);
|
||||||
C_dup(int_size);
|
ForLoopVarExpr(nd);
|
||||||
CodeDStore(nd);
|
|
||||||
C_lol(tmp);
|
C_lol(tmp);
|
||||||
}
|
}
|
||||||
C_sbu(int_size);
|
C_sbu(int_size);
|
||||||
|
@ -535,15 +534,18 @@ WalkStat(nd, exit_label)
|
||||||
C_loc((arith) 1);
|
C_loc((arith) 1);
|
||||||
C_adu(int_size);
|
C_adu(int_size);
|
||||||
}
|
}
|
||||||
|
C_stl(tmp);
|
||||||
nd->nd_def->df_flags |= D_FORLOOP;
|
nd->nd_def->df_flags |= D_FORLOOP;
|
||||||
C_df_ilb(l1);
|
C_df_ilb(l1);
|
||||||
}
|
}
|
||||||
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 (stepsize && good_forvar) {
|
||||||
|
C_lol(tmp);
|
||||||
C_loc((arith) 1);
|
C_loc((arith) 1);
|
||||||
C_sbu(int_size);
|
C_sbu(int_size);
|
||||||
C_dup(int_size);
|
C_stl(tmp);
|
||||||
|
C_lol(tmp);
|
||||||
C_zeq(l2);
|
C_zeq(l2);
|
||||||
C_loc(left->nd_INT);
|
C_loc(left->nd_INT);
|
||||||
ForLoopVarExpr(nd);
|
ForLoopVarExpr(nd);
|
||||||
|
@ -553,7 +555,6 @@ WalkStat(nd, exit_label)
|
||||||
}
|
}
|
||||||
C_bra(l1);
|
C_bra(l1);
|
||||||
C_df_ilb(l2);
|
C_df_ilb(l2);
|
||||||
C_asp(int_size);
|
|
||||||
FreeInt(tmp);
|
FreeInt(tmp);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nd->nd_left = left;
|
nd->nd_left = left;
|
||||||
|
|
Loading…
Add table
Reference in a new issue