Sfoglia il codice sorgente

+ added helper function are_equal_ints()

git-svn-id: trunk@35761 -
nickysn 8 anni fa
parent
commit
876c0c5fd5
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      compiler/defutil.pas

+ 13 - 0
compiler/defutil.pas

@@ -259,6 +259,9 @@ interface
     {# Returns true, if def is a 64 bit type }
     function is_64bit(def : tdef) : boolean;
 
+    { true, if def1 and def2 are both integers of the same bit size and sign }
+    function are_equal_ints(def1, def2: tdef): boolean;
+
     { true, if def is an int type, larger than the processor's native int size }
     function is_oversizedint(def : tdef) : boolean;
 
@@ -925,6 +928,16 @@ implementation
       end;
 
 
+    { true, if def1 and def2 are both integers of the same bit size and sign }
+    function are_equal_ints(def1, def2: tdef): boolean;
+      begin
+        result:=(def1.typ=orddef) and (def2.typ=orddef) and
+          (torddef(def1).ordtype in [u8bit,u16bit,u32bit,u64bit,
+                                     s8bit,s16bit,s32bit,s64bit]) and
+          (torddef(def1).ordtype=torddef(def2).ordtype);
+      end;
+
+
     { true, if def is an int type, larger than the processor's native int size }
     function is_oversizedint(def : tdef) : boolean;
       begin