Browse Source

* extend ref_rtti() with the possibility to use a direct reference if really desired

git-svn-id: trunk@35127 -
svenbarth 8 years ago
parent
commit
e580e22576
1 changed files with 7 additions and 5 deletions
  1. 7 5
      compiler/ncgrtti.pas

+ 7 - 5
compiler/ncgrtti.pas

@@ -50,7 +50,9 @@ interface
         function  published_properties_count(st:tsymtable):longint;
         function  published_properties_count(st:tsymtable):longint;
         procedure published_properties_write_rtti_data(tcb: ttai_typedconstbuilder; propnamelist: TFPHashObjectList; st: tsymtable);
         procedure published_properties_write_rtti_data(tcb: ttai_typedconstbuilder; propnamelist: TFPHashObjectList; st: tsymtable);
         procedure collect_propnamelist(propnamelist:TFPHashObjectList;objdef:tobjectdef);
         procedure collect_propnamelist(propnamelist:TFPHashObjectList;objdef:tobjectdef);
-        function  ref_rtti(def:tdef;rt:trttitype):tasmsymbol;
+        { only use a direct reference if the referenced type can *only* reside
+          in the same unit as the current one }
+        function  ref_rtti(def:tdef;rt:trttitype;indirect:boolean):tasmsymbol;
         procedure write_rtti_name(tcb: ttai_typedconstbuilder; def: tdef);
         procedure write_rtti_name(tcb: ttai_typedconstbuilder; def: tdef);
         procedure write_rtti_data(tcb: ttai_typedconstbuilder; def:tdef; rt: trttitype);
         procedure write_rtti_data(tcb: ttai_typedconstbuilder; def:tdef; rt: trttitype);
         procedure write_child_rtti_data(def:tdef;rt:trttitype);
         procedure write_child_rtti_data(def:tdef;rt:trttitype);
@@ -785,7 +787,7 @@ implementation
                { total element count }
                { total element count }
                tcb.emit_tai(Tai_const.Create_sizeint(asizeint(totalcount)),sizeuinttype);
                tcb.emit_tai(Tai_const.Create_sizeint(asizeint(totalcount)),sizeuinttype);
                { last dimension element type }
                { last dimension element type }
-               tcb.emit_tai(Tai_const.Create_sym(ref_rtti(curdef.elementdef,rt)),voidpointertype);
+               tcb.emit_tai(Tai_const.Create_sym(ref_rtti(curdef.elementdef,rt,true)),voidpointertype);
                { dimension count }
                { dimension count }
                tcb.emit_ord_const(dimcount,u8inttype);
                tcb.emit_ord_const(dimcount,u8inttype);
                finaldef:=def;
                finaldef:=def;
@@ -1548,16 +1550,16 @@ implementation
         if not assigned(def) or is_void(def) or ((rt<>initrtti) and is_objc_class_or_protocol(def)) then
         if not assigned(def) or is_void(def) or ((rt<>initrtti) and is_objc_class_or_protocol(def)) then
           tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype)
           tcb.emit_tai(Tai_const.Create_nil_dataptr,voidpointertype)
         else
         else
-          tcb.emit_tai(Tai_const.Create_sym(ref_rtti(def,rt)),voidpointertype);
+          tcb.emit_tai(Tai_const.Create_sym(ref_rtti(def,rt,true)),voidpointertype);
       end;
       end;
 
 
 
 
-    function TRTTIWriter.ref_rtti(def:tdef;rt:trttitype):tasmsymbol;
+    function TRTTIWriter.ref_rtti(def:tdef;rt:trttitype;indirect:boolean):tasmsymbol;
       var
       var
         s : TSymStr;
         s : TSymStr;
       begin
       begin
         s:=def.rtti_mangledname(rt);
         s:=def.rtti_mangledname(rt);
-        result:=current_asmdata.RefAsmSymbol(s,AT_DATA,true);
+        result:=current_asmdata.RefAsmSymbol(s,AT_DATA,indirect);
         if (cs_create_pic in current_settings.moduleswitches) and
         if (cs_create_pic in current_settings.moduleswitches) and
            assigned(current_procinfo) then
            assigned(current_procinfo) then
           include(current_procinfo.flags,pi_needs_got);
           include(current_procinfo.flags,pi_needs_got);