瀏覽代碼

* use Low(LongInt) and Max(LongInt) as min/max values for the RTTI of the ByteBool, WordBool and LongBool types to be Delphi compatible; the range of the defs is not changed to avoid the application of range checks

git-svn-id: trunk@35184 -
svenbarth 8 年之前
父節點
當前提交
26e7d005aa
共有 1 個文件被更改,包括 17 次插入7 次删除
  1. 17 7
      compiler/ncgrtti.pas

+ 17 - 7
compiler/ncgrtti.pas

@@ -622,7 +622,7 @@ implementation
 
 
         procedure orddef_rtti(def:torddef);
         procedure orddef_rtti(def:torddef);
 
 
-          procedure dointeger(typekind: byte);
+          procedure doint32_64(typekind: byte;min,max:int64);
             const
             const
               trans : array[tordtype] of byte =
               trans : array[tordtype] of byte =
                 (otUByte{otNone},
                 (otUByte{otNone},
@@ -657,24 +657,29 @@ implementation
             case trans[def.ordtype] of
             case trans[def.ordtype] of
               otUQWord:
               otUQWord:
                 begin
                 begin
-                  tcb.emit_ord_const(def.low.uvalue,u64inttype);
-                  tcb.emit_ord_const(int64(def.high.uvalue),u64inttype);
+                  tcb.emit_ord_const(min,u64inttype);
+                  tcb.emit_ord_const(max,u64inttype);
                 end;
                 end;
               otSQWord:
               otSQWord:
                 begin
                 begin
-                  tcb.emit_ord_const(def.low.svalue,s64inttype);
-                  tcb.emit_ord_const(def.high.svalue,s64inttype);
+                  tcb.emit_ord_const(min,s64inttype);
+                  tcb.emit_ord_const(max,s64inttype);
                 end;
                 end;
               else
               else
                 begin
                 begin
-                  tcb.emit_ord_const(longint(def.low.svalue),s32inttype);
-                  tcb.emit_ord_const(longint(def.high.svalue),s32inttype);
+                  tcb.emit_ord_const(longint(min),s32inttype);
+                  tcb.emit_ord_const(longint(max),s32inttype);
                 end;
                 end;
             end;
             end;
             tcb.end_anonymous_record;
             tcb.end_anonymous_record;
             tcb.end_anonymous_record;
             tcb.end_anonymous_record;
           end;
           end;
 
 
+        procedure dointeger(typekind:byte);inline;
+          begin
+            doint32_64(typekind,int64(def.low.svalue),int64(def.high.svalue));
+          end;
+
         begin
         begin
           case def.ordtype of
           case def.ordtype of
             s64bit :
             s64bit :
@@ -683,6 +688,11 @@ implementation
                 dointeger(tkQWord);
                 dointeger(tkQWord);
             pasbool8:
             pasbool8:
                 dointeger(tkBool);
                 dointeger(tkBool);
+            { use different low/high values to be Delphi compatible }
+            bool8bit,
+            bool16bit,
+            bool32bit:
+                doint32_64(tkInteger,longint(low(longint)),longint(high(longint)));
             uchar:
             uchar:
                 dointeger(tkChar);
                 dointeger(tkChar);
             uwidechar:
             uwidechar: