Browse Source

* > < >= <= support for boolean
* boolean constants are now calculated like integer constants

peter 26 years ago
parent
commit
f89f09413b
3 changed files with 25 additions and 20 deletions
  1. 8 3
      compiler/cg386add.pas
  2. 10 10
      compiler/tcadd.pas
  3. 7 7
      compiler/tree.pas

+ 8 - 3
compiler/cg386add.pas

@@ -373,7 +373,8 @@ implementation
              restore(p,false);
              set_location(p^.left^.location,p^.location);
           end;
-             
+
+
 
         set_location(p^.location,p^.left^.location);
 
@@ -710,7 +711,7 @@ implementation
                        secondpass(p^.right);
                        maketojumpbool(p^.right);
                      end;
-          unequaln,
+          unequaln,ltn,lten,gtn,gten,
        equaln,xorn : begin
                        if p^.left^.treetype=ordconstn then
                         swaptree(p);
@@ -2139,7 +2140,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.77  1999-08-30 12:00:45  pierre
+  Revision 1.78  1999-09-07 07:52:19  peter
+    * > < >= <= support for boolean
+    * boolean constants are now calculated like integer constants
+
+  Revision 1.77  1999/08/30 12:00:45  pierre
    * problem with maybe_push/restore solved hopefully
 
   Revision 1.76  1999/08/23 23:31:00  pierre

+ 10 - 10
compiler/tcadd.pas

@@ -194,12 +194,10 @@ implementation
          in fpc mode (Needed for conversion of C code) }
          if ((lt=ordconstn) and (rt=ordconstn)) and
             ((is_constintnode(p^.left) and is_constintnode(p^.right)) or
-             ((ld^.deftype=enumdef) and is_equal(ld,rd) and (m_fpc in aktmodeswitches))) then
+             (is_constboolnode(p^.left) and is_constboolnode(p^.right) and
+              (p^.treetype in [ltn,lten,gtn,gten,equaln,unequaln]))) then
            begin
-              if ld^.deftype=enumdef then
-                resdef:=ld
-              else
-                resdef:=s32bitdef;
+              resdef:=s32bitdef;
               lv:=p^.left^.value;
               rv:=p^.right^.value;
               case p^.treetype of
@@ -350,7 +348,7 @@ implementation
                       make_bool_equal_size(p);
                       p^.location.loc:=LOC_JUMP;
                     end;
-                  xorn:
+                  xorn,ltn,lten,gtn,gten :
                     begin
                       make_bool_equal_size(p);
                       if (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) and
@@ -363,9 +361,7 @@ implementation
                   equaln:
                     begin
                       make_bool_equal_size(p);
-                      { Remove any compares with constants, becuase then
-                        we get a compare with Flags in the codegen which
-                        is not supported (PFV) }
+                      { Remove any compares with constants }
                       if (p^.left^.treetype=ordconstn) then
                        begin
                          hp:=p^.right;
@@ -1122,7 +1118,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.43  1999-08-23 23:44:05  pierre
+  Revision 1.44  1999-09-07 07:52:19  peter
+    * > < >= <= support for boolean
+    * boolean constants are now calculated like integer constants
+
+  Revision 1.43  1999/08/23 23:44:05  pierre
    * setelementn registers32 corrected
 
   Revision 1.42  1999/08/07 11:29:27  peter

+ 7 - 7
compiler/tree.pas

@@ -1662,9 +1662,7 @@ unit tree;
     function is_constcharnode(p : ptree) : boolean;
 
       begin
-         is_constcharnode:=((p^.treetype=ordconstn) and
-           (p^.resulttype^.deftype=orddef) and
-           (porddef(p^.resulttype)^.typ=uchar));
+         is_constcharnode:=(p^.treetype=ordconstn) and is_char(p^.resulttype);
       end;
 
     function is_constrealnode(p : ptree) : boolean;
@@ -1676,9 +1674,7 @@ unit tree;
     function is_constboolnode(p : ptree) : boolean;
 
       begin
-         is_constboolnode:=((p^.treetype=ordconstn) and
-           (p^.resulttype^.deftype=orddef) and
-           (porddef(p^.resulttype)^.typ in [bool8bit,bool16bit,bool32bit]));
+         is_constboolnode:=(p^.treetype=ordconstn) and is_boolean(p^.resulttype);
       end;
 
     function str_length(p : ptree) : longint;
@@ -1756,7 +1752,11 @@ unit tree;
 end.
 {
   $Log$
-  Revision 1.93  1999-08-27 10:38:31  pierre
+  Revision 1.94  1999-09-07 07:52:20  peter
+    * > < >= <= support for boolean
+    * boolean constants are now calculated like integer constants
+
+  Revision 1.93  1999/08/27 10:38:31  pierre
    + EXTTEMPREGDEBUG code added
 
   Revision 1.92  1999/08/26 21:10:08  peter