Browse Source

+ added defutil.is_nativeint and is_nativeord

git-svn-id: branches/i8086@24166 -
nickysn 12 years ago
parent
commit
70d02e6942
1 changed files with 35 additions and 0 deletions
  1. 35 0
      compiler/defutil.pas

+ 35 - 0
compiler/defutil.pas

@@ -255,6 +255,12 @@ interface
     { true, if def is an ordinal type, larger than the processor's native int size }
     { true, if def is an ordinal type, larger than the processor's native int size }
     function is_oversizedord(def : tdef) : boolean;
     function is_oversizedord(def : tdef) : boolean;
 
 
+    { true, if def is an int type, equal in size to the processor's native int size }
+    function is_nativeint(def : tdef) : boolean;
+
+    { true, if def is an ordinal type, equal in size to the processor's native int size }
+    function is_nativeord(def : tdef) : boolean;
+
     {# If @var(l) isn't in the range of todef a range check error (if not explicit) is generated and
     {# If @var(l) isn't in the range of todef a range check error (if not explicit) is generated and
       the value is placed within the range
       the value is placed within the range
     }
     }
@@ -888,6 +894,35 @@ implementation
       end;
       end;
 
 
 
 
+    { true, if def is an int type, equal in size to the processor's native int size }
+    function is_nativeint(def: tdef): boolean;
+      begin
+{$if defined(cpu8bitalu)}
+         result:=is_8bitint(def);
+{$elseif defined(cpu16bitalu)}
+         result:=is_16bitint(def);
+{$elseif defined(cpu32bitaddr)}
+         result:=is_32bitint(def);
+{$elseif defined(cpu64bitaddr)}
+         result:=is_64bitint(def);
+{$endif}
+      end;
+
+    { true, if def is an ordinal type, equal in size to the processor's native int size }
+    function is_nativeord(def: tdef): boolean;
+      begin
+{$if defined(cpu8bitalu)}
+         result:=is_8bit(def);
+{$elseif defined(cpu16bitalu)}
+         result:=is_16bit(def);
+{$elseif defined(cpu32bitaddr)}
+         result:=is_32bit(def);
+{$elseif defined(cpu64bitaddr)}
+         result:=is_64bit(def);
+{$endif}
+      end;
+
+
     { if l isn't in the range of todef a range check error (if not explicit) is generated and
     { if l isn't in the range of todef a range check error (if not explicit) is generated and
       the value is placed within the range }
       the value is placed within the range }
     procedure testrange(todef : tdef;var l : tconstexprint;explicit,forcerangecheck:boolean);
     procedure testrange(todef : tdef;var l : tconstexprint;explicit,forcerangecheck:boolean);