Browse Source

* write dependent rtti for non-published in case of extended RTTI

Michaël Van Canneyt 1 year ago
parent
commit
9059ac067c
1 changed files with 13 additions and 8 deletions
  1. 13 8
      compiler/ncgrtti.pas

+ 13 - 8
compiler/ncgrtti.pas

@@ -49,7 +49,7 @@ interface
         procedure fields_write_rtti_data(tcb: ttai_typedconstbuilder; def: tabstractrecorddef; rt: trttitype);
         procedure fields_write_rtti_data(tcb: ttai_typedconstbuilder; def: tabstractrecorddef; rt: trttitype);
         procedure methods_write_rtti(st:tsymtable;rt:trttitype;visibilities:tvisibilities;allow_hidden:boolean);
         procedure methods_write_rtti(st:tsymtable;rt:trttitype;visibilities:tvisibilities;allow_hidden:boolean);
         procedure write_rtti_extrasyms(def:Tdef;rt:Trttitype;mainrtti:Tasmsymbol);
         procedure write_rtti_extrasyms(def:Tdef;rt:Trttitype;mainrtti:Tasmsymbol);
-        procedure published_write_rtti(st:tsymtable;rt:trttitype);
+        procedure published_write_rtti(def : tobjectdef;rt:trttitype);
         procedure properties_write_rtti_data(tcb:ttai_typedconstbuilder;propnamelist:TFPHashObjectList;st:tsymtable;extended_rtti:boolean;visibilities:tvisibilities);
         procedure properties_write_rtti_data(tcb:ttai_typedconstbuilder;propnamelist:TFPHashObjectList;st:tsymtable;extended_rtti:boolean;visibilities:tvisibilities);
         procedure write_extended_method_table(tcb:ttai_typedconstbuilder;def:tabstractrecorddef;packrecords:longint);
         procedure write_extended_method_table(tcb:ttai_typedconstbuilder;def:tabstractrecorddef;packrecords:longint);
         procedure write_extended_field_table(tcb:ttai_typedconstbuilder;def:tabstractrecorddef;packrecords:longint);
         procedure write_extended_field_table(tcb:ttai_typedconstbuilder;def:tabstractrecorddef;packrecords:longint);
@@ -888,15 +888,17 @@ implementation
       end;
       end;
 
 
 
 
-    procedure TRTTIWriter.published_write_rtti(st:tsymtable;rt:trttitype);
+    procedure TRTTIWriter.published_write_rtti(def : tobjectdef;rt:trttitype);
       var
       var
         i   : longint;
         i   : longint;
+        st : tsymtable;
         sym : tsym;
         sym : tsym;
       begin
       begin
+        st:=def.symtable;
         for i:=0 to st.SymList.Count-1 do
         for i:=0 to st.SymList.Count-1 do
           begin
           begin
             sym:=tsym(st.SymList[i]);
             sym:=tsym(st.SymList[i]);
-            if (sym.visibility=vis_published) then
+            if (sym.visibility=vis_published) or def.is_visible_for_rtti(ro_properties, sym.visibility)  then
               begin
               begin
                 case tsym(sym).typ of
                 case tsym(sym).typ of
                   propertysym:
                   propertysym:
@@ -1075,7 +1077,10 @@ implementation
             { TPropInfo is a packed record (even on targets that require
             { TPropInfo is a packed record (even on targets that require
               alignment), but it starts aligned }
               alignment), but it starts aligned }
             if addcomments then
             if addcomments then
-              tcb.emit_comment('RTTI: begin propinfo record '+sym.realname);
+              if assigned(st.name) then
+                tcb.emit_comment('RTTI: begin propinfo record '+sym.realname+' (class/rec: '+st.name^+')')
+              else
+                tcb.emit_comment('RTTI: begin propinfo record '+sym.realname+'(anon)');
             tcb.begin_anonymous_record(
             tcb.begin_anonymous_record(
               propdefname,
               propdefname,
               1,min(reqalign,SizeOf(PInt)),
               1,min(reqalign,SizeOf(PInt)),
@@ -1085,7 +1090,7 @@ implementation
             else
             else
               proctypesinfo:=0;
               proctypesinfo:=0;
             if addcomments then
             if addcomments then
-              tcb.emit_comment(#9'type info');
+              tcb.emit_comment(#9'type info '+sym.Name+' (Type: '+sym.propdef.GetTypeName+')');
             write_rtti_reference(tcb,sym.propdef,fullrtti);
             write_rtti_reference(tcb,sym.propdef,fullrtti);
             if addcomments then
             if addcomments then
               tcb.emit_comment(#9'read access');
               tcb.emit_comment(#9'read access');
@@ -2513,7 +2518,7 @@ implementation
               if (rt=initrtti) or (tobjectdef(def).objecttype=odt_object) then
               if (rt=initrtti) or (tobjectdef(def).objecttype=odt_object) then
                 fields_write_rtti(tobjectdef(def).symtable,rt)
                 fields_write_rtti(tobjectdef(def).symtable,rt)
               else
               else
-                published_write_rtti(tobjectdef(def).symtable,rt);
+                published_write_rtti(tobjectdef(def),rt);
 
 
               if (rt=fullrtti) then
               if (rt=fullrtti) then
                 begin
                 begin
@@ -2596,7 +2601,7 @@ implementation
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_data_force_indirect]);
         tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_data_force_indirect]);
         s:=internaltypeprefixName[itp_rttidef]+tstoreddef(def).rtti_mangledname(rt);
         s:=internaltypeprefixName[itp_rttidef]+tstoreddef(def).rtti_mangledname(rt);
 
 
-        maybe_add_comment(tcb,'RTTI: begin '+def.GetTypeName+' ('+rttitypenames[rt]+')');
+        maybe_add_comment(tcb,'RTTI: begin Type '+def.GetTypeName+' ('+rttitypenames[rt]+')');
         tcb.begin_anonymous_record(
         tcb.begin_anonymous_record(
           s,
           s,
           defaultpacking,reqalign,
           defaultpacking,reqalign,
@@ -2604,7 +2609,7 @@ implementation
         );
         );
         write_rtti_data(tcb,def,rt);
         write_rtti_data(tcb,def,rt);
         rttidef:=tcb.end_anonymous_record;
         rttidef:=tcb.end_anonymous_record;
-        maybe_add_comment(tcb,'RTTI: end '+def.GetTypeName+' ('+rttitypenames[rt]+')');
+        maybe_add_comment(tcb,'RTTI: end Type '+def.GetTypeName+' ('+rttitypenames[rt]+')');
         rttilab:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_GLOBAL,AT_DATA_NOINDIRECT,rttidef);
         rttilab:=current_asmdata.DefineAsmSymbol(tstoreddef(def).rtti_mangledname(rt),AB_GLOBAL,AT_DATA_NOINDIRECT,rttidef);
         current_asmdata.AsmLists[al_rtti].concatList(
         current_asmdata.AsmLists[al_rtti].concatList(
           tcb.get_final_asmlist(rttilab,rttidef,sec_rodata,rttilab.name,min(target_info.alignment.maxCrecordalign,SizeOf(QWord))));
           tcb.get_final_asmlist(rttilab,rttidef,sec_rodata,rttilab.name,min(target_info.alignment.maxCrecordalign,SizeOf(QWord))));