2
0
Эх сурвалжийг харах

* fixed qword(longint) that removed sign from the number
* removed code in the compiler that relied on wrong qword(longint)
code generation

peter 21 жил өмнө
parent
commit
c96ba04d84

+ 9 - 9
compiler/cresstr.pas

@@ -91,9 +91,8 @@ begin
   FreeMem(Value,Len);
 end;
 
-{$ifopt r+}
-{$define rangeon}
-{$r-}
+{$ifdef ver1_0}
+  {$R-}
 {$endif}
 
 procedure TResourceStringItem.CalcHash;
@@ -114,13 +113,9 @@ begin
       end;
    end;
   If Hash=0 then
-    Hash:=Not(0);
+    Hash:=$ffffffff;
 end;
 
-{$ifdef rangeon}
-{$r+}
-{$undef rangeon}
-{$endif}
 
 { ---------------------------------------------------------------------
                           TRESOURCESTRINGS
@@ -300,7 +295,12 @@ end;
 end.
 {
   $Log$
-  Revision 1.22  2004-03-02 00:36:33  olle
+  Revision 1.23  2004-05-23 15:23:30  peter
+    * fixed qword(longint) that removed sign from the number
+    * removed code in the compiler that relied on wrong qword(longint)
+      code generation
+
+  Revision 1.22  2004/03/02 00:36:33  olle
     * big transformation of Tai_[const_]Symbol.Create[data]name*
 
   Revision 1.21  2004/02/26 16:16:38  peter

+ 7 - 3
compiler/ncgutil.pas

@@ -394,8 +394,7 @@ implementation
               end;
               { reset hi part, take care of the signed bit of the current value }
               hregisterhi:=cg.getintregister(list,OS_INT);
-              if (dst_size=OS_S64) and
-                 (l.size in [OS_S8,OS_S16,OS_S32]) then
+              if (l.size in [OS_S8,OS_S16,OS_S32]) then
                begin
                  if l.loc=LOC_CONSTANT then
                   begin
@@ -2134,7 +2133,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.201  2004-05-23 15:06:21  peter
+  Revision 1.202  2004-05-23 15:23:30  peter
+    * fixed qword(longint) that removed sign from the number
+    * removed code in the compiler that relied on wrong qword(longint)
+      code generation
+
+  Revision 1.201  2004/05/23 15:06:21  peter
     * implicit_finally flag must be set in pass1
     * add check whether the implicit frame is generated when expected
 

+ 14 - 10
compiler/ptconst.pas

@@ -99,7 +99,6 @@ implementation
               end;
          end;
 
-{$R-}  {Range check creates problem with init_8bit(-1) !!}
       begin
          old_block_type:=block_type;
          block_type:=bt_const;
@@ -115,28 +114,28 @@ implementation
                     bool8bit :
                       begin
                          if is_constboolnode(p) then
-                           curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value))
+                           curconstSegment.concat(Tai_const.Create_8bit(byte(tordconstnode(p).value)))
                          else
                            Message(cg_e_illegal_expression);
                       end;
                     bool16bit :
                       begin
                          if is_constboolnode(p) then
-                           curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value))
+                           curconstSegment.concat(Tai_const.Create_16bit(word(tordconstnode(p).value)))
                          else
                            Message(cg_e_illegal_expression);
                       end;
                     bool32bit :
                       begin
                          if is_constboolnode(p) then
-                           curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value))
+                           curconstSegment.concat(Tai_const.Create_32bit(cardinal(tordconstnode(p).value)))
                          else
                            Message(cg_e_illegal_expression);
                       end;
                     uchar :
                       begin
                          if is_constcharnode(p) then
-                           curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value))
+                           curconstSegment.concat(Tai_const.Create_8bit(byte(tordconstnode(p).value)))
                          else
                            Message(cg_e_illegal_expression);
                       end;
