浏览代码

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

daniel 23 年之前
父节点
当前提交
c6f75def0c
共有 1 个文件被更改,包括 13 次插入12 次删除
  1. 13 12
      compiler/nflw.pas

+ 13 - 12
compiler/nflw.pas

@@ -581,6 +581,7 @@ implementation
          inherited create(forn,l,r,_t1,_t2);
          inherited create(forn,l,r,_t1,_t2);
          if back then
          if back then
            include(flags,nf_backward);
            include(flags,nf_backward);
+	 testatbegin:=true;
       end;
       end;
 
 
 
 
@@ -591,20 +592,21 @@ implementation
          result:=nil;
          result:=nil;
          resulttype:=voidtype;
          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
          if left.nodetype<>assignn then
            begin
            begin
               CGMessage(cg_e_illegal_expression);
               CGMessage(cg_e_illegal_expression);
               exit;
               exit;
            end;
            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 }
          { save counter var }
          t2:=tassignmentnode(left).left.getcopy;
          t2:=tassignmentnode(left).left.getcopy;
 
 
@@ -1244,10 +1246,9 @@ begin
 end.
 end.
 {
 {
   $Log$
   $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
   Revision 1.40  2002/07/20 08:19:31  daniel
   * State tracker automatically changes while loops into repeat loops
   * State tracker automatically changes while loops into repeat loops