* Small mistake fixed; the skip test was done before we know the for node

is correct.
This commit is contained in:
daniel 2002-07-20 11:18:18 +00:00
parent 8cbd40c2f0
commit c6f75def0c

View File

@ -581,6 +581,7 @@ implementation
inherited create(forn,l,r,_t1,_t2);
if back then
include(flags,nf_backward);
testatbegin:=true;
end;
@ -591,20 +592,21 @@ implementation
result:=nil;
resulttype:=voidtype;
{Can we spare the first comparision.}
{testatbegin:=false; Already false by constructor}
if right.nodetype=ordconstn then
if Tassignmentnode(left).right.nodetype=ordconstn then
testatbegin:=((nf_backward in flags) and
(Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value))
or (not(nf_backward in flags) and
(Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value));
if left.nodetype<>assignn then
begin
CGMessage(cg_e_illegal_expression);
exit;
end;
{Can we spare the first comparision?}
if right.nodetype=ordconstn then
if Tassignmentnode(left).right.nodetype=ordconstn then
testatbegin:=not(((nf_backward in flags) and
(Tordconstnode(Tassignmentnode(left).right).value>=Tordconstnode(right).value))
or (not(nf_backward in flags) and
(Tordconstnode(Tassignmentnode(left).right).value<=Tordconstnode(right).value)));
{ save counter var }
t2:=tassignmentnode(left).left.getcopy;
@ -1244,10 +1246,9 @@ begin
end.
{
$Log$
Revision 1.41 2002-07-20 11:15:51 daniel
* The for node does a check if the first comparision can be skipped. I moved
the check from the second pass to the resulttype pass. The advantage is
that the state tracker can now decide to skip the first comparision too.
Revision 1.42 2002-07-20 11:18:18 daniel
* Small mistake fixed; the skip test was done before we know the for node
is correct.
Revision 1.40 2002/07/20 08:19:31 daniel
* State tracker automatically changes while loops into repeat loops