@@ -145,7 +144,7 @@ implementation
                          if is_constcharnode(p) then
                            inserttypeconv(p,cwidechartype);
                          if is_constwidecharnode(p) then
-                           curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value))
+                           curconstSegment.concat(Tai_const.Create_16bit(word(tordconstnode(p).value)))
                          else
                            Message(cg_e_illegal_expression);
                       end;
@@ -154,7 +153,7 @@ implementation
                       begin
                          if is_constintnode(p) then
                            begin
-                              curconstSegment.concat(Tai_const.Create_8bit(tordconstnode(p).value));
+                              curconstSegment.concat(Tai_const.Create_8bit(byte(tordconstnode(p).value)));
                               check_range(torddef(t.def));
                            end
                          else
@@ -165,7 +164,7 @@ implementation
                       begin
                          if is_constintnode(p) then
                            begin
-                             curconstSegment.concat(Tai_const.Create_16bit(tordconstnode(p).value));
+                             curconstSegment.concat(Tai_const.Create_16bit(word(tordconstnode(p).value)));
                              check_range(torddef(t.def));
                            end
                          else
@@ -176,7 +175,7 @@ implementation
                       begin
                          if is_constintnode(p) then
                            begin
-                              curconstSegment.concat(Tai_const.Create_32bit(tordconstnode(p).value));
+                              curconstSegment.concat(Tai_const.Create_32bit(cardinal(tordconstnode(p).value)));
                               if torddef(t.def).typ<>u32bit then
                                check_range(torddef(t.def));
                            end
@@ -1090,7 +1089,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.84  2004-04-29 19:56:37  daniel
+  Revision 1.85  2004-05-23 15:23:30  peter
+    * fixed qword(longint) that removed sign from the number
+    * removed code in the compiler that relied on wrong qword(longint)
+      code generation
+
+  Revision 1.84  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
 
   Revision 1.83  2004/04/11 10:44:23  peter

+ 19 - 42
compiler/symdef.pas

@@ -1858,44 +1858,20 @@ implementation
 
 
     constructor torddef.ppuload(ppufile:tcompilerppufile);
-      var
-        l1,l2 : longint;
       begin
          inherited ppuloaddef(ppufile);
          deftype:=orddef;
          typ:=tbasetype(ppufile.getbyte);
          if sizeof(TConstExprInt)=8 then
-          begin
-            l1:=ppufile.getlongint;
-            l2:=ppufile.getlongint;
-{$ifopt R+}
-  {$define Range_check_on}
-{$endif opt R+}
-{$R- needed here }
-            low:=qword(l1)+(int64(l2) shl 32);
-{$ifdef Range_check_on}
-  {$R+}
-  {$undef Range_check_on}
-{$endif Range_check_on}
-          end
-         else
-          low:=ppufile.getlongint;
-         if sizeof(TConstExprInt)=8 then
-          begin
-            l1:=ppufile.getlongint;
-            l2:=ppufile.getlongint;
-{$ifopt R+}
-  {$define Range_check_on}
-{$endif opt R+}
-{$R- needed here }
-            high:=qword(l1)+(int64(l2) shl 32);
-{$ifdef Range_check_on}
-  {$R+}
-  {$undef Range_check_on}
-{$endif Range_check_on}
-          end
+           begin
+             low:=ppufile.getint64;
+             high:=ppufile.getint64;
+           end
          else
-          high:=ppufile.getlongint;
+           begin
+             low:=ppufile.getlongint;
+             high:=ppufile.getlongint;
+           end;
          setsize;
       end;
 
@@ -1931,18 +1907,14 @@ implementation
          ppufile.putbyte(byte(typ));
          if sizeof(TConstExprInt)=8 then
           begin
-            ppufile.putlongint(longint(lo(low)));
-            ppufile.putlongint(longint(hi(low)));
+            ppufile.putint64(low);
+            ppufile.putint64(high);
           end
          else
-          ppufile.putlongint(low);
-         if sizeof(TConstExprInt)=8 then
           begin
-            ppufile.putlongint(longint(lo(high)));
-            ppufile.putlongint(longint(hi(high)));
-          end
-         else
-          ppufile.putlongint(high);
+            ppufile.putlongint(low);
+            ppufile.putlongint(high);
+          end;
          ppufile.writeentry(iborddef);
       end;
 
@@ -6184,7 +6156,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.237  2004-05-22 23:33:18  peter
+  Revision 1.238  2004-05-23 15:23:30  peter
+    * fixed qword(longint) that removed sign from the number
+    * removed code in the compiler that relied on wrong qword(longint)
+      code generation
+
+  Revision 1.237  2004/05/22 23:33:18  peter
   fix range check error when array size > maxlongint
 
   Revision 1.236  2004/05/01 22:05:01  florian

+ 10 - 47
compiler/symtype.pas

@@ -1182,54 +1182,18 @@ implementation
 
 
     function tcompilerppufile.getexprint:tconstexprint;
-      var
-        l1,l2 : longint;
       begin
         if sizeof(tconstexprint)=8 then
-          begin
-            l1:=getlongint;
-            l2:=getlongint;
-{$ifopt R+}
-  {$define Range_check_on}
-{$endif opt R+}
-{$R- needed here }
-{$ifdef Delphi}
-            result:=int64(l1)+(int64(l2) shl 32);
-{$else}
-            result:=qword(l1)+(int64(l2) shl 32);
-{$endif}
-{$ifdef Range_check_on}
-  {$R+}
-  {$undef Range_check_on}
-{$endif Range_check_on}
-          end
+          result:=tconstexprint(getint64)
         else
           result:=tconstexprint(getlongint);
       end;
 
 
     function tcompilerppufile.getPtrUInt:TConstPtrUInt;
-      var
-        l1,l2 : longint;
       begin
         if sizeof(TConstPtrUInt)=8 then
-          begin
-            l1:=getlongint;
-            l2:=getlongint;
-{$ifopt R+}
-  {$define Range_check_on}
-{$endif opt R+}
-{$R- needed here }
-{$ifdef Delphi}
-            result:=int64(l1)+(int64(l2) shl 32);
-{$else}
-            result:=qword(l1)+(int64(l2) shl 32);
-{$endif}
-{$ifdef Range_check_on}
-  {$R+}
-  {$undef Range_check_on}
-{$endif Range_check_on}
-          end
+          result:=tconstptruint(getint64)
         else
           result:=TConstPtrUInt(getlongint);
       end;
@@ -1415,10 +1379,7 @@ implementation
     procedure tcompilerppufile.putexprint(v:tconstexprint);
       begin
         if sizeof(TConstExprInt)=8 then
-          begin
-             putlongint(longint(lo(v)));
-             putlongint(longint(hi(v)));
-          end
+          putint64(int64(v))
         else if sizeof(TConstExprInt)=4 then
           putlongint(longint(v))
         else
@@ -1429,10 +1390,7 @@ implementation
     procedure tcompilerppufile.PutPtrUInt(v:TConstPtrUInt);
       begin
         if sizeof(TConstPtrUInt)=8 then
-          begin
-             putlongint(longint(lo(v)));
-             putlongint(longint(hi(v)));
-          end
+          putint64(int64(v))
         else if sizeof(TConstPtrUInt)=4 then
           putlongint(longint(v))
         else
@@ -1529,7 +1487,12 @@ finalization
 end.
 {
   $Log$
-  Revision 1.40  2004-02-27 13:04:22  daniel
+  Revision 1.41  2004-05-23 15:23:30  peter
+    * fixed qword(longint) that removed sign from the number
+    * removed code in the compiler that relied on wrong qword(longint)
+      code generation
+
+  Revision 1.40  2004/02/27 13:04:22  daniel
     * Removed unused concatstabto
 
   Revision 1.39  2004/02/11 19:59:06  peter