Browse Source

Switch static arrays to indirect RTTI reference.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * arraydef_rtti: write the dimension types and the final field type as indirect references

rtl/inc/rtti.inc:
  * TArrayInfo: switch ElInfo to PPointer for 2.7.1+
  * ArrayRTTI & fpc_copy: correctly dereference ElInfo for 2.7.1+
rtl/objpas/typinfo.pp, TArrayTypeData:
  * switch ElType and Dims to PPTypeInfo; no backwards compatibility needed here as TArrayTypeData was added in 2.7.1 only

tests/test/trtti8.pp: fix test

git-svn-id: branches/svenbarth/packages@28291 -
svenbarth 11 years ago
parent
commit
8c30a4b2b4
4 changed files with 13 additions and 9 deletions
  1. 2 2
      compiler/ncgrtti.pas
  2. 6 2
      rtl/inc/rtti.inc
  3. 2 2
      rtl/objpas/typinfo.pp
  4. 3 3
      tests/test/trtti8.pp

+ 2 - 2
compiler/ncgrtti.pas

@@ -616,7 +616,7 @@ implementation
                while assigned(curdef) do
                while assigned(curdef) do
                  begin
                  begin
                    { Dims[i] PTypeInfo }
                    { Dims[i] PTypeInfo }
-                   write_rtti_reference(curdef.rangedef,rt);
+                   write_rtti_reference(curdef.rangedef,rt,true);
                    inc(dimcount);
                    inc(dimcount);
                    totalcount:=totalcount*curdef.elecount;
                    totalcount:=totalcount*curdef.elecount;
                    { get the next static array }
                    { get the next static array }
@@ -632,7 +632,7 @@ implementation
                { dimension count }
                { dimension count }
                current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_8bit(dimcount),lastai);
                current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_8bit(dimcount),lastai);
                { last dimension element type }
                { last dimension element type }
-               current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_sym(ref_rtti(curdef.elementdef,rt)),lastai);
+               current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_sym(ref_rtti(curdef.elementdef,rt,true)),lastai);
                { total element count }
                { total element count }
                current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_pint(pint(totalcount)),lastai);
                current_asmdata.asmlists[al_rtti].InsertAfter(Tai_const.Create_pint(pint(totalcount)),lastai);
                { total size = elecount * elesize of the first arraydef }
                { total size = elecount * elesize of the first arraydef }

+ 6 - 2
rtl/inc/rtti.inc

@@ -58,7 +58,11 @@ type
   record
   record
     Size: SizeInt;
     Size: SizeInt;
     ElCount: SizeInt;
     ElCount: SizeInt;
+{$ifdef ver2_6}
     ElInfo: Pointer;
     ElInfo: Pointer;
+{$else}
+    ElInfo: PPointer;
+{$endif}
     DimCount: Byte;
     DimCount: Byte;
     Dims:array[0..255] of Pointer;
     Dims:array[0..255] of Pointer;
   end;
   end;
@@ -143,7 +147,7 @@ begin
   if Count = 0 then
   if Count = 0 then
     Exit;
     Exit;
   ElSize:=PArrayInfo(typeInfo)^.Size div Count;
   ElSize:=PArrayInfo(typeInfo)^.Size div Count;
-  Info:=PArrayInfo(typeInfo)^.ElInfo;
+  Info:=PArrayInfo(typeInfo)^.ElInfo^;
   { Process elements }
   { Process elements }
   for I:=0 to Count-1 do
   for I:=0 to Count-1 do
     rttiproc(Data+(I*ElSize),Info);
     rttiproc(Data+(I*ElSize),Info);
@@ -292,7 +296,7 @@ begin
         { no elements to process => exit }
         { no elements to process => exit }
         if Count = 0 then
         if Count = 0 then
           Exit;
           Exit;
-        Info:=PArrayInfo(Temp)^.ElInfo;
+        Info:=PArrayInfo(Temp)^.ElInfo^;
         copiedsize:=Result div Count;
         copiedsize:=Result div Count;
         Offset:=0;
         Offset:=0;
         { Process elements }
         { Process elements }

+ 2 - 2
rtl/objpas/typinfo.pp

@@ -129,9 +129,9 @@ unit typinfo;
       record
       record
         Size: SizeInt;
         Size: SizeInt;
         ElCount: SizeInt;
         ElCount: SizeInt;
-        ElType: PTypeInfo;
+        ElType: PPTypeInfo;
         DimCount: Byte;
         DimCount: Byte;
-        Dims: array[0..255] of PTypeInfo;
+        Dims: array[0..255] of PPTypeInfo;
       end;
       end;
 
 
       PManagedField = ^TManagedField;
       PManagedField = ^TManagedField;

+ 3 - 3
tests/test/trtti8.pp

@@ -21,10 +21,10 @@ begin
     halt(2);
     halt(2);
   if Data^.ArrayData.ElCount <> 12 then
   if Data^.ArrayData.ElCount <> 12 then
     halt(3);
     halt(3);
-  if Data^.ArrayData.ElType <> TypeInfo(Integer) then
+  if Data^.ArrayData.ElType^ <> TypeInfo(Integer) then
     halt(4);
     halt(4);
   if Data^.ArrayData.DimCount <> 2 then
   if Data^.ArrayData.DimCount <> 2 then
     halt(5);
     halt(5);
-  if Data^.ArrayData.Dims[0] <> TypeInfo(TColor) then
+  if Data^.ArrayData.Dims[0]^ <> TypeInfo(TColor) then
     halt(6)
     halt(6)
-end.
+end.