Browse Source

* fixed repeat continue until true;

peter 27 years ago
parent
commit
8772ddfc7b
2 changed files with 40 additions and 48 deletions
  1. 1 1
      bugs/readme.txt
  2. 39 47
      compiler/cg386flw.pas

+ 1 - 1
bugs/readme.txt

@@ -182,6 +182,7 @@ Fixed bugs:
   bug0157.pp   Invalid compilation and also crashes                  OK 0.99.7 (PFV)
   bug0157.pp   Invalid compilation and also crashes                  OK 0.99.7 (PFV)
   bug0158.pp   Invalid boolean typecast                              OK 0.99.7 (PFV)
   bug0158.pp   Invalid boolean typecast                              OK 0.99.7 (PFV)
   bug0159.pp   Invalid virtual functions - should compile            OK 0.99.7 (FK)
   bug0159.pp   Invalid virtual functions - should compile            OK 0.99.7 (FK)
+  bug0162.pp   continue in repeat ... until loop doesn't work correct OK 0.99.8 (PFV)
   bug0164.pp   crash when using undeclared array index in with statement OK 0.99.8 (PFV)
   bug0164.pp   crash when using undeclared array index in with statement OK 0.99.8 (PFV)
 
 
 Unproducable bugs:
 Unproducable bugs:
@@ -216,7 +217,6 @@ bug0152.pp   End value of loop variable must be calculated before loop
              variable is initialized.
              variable is initialized.
 bug0161.pp   internal error when trying to create a set with another set as
 bug0161.pp   internal error when trying to create a set with another set as
              its element (instead of a syntax error)
              its element (instead of a syntax error)
-bug0162.pp   continue in repeat ... until loop doesn't work correct
 bug0163.pp   missing <= and >= operators for sets.
 bug0163.pp   missing <= and >= operators for sets.
 bug0165.pp   missing range check code for enumerated types.
 bug0165.pp   missing range check code for enumerated types.
 bug0166.pp   forward type used in declaration crashes instead of error
 bug0166.pp   forward type used in declaration crashes instead of error

+ 39 - 47
compiler/cg386flw.pas

@@ -55,62 +55,51 @@ implementation
 
 
     procedure second_while_repeatn(var p : ptree);
     procedure second_while_repeatn(var p : ptree);
       var
       var
-         l1,l2,l3,oldclabel,oldblabel : plabel;
+         lcont,lbreak,lloop,
+         oldclabel,oldblabel : plabel;
          otlabel,oflabel : plabel;
          otlabel,oflabel : plabel;
       begin
       begin
-         getlabel(l1);
-         getlabel(l2);
+         getlabel(lloop);
+         getlabel(lcont);
+         getlabel(lbreak);
          { arrange continue and breaklabels: }
          { arrange continue and breaklabels: }
          oldclabel:=aktcontinuelabel;
          oldclabel:=aktcontinuelabel;
          oldblabel:=aktbreaklabel;
          oldblabel:=aktbreaklabel;
-         if p^.treetype=repeatn then
-           begin
-              emitl(A_LABEL,l1);
-              aktcontinuelabel:=l1;
-              aktbreaklabel:=l2;
-              cleartempgen;
-              if assigned(p^.right) then
-                secondpass(p^.right);
 
 
-              otlabel:=truelabel;
-              oflabel:=falselabel;
-              truelabel:=l2;
-              falselabel:=l1;
-              cleartempgen;
-              secondpass(p^.left);
-              maketojumpbool(p^.left);
-              emitl(A_LABEL,l2);
-              truelabel:=otlabel;
-              falselabel:=oflabel;
-           end
-         else
-           begin
-              { handling code at the end as it is much more efficient }
-              emitl(A_JMP,l2);
-
-              emitl(A_LABEL,l1);
-              cleartempgen;
+         { handling code at the end as it is much more efficient, and makes
+           while equal to repeat loop, only the end true/false is swapped (PFV) }
+         if p^.treetype=whilen then
+          emitl(A_JMP,lcont);
 
 
-              getlabel(l3);
-              aktcontinuelabel:=l2;
-              aktbreaklabel:=l3;
+         emitl(A_LABEL,lloop);
 
 
-              if assigned(p^.right) then
-                secondpass(p^.right);
+         aktcontinuelabel:=lcont;
+         aktbreaklabel:=lbreak;
+         cleartempgen;
+         if assigned(p^.right) then
+          secondpass(p^.right);
 
 
-              emitl(A_LABEL,l2);
-              otlabel:=truelabel;
-              oflabel:=falselabel;
-              truelabel:=l1;
-              falselabel:=l3;
-              cleartempgen;
-              secondpass(p^.left);
-              maketojumpbool(p^.left);
+         emitl(A_LABEL,lcont);
+         otlabel:=truelabel;
+         oflabel:=falselabel;
+         if p^.treetype=whilen then
+          begin
+            truelabel:=lloop;
+            falselabel:=lbreak;
+          end
+         { repeatn }
+         else
+          begin
+            truelabel:=lbreak;
+            falselabel:=lloop;
+          end;
+         cleartempgen;
+         secondpass(p^.left);
+         maketojumpbool(p^.left);
+         emitl(A_LABEL,lbreak);
+         truelabel:=otlabel;
+         falselabel:=oflabel;
 
 
-              emitl(A_LABEL,l3);
-              truelabel:=otlabel;
-              falselabel:=oflabel;
-           end;
          aktcontinuelabel:=oldclabel;
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
          aktbreaklabel:=oldblabel;
       end;
       end;
@@ -735,7 +724,10 @@ do_jmp:
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.18  1998-09-26 15:03:04  florian
+  Revision 1.19  1998-09-28 12:13:53  peter
+    * fixed repeat continue until true;
+
+  Revision 1.18  1998/09/26 15:03:04  florian
     * small problems with DOM and excpetions fixed (code generation
     * small problems with DOM and excpetions fixed (code generation
       of raise was wrong and self was sometimes destroyed :()
       of raise was wrong and self was sometimes destroyed :()