Browse Source

* Check whether call to deref(impl) is needed during re-resolve (indexes may be -1 if not yet built)

Michaël Van Canneyt 1 year ago
parent
commit
881eb0fab5
2 changed files with 26 additions and 4 deletions
  1. 8 4
      compiler/fppu.pas
  2. 18 0
      compiler/symtable.pas

+ 8 - 4
compiler/fppu.pas

@@ -194,14 +194,18 @@ var
 
 
       begin
       begin
         Message1(unit_u_reresolving_unit,modulename^);
         Message1(unit_u_reresolving_unit,modulename^);
-        tstoredsymtable(globalsymtable).deref(false);
-        tstoredsymtable(globalsymtable).derefimpl(false);
+        if tstoredsymtable(globalsymtable).is_deref_built then
+          tstoredsymtable(globalsymtable).deref(false);
+        if tstoredsymtable(globalsymtable).is_derefimpl_built then
+          tstoredsymtable(globalsymtable).derefimpl(false);
         if assigned(localsymtable) then
         if assigned(localsymtable) then
           begin
           begin
             { we have only builderef(impl)'d the registered symbols of
             { we have only builderef(impl)'d the registered symbols of
               the localsymtable -> also only deref those again }
               the localsymtable -> also only deref those again }
-            tstoredsymtable(localsymtable).deref(true);
-            tstoredsymtable(localsymtable).derefimpl(true);
+            if tstoredsymtable(localsymtable).is_deref_built then
+              tstoredsymtable(localsymtable).deref(true);
+            if tstoredsymtable(localsymtable).is_derefimpl_built then
+              tstoredsymtable(localsymtable).derefimpl(true);
           end;
           end;
         if assigned(wpoinfo) then
         if assigned(wpoinfo) then
           begin
           begin

+ 18 - 0
compiler/symtable.pas

@@ -36,9 +36,14 @@ interface
 ****************************************************************************}
 ****************************************************************************}
 
 
     type
     type
+
+       { tstoredsymtable }
+
        tstoredsymtable = class(TSymtable)
        tstoredsymtable = class(TSymtable)
        private
        private
           init_final_check_done : boolean;
           init_final_check_done : boolean;
+          deref_built : boolean;
+          derefimpl_built : boolean;
           procedure _needs_init_final(sym:TObject;arg:pointer);
           procedure _needs_init_final(sym:TObject;arg:pointer);
           procedure do_init_final_check;
           procedure do_init_final_check;
           procedure check_forward(sym:TObject;arg:pointer);
           procedure check_forward(sym:TObject;arg:pointer);
@@ -73,6 +78,8 @@ interface
           procedure checklabels;
           procedure checklabels;
           function  needs_init_final : boolean; virtual;
           function  needs_init_final : boolean; virtual;
           function  has_non_trivial_init:boolean;virtual;
           function  has_non_trivial_init:boolean;virtual;
+          function is_derefimpl_built: Boolean;
+          function is_deref_built: Boolean;
           procedure testfordefaultproperty(sym:TObject;arg:pointer);
           procedure testfordefaultproperty(sym:TObject;arg:pointer);
           procedure register_children;
           procedure register_children;
        end;
        end;
@@ -697,6 +704,15 @@ implementation
         ppufile.writeentry(ibendsyms);
         ppufile.writeentry(ibendsyms);
       end;
       end;
 
 
+    function tstoredsymtable.is_deref_built: Boolean;
+    begin
+      Result:=deref_built;
+    end;
+
+    function tstoredsymtable.is_derefimpl_built: Boolean;
+    begin
+      Result:=derefimpl_built;
+    end;
 
 
     procedure tstoredsymtable.buildderef;
     procedure tstoredsymtable.buildderef;
       var
       var
@@ -716,6 +732,7 @@ implementation
             sym:=tstoredsym(SymList[i]);
             sym:=tstoredsym(SymList[i]);
             sym.buildderef;
             sym.buildderef;
           end;
           end;
+        deref_built:=True;
       end;
       end;
 
 
 
 
@@ -730,6 +747,7 @@ implementation
             def:=tstoreddef(DefList[i]);
             def:=tstoreddef(DefList[i]);
             def.buildderefimpl;
             def.buildderefimpl;
           end;
           end;
+        derefimpl_built:=True;
       end;
       end;