Changed translation of FOR-statement: now, if it is executed 0
times, the loop-control-variable is not assigned to
This commit is contained in:
parent
d418617de6
commit
b90690ba5d
2 changed files with 7 additions and 6 deletions
|
@ -1 +1 @@
|
||||||
static char Version[] = "ACK Modula-2 compiler Version 0.41";
|
static char Version[] = "ACK Modula-2 compiler Version 0.42";
|
||||||
|
|
|
@ -525,7 +525,7 @@ WalkStat(nd, exit_label)
|
||||||
case FOR:
|
case FOR:
|
||||||
{
|
{
|
||||||
arith tmp = NewInt();
|
arith tmp = NewInt();
|
||||||
arith tmp2 = 0;
|
arith tmp2 = NewInt();
|
||||||
register t_node *fnd;
|
register t_node *fnd;
|
||||||
int good_forvar;
|
int good_forvar;
|
||||||
label l1 = ++text_label;
|
label l1 = ++text_label;
|
||||||
|
@ -548,11 +548,13 @@ WalkStat(nd, exit_label)
|
||||||
C_stl(tmp);
|
C_stl(tmp);
|
||||||
CodePExpr(left->nd_left);
|
CodePExpr(left->nd_left);
|
||||||
C_dup(int_size);
|
C_dup(int_size);
|
||||||
CodeDStore(nd);
|
C_stl(tmp2);
|
||||||
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);
|
||||||
C_zgt(l2);
|
C_zgt(l2);
|
||||||
|
C_lol(tmp2);
|
||||||
|
CodeDStore(nd);
|
||||||
C_lol(tmp);
|
C_lol(tmp);
|
||||||
ForLoopVarExpr(nd);
|
ForLoopVarExpr(nd);
|
||||||
if (left->nd_INT >= 0) {
|
if (left->nd_INT >= 0) {
|
||||||
|
@ -570,13 +572,12 @@ WalkStat(nd, exit_label)
|
||||||
nd->nd_def->df_flags |= D_FORLOOP;
|
nd->nd_def->df_flags |= D_FORLOOP;
|
||||||
def_ilb(l1);
|
def_ilb(l1);
|
||||||
if (! options['R']) {
|
if (! options['R']) {
|
||||||
tmp2 = NewInt();
|
|
||||||
ForLoopVarExpr(nd);
|
ForLoopVarExpr(nd);
|
||||||
C_stl(tmp2);
|
C_stl(tmp2);
|
||||||
}
|
}
|
||||||
WalkNode(right, exit_label);
|
WalkNode(right, exit_label);
|
||||||
nd->nd_def->df_flags &= ~D_FORLOOP;
|
nd->nd_def->df_flags &= ~D_FORLOOP;
|
||||||
if (tmp2 != 0) {
|
if (! options['R']) {
|
||||||
label x = ++text_label;
|
label x = ++text_label;
|
||||||
C_lol(tmp2);
|
C_lol(tmp2);
|
||||||
ForLoopVarExpr(nd);
|
ForLoopVarExpr(nd);
|
||||||
|
@ -584,8 +585,8 @@ WalkStat(nd, exit_label)
|
||||||
c_loc(M2_FORCH);
|
c_loc(M2_FORCH);
|
||||||
C_trp();
|
C_trp();
|
||||||
def_ilb(x);
|
def_ilb(x);
|
||||||
FreeInt(tmp2);
|
|
||||||
}
|
}
|
||||||
|
FreeInt(tmp2);
|
||||||
if (stepsize) {
|
if (stepsize) {
|
||||||
C_lol(tmp);
|
C_lol(tmp);
|
||||||
C_zeq(l2);
|
C_zeq(l2);
|
||||||
|
|
Loading…
Reference in a new issue