Browse Source

+ constant eval for in

peter 27 years ago
parent
commit
2663a9ff1b
1 changed files with 18 additions and 1 deletions
  1. 18 1
      compiler/tcset.pas

+ 18 - 1
compiler/tcset.pas

@@ -74,6 +74,10 @@ implementation
 *****************************************************************************}
 *****************************************************************************}
 
 
     procedure firstin(var p : ptree);
     procedure firstin(var p : ptree);
+      type
+        byteset = set of byte;
+      var
+        t : ptree;
       begin
       begin
          p^.location.loc:=LOC_FLAGS;
          p^.location.loc:=LOC_FLAGS;
          p^.resulttype:=booldef;
          p^.resulttype:=booldef;
@@ -95,6 +99,16 @@ implementation
          if codegenerror then
          if codegenerror then
            exit;
            exit;
 
 
+         { constant evaulation }
+         if (p^.left^.treetype=ordconstn) and (p^.right^.treetype=setconstn) then
+          begin
+            t:=genordinalconstnode(byte(p^.left^.value in byteset(p^.right^.value_set^)),booldef);
+            disposetree(p);
+            firstpass(t);
+            p:=t;
+            exit;
+          end;
+
          left_right_max(p);
          left_right_max(p);
          { this is not allways true due to optimization }
          { this is not allways true due to optimization }
          { but if we don't set this we get problems with optimizing self code }
          { but if we don't set this we get problems with optimizing self code }
@@ -219,7 +233,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  1998-10-06 20:49:13  peter
+  Revision 1.3  1998-11-13 10:17:06  peter
+    + constant eval for in
+
+  Revision 1.2  1998/10/06 20:49:13  peter
     * m68k compiler compiles again
     * m68k compiler compiles again
 
 
   Revision 1.1  1998/09/23 20:42:24  peter
   Revision 1.1  1998/09/23 20:42:24  peter