Răsfoiți Sursa

Switch dynamic arrays to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.arraydef_rtti:
  * write indirect references for the two element entries

rtl/inc/dynarr.inc:
  * tdynarraytypedata: change elType2 to PPointer for 2.7.1+
  * fpc_dynarray_clear, fpc_dynarray_setlength & fpc_dynarray_copy: correctly dereference elType2 for 2.7.1+
rtl/objpas/typinfo.pp, TTypeData:
  * rename elType and elType2 to elTypeRef and elType2Ref respectively and change type to TypeInfoPtr
  * add properties elType and elType2 which return PTypeInfo by dereferencing elTypeRef and elType2Ref respecively correctly
  * remove a few stray "inline" directives in the implementation

git-svn-id: branches/svenbarth/packages@28292 -
svenbarth 11 ani în urmă
părinte
comite
d573f3e874
3 a modificat fișierele cu 40 adăugiri și 9 ștergeri
  1. 2 2
      compiler/ncgrtti.pas
  2. 16 0
      rtl/inc/dynarr.inc
  3. 22 7
      rtl/objpas/typinfo.pp

+ 2 - 2
compiler/ncgrtti.pas

@@ -649,12 +649,12 @@ implementation
                { size of elements }
                current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_pint(def.elesize));
                { element type }
-               write_rtti_reference(def.elementdef,rt);
+               write_rtti_reference(def.elementdef,rt,true);
                { variant type }
                current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_32bit(tstoreddef(def.elementdef).getvardef));
                { element type }
                if def.elementdef.needs_inittable then
-                 write_rtti_reference(def.elementdef,rt)
+                 write_rtti_reference(def.elementdef,rt,true)
                else
                  current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_pint(0));
                { write unit name }

+ 16 - 0
rtl/inc/dynarr.inc

@@ -31,7 +31,11 @@ type
 {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
    record
      elSize : PtrUInt;
+{$ifdef ver2_6}
      elType2 : Pointer;
+{$else}
+     elType2 : PPointer;
+{$endif}
      varType : Longint;
    end;
 
@@ -73,7 +77,11 @@ procedure fpc_dynarray_clear(var p : pointer;ti : pointer); [Public,Alias:'FPC_D
     if declocked(realp^.refcount) then
       begin
         ti:=aligntoptr(ti+2+PByte(ti)[1]);
+        {$ifdef ver2_6}
         int_finalizearray(p,pdynarraytypedata(ti)^.elType2,realp^.high+1);
+        {$else}
+        int_finalizearray(p,pdynarraytypedata(ti)^.elType2^,realp^.high+1);
+        {$endif}
         freemem(realp);
       end;
     p:=nil;
@@ -138,7 +146,11 @@ procedure fpc_dynarray_setlength(var p : pointer;pti : pointer;
      ti:=aligntoptr(Pointer(pti)+2+PByte(pti)[1]);
 
      elesize:=pdynarraytypedata(ti)^.elSize;
+     {$ifdef ver2_6}
      eletype:=pdynarraytypedata(ti)^.elType2;
+     {$else}
+     eletype:=pdynarraytypedata(ti)^.elType2^;
+     {$endif}
 
      { determine new memory size }
      size:=elesize*dims[0]+sizeof(tdynarray);
@@ -282,7 +294,11 @@ function fpc_dynarray_copy(psrc : pointer;ti : pointer;
      ti:=aligntoptr(ti+2+PByte(ti)[1]);
 
      elesize:=pdynarraytypedata(ti)^.elSize;
+     {$ifdef ver2_6}
      eletype:=pdynarraytypedata(ti)^.elType2;
+     {$else}
+     eletype:=pdynarraytypedata(ti)^.elType2^;
+     {$endif}
 
      { create new array }
      size:=elesize*count;

+ 22 - 7
rtl/objpas/typinfo.pp

@@ -183,6 +183,8 @@ unit typinfo;
         function GetExtendedInfo: PTypeInfo; inline;
         function GetIntfParent: PTypeInfo; inline;
         function GetRawIntfParent: PTypeInfo; inline;
+        function GetElType: PTypeInfo; inline;
+        function GetElType2: PTypeInfo; inline;
         function GetInstanceType: PTypeInfo; inline;
         function GetRefType: PTypeInfo; inline;
       public
@@ -199,6 +201,9 @@ unit typinfo;
         property IntfParent: PTypeInfo read GetIntfParent;
         { tkInterfaceRaw }
         property RawIntfParent: PTypeInfo read GetRawIntfParent;
+        { tkDynArray }
+        property ElType2: PTypeInfo read GetElType2;
+        property ElType: PTypeInfo read GetElType;
         { tkClassRef }
         property InstanceType: PTypeInfo read GetInstanceType;
         { tkPointer }
@@ -292,9 +297,9 @@ unit typinfo;
             tkDynArray:
               (
               elSize     : PtrUInt;
-              elType2    : PTypeInfo;
+              elType2Ref : TypeInfoPtr;
               varType    : Longint;
-              elType     : PTypeInfo;
+              elTypeRef  : TypeInfoPtr;
               DynUnitName: ShortStringBase
               );
             tkClassRef:
@@ -2126,31 +2131,41 @@ begin
   Result := DerefTypeInfoPtr(CompTypeRef);
 end;
 
-function TTypeData.GetParentInfo: PTypeInfo; inline;
+function TTypeData.GetParentInfo: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(ParentInfoRef);
 end;
 
-function TTypeData.GetHelperParent: PTypeInfo; inline;
+function TTypeData.GetHelperParent: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(HelperParentRef);
 end;
 
-function TTypeData.GetExtendedInfo: PTypeInfo; inline;
+function TTypeData.GetExtendedInfo: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(ExtendedInfoRef);
 end;
 
-function TTypeData.GetIntfParent: PTypeInfo; inline;
+function TTypeData.GetIntfParent: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(IntfParentRef);
 end;
 
-function TTypeData.GetRawIntfParent: PTypeInfo; inline;
+function TTypeData.GetRawIntfParent: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(RawIntfParentRef);
 end;
 
+function TTypeData.GetElType: PTypeInfo;
+begin
+  Result := DerefTypeInfoPtr(elTypeRef);
+end;
+
+function TTypeData.GetElType2: PTypeInfo;
+begin
+  Result := DerefTypeInfoPtr(elType2Ref);
+end;
+
 function TTypeData.GetInstanceType: PTypeInfo;
 begin
   Result := DerefTypeInfoPtr(InstanceTypeRef);