瀏覽代碼

* overload chaining checks if the procdef is in the same symtable, this
prevents keeping references to staticsymtable only procdefs that are
not accessible through the globalsymtable. And can cause crashes when
the staticsymtable is already released.

git-svn-id: trunk@644 -

peter 20 年之前
父節點
當前提交
24f6bb1594
共有 2 個文件被更改,包括 16 次插入13 次删除
  1. 0 1
      compiler/symdef.pas
  2. 16 12
      compiler/symsym.pas

+ 0 - 1
compiler/symdef.pas

@@ -634,7 +634,6 @@ interface
        tprocdeflist = record
        tprocdeflist = record
          def  : tprocdef;
          def  : tprocdef;
          defderef : tderef;
          defderef : tderef;
-         own  : boolean;
          next : pprocdeflist;
          next : pprocdeflist;
        end;
        end;
 
 

+ 16 - 12
compiler/symsym.pas

@@ -665,8 +665,7 @@ implementation
            begin
            begin
              { only write the proc definitions that belong
              { only write the proc definitions that belong
                to this procsym and are in the global symtable }
                to this procsym and are in the global symtable }
-             if p^.own and
-                (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
+             if p^.def.owner=owner then
                inc(n);
                inc(n);
              p:=p^.next;
              p:=p^.next;
            end;
            end;
@@ -677,8 +676,7 @@ implementation
            begin
            begin
              { only write the proc definitions that belong
              { only write the proc definitions that belong
                to this procsym and are in the global symtable }
                to this procsym and are in the global symtable }
-             if p^.own and
-                (p^.def.owner.symtabletype in [globalsymtable,objectsymtable]) then
+             if p^.def.owner=owner then
                ppufile.putderef(p^.defderef);
                ppufile.putderef(p^.defderef);
              p:=p^.next;
              p:=p^.next;
            end;
            end;
@@ -717,7 +715,7 @@ implementation
          p:=pdlistfirst;
          p:=pdlistfirst;
          while assigned(p) do
          while assigned(p) do
            begin
            begin
-              if p^.own and (p^.def.forwarddef) then
+              if (p^.def.owner=owner) and (p^.def.forwarddef) then
                 begin
                 begin
                    if (m_mac in aktmodeswitches) and (p^.def.interfacedef) then
                    if (m_mac in aktmodeswitches) and (p^.def.interfacedef) then
                      import_implict_external(p^.def)
                      import_implict_external(p^.def)
@@ -740,7 +738,7 @@ implementation
          p:=pdlistfirst;
          p:=pdlistfirst;
          while assigned(p) do
          while assigned(p) do
            begin
            begin
-             if p^.own then
+             if p^.def.owner=owner then
                p^.defderef.build(p^.def);
                p^.defderef.build(p^.def);
              p:=p^.next;
              p:=p^.next;
            end;
            end;
@@ -760,7 +758,10 @@ implementation
          p:=pdlistfirst;
          p:=pdlistfirst;
          while assigned(p) do
          while assigned(p) do
            begin
            begin
-             if not p^.own then
+             if not(
+                    (p^.def=nil) or
+                    (p^.def.owner=owner)
+                   ) then
                internalerror(200310291);
                internalerror(200310291);
              p^.def:=tprocdef(p^.defderef.resolve);
              p^.def:=tprocdef(p^.defderef.resolve);
              p:=p^.next;
              p:=p^.next;
@@ -776,7 +777,6 @@ implementation
         pd^.def:=p;
         pd^.def:=p;
         pd^.defderef.reset;
         pd^.defderef.reset;
         pd^.next:=nil;
         pd^.next:=nil;
-        pd^.own:=(pd^.def.procsym=self);
         { Add at end of list to keep always
         { Add at end of list to keep always
           a correct order, also after loading from ppu }
           a correct order, also after loading from ppu }
         if assigned(pdlistlast) then
         if assigned(pdlistlast) then
@@ -801,7 +801,6 @@ implementation
         pd^.def:=nil;
         pd^.def:=nil;
         pd^.defderef:=d;
         pd^.defderef:=d;
         pd^.next:=nil;
         pd^.next:=nil;
-        pd^.own:=true;
         { Add at end of list to keep always
         { Add at end of list to keep always
           a correct order, also after loading from ppu }
           a correct order, also after loading from ppu }
         if assigned(pdlistlast) then
         if assigned(pdlistlast) then
@@ -1066,7 +1065,7 @@ implementation
          p:=pdlistfirst;
          p:=pdlistfirst;
          while assigned(p) do
          while assigned(p) do
            begin
            begin
-              if p^.own then
+              if p^.def.owner=owner then
                 p^.def.write_references(ppufile,locals);
                 p^.def.write_references(ppufile,locals);
               p:=p^.next;
               p:=p^.next;
            end;
            end;
@@ -1087,7 +1086,12 @@ implementation
          while assigned(p) do
          while assigned(p) do
            begin
            begin
               hp:=p^.next;
               hp:=p^.next;
-              if p^.own then
+             { only keep the proc definitions:
+                - are not deref'd (def=nil)
+                - are in the same symtable as the procsym (for example both
+                  are in the staticsymtable) }
+             if (p^.def=nil) or
+                (p^.def.owner=owner) then
                 begin
                 begin
                   { keep, add to list }
                   { keep, add to list }
                   if assigned(pdlistlast) then
                   if assigned(pdlistlast) then
@@ -1123,7 +1127,7 @@ implementation
         p:=pdlistfirst;
         p:=pdlistfirst;
         while assigned(p) do
         while assigned(p) do
           begin
           begin
-             if p^.own and
+             if (p^.def.owner=owner) and
                 p^.def.is_visible_for_object(tobjectdef(currobjdef)) then
                 p^.def.is_visible_for_object(tobjectdef(currobjdef)) then
                begin
                begin
                  result:=true;
                  result:=true;