浏览代码

* do not write a "copied" symtable to a ppu when holding only a reference to it,
write the owner instead and get a reference to the symtable again when loading
a ppu, might resolve #8180

git-svn-id: trunk@11262 -

florian 17 年之前
父节点
当前提交
396b1c7c1e
共有 2 个文件被更改,包括 28 次插入6 次删除
  1. 2 1
      compiler/symconst.pas
  2. 26 5
      compiler/symdef.pas

+ 2 - 1
compiler/symconst.pas

@@ -301,7 +301,8 @@ type
     oo_has_msgint,
     oo_has_msgint,
     oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
     oo_can_have_published,{ the class has rtti, i.e. you can publish properties }
     oo_has_default_property,
     oo_has_default_property,
-    oo_has_valid_guid
+    oo_has_valid_guid,
+    oo_copied_class
   );
   );
   tobjectoptions=set of tobjectoption;
   tobjectoptions=set of tobjectoption;
 
 

+ 26 - 5
compiler/symdef.pas

@@ -226,6 +226,9 @@ interface
           dwarf_struct_lab : tasmsymbol;
           dwarf_struct_lab : tasmsymbol;
           childof        : tobjectdef;
           childof        : tobjectdef;
           childofderef   : tderef;
           childofderef   : tderef;
+          cloneddef      : tobjectdef;
+          cloneddefderef : tderef;
+
           objname,
           objname,
           objrealname    : pshortstring;
           objrealname    : pshortstring;
           objectoptions  : tobjectoptions;
           objectoptions  : tobjectoptions;
@@ -3699,7 +3702,10 @@ implementation
          else
          else
            ImplementedInterfaces:=nil;
            ImplementedInterfaces:=nil;
 
 
-         tObjectSymtable(symtable).ppuload(ppufile);
+         if oo_copied_class in objectoptions then
+           ppufile.getderef(cloneddefderef)
+         else
+           tObjectSymtable(symtable).ppuload(ppufile);
 
 
          { handles the predefined class tobject  }
          { handles the predefined class tobject  }
          { the last TOBJECT which is loaded gets }
          { the last TOBJECT which is loaded gets }
@@ -3715,6 +3721,7 @@ implementation
          writing_class_record_dbginfo:=false;
          writing_class_record_dbginfo:=false;
        end;
        end;
 
 
+
     destructor tobjectdef.destroy;
     destructor tobjectdef.destroy;
       begin
       begin
          if assigned(symtable) then
          if assigned(symtable) then
@@ -3754,7 +3761,7 @@ implementation
           tobjectdef(result).objname:=stringdup(objname^);
           tobjectdef(result).objname:=stringdup(objname^);
         if assigned(objrealname) then
         if assigned(objrealname) then
           tobjectdef(result).objrealname:=stringdup(objrealname^);
           tobjectdef(result).objrealname:=stringdup(objrealname^);
-        tobjectdef(result).objectoptions:=objectoptions;
+        tobjectdef(result).objectoptions:=objectoptions+[oo_copied_class];
         tobjectdef(result).vmt_offset:=vmt_offset;
         tobjectdef(result).vmt_offset:=vmt_offset;
         if assigned(iidguid) then
         if assigned(iidguid) then
           begin
           begin
@@ -3807,9 +3814,13 @@ implementation
                end;
                end;
            end;
            end;
 
 
+         if oo_copied_class in objectoptions then
+           ppufile.putderef(cloneddefderef);
+
          ppufile.writeentry(ibobjectdef);
          ppufile.writeentry(ibobjectdef);
 
 
-         tObjectSymtable(symtable).ppuwrite(ppufile);
+         if not(oo_copied_class in objectoptions) then
+           tObjectSymtable(symtable).ppuwrite(ppufile);
       end;
       end;
 
 
 
 
@@ -3832,7 +3843,11 @@ implementation
       begin
       begin
          inherited buildderef;
          inherited buildderef;
          childofderef.build(childof);
          childofderef.build(childof);
-         tstoredsymtable(symtable).buildderef;
+         if oo_copied_class in objectoptions then
+           cloneddefderef.build(symtable.defowner)
+         else
+           tstoredsymtable(symtable).buildderef;
+
          if objecttype in [odt_class,odt_interfacecorba] then
          if objecttype in [odt_class,odt_interfacecorba] then
            begin
            begin
              for i:=0 to ImplementedInterfaces.count-1 do
              for i:=0 to ImplementedInterfaces.count-1 do
@@ -3847,7 +3862,13 @@ implementation
       begin
       begin
          inherited deref;
          inherited deref;
          childof:=tobjectdef(childofderef.resolve);
          childof:=tobjectdef(childofderef.resolve);
-         tstoredsymtable(symtable).deref;
+         if oo_copied_class in objectoptions then
+           begin
+             cloneddef:=tobjectdef(cloneddefderef.resolve);
+             symtable:=cloneddef.symtable.getcopy;
+           end
+         else
+           tstoredsymtable(symtable).deref;
          if objecttype in [odt_class,odt_interfacecorba] then
          if objecttype in [odt_class,odt_interfacecorba] then
            begin
            begin
              for i:=0 to ImplementedInterfaces.count-1 do
              for i:=0 to ImplementedInterfaces.count-1 do