Przeglądaj źródła

* have the generic dummy symbols for procsyms keep track of their overloaded generic procsyms so that they can be easily found (will be needed for implicit specializations)

git-svn-id: trunk@48096 -
svenbarth 4 lat temu
rodzic
commit
6160abe37e

+ 2 - 0
compiler/pdecsub.pas

@@ -1183,6 +1183,8 @@ implementation
                 include(dummysym.symoptions,sp_generic_dummy);
                 add_generic_dummysym(dummysym);
               end;
+            if dummysym.typ=procsym then
+              tprocsym(dummysym).add_generic_overload(aprocsym);
             { start token recorder for the declaration }
             pd.init_genericdecl;
             current_scanner.startrecordtokens(pd.genericdecltokenbuf);

+ 1 - 1
compiler/ppu.pas

@@ -48,7 +48,7 @@ const
   CurrentPPUVersion = 208;
   { for any other changes to the ppu format, increase this version number
     (it's a cardinal) }
-  CurrentPPULongVersion = 12;
+  CurrentPPULongVersion = 13;
 
 { unit flags }
   uf_big_endian          = $000004;

+ 78 - 0
compiler/symsym.pas

@@ -131,6 +131,8 @@ interface
        protected
           FProcdefList   : TFPObjectList;
           FProcdefDerefList : TFPList;
+          fgenprocsymovlds : tfpobjectlist;
+          fgenprocsymovldsderefs : tfplist;
        public
           constructor create(const n : TSymStr);virtual;
           constructor ppuload(ppufile:tcompilerppufile);
@@ -153,7 +155,11 @@ interface
           function find_procdef_byprocvardef(d:Tprocvardef):Tprocdef;
           function find_procdef_assignment_operator(fromdef,todef:tdef;var besteq:tequaltype;isexplicit:boolean):Tprocdef;
           function find_procdef_enumerator_operator(fromdef,todef:tdef;var besteq:tequaltype):Tprocdef;
+          procedure add_generic_overload(sym:tprocsym);
           property ProcdefList:TFPObjectList read FProcdefList;
+          { only valid if sp_generic_dummy is set and either an overload was
+            added using add_generic_overload or this was loaded from a ppu }
+          property genprocsymovlds:tfpobjectlist read fgenprocsymovlds;
        end;
        tprocsymclass = class of tprocsym;
 
@@ -902,8 +908,10 @@ implementation
 
     constructor tprocsym.ppuload(ppufile:tcompilerppufile);
       var
+         symderef,
          pdderef : tderef;
          i,
+         symcnt,
          pdcnt : longint;
       begin
          inherited ppuload(procsym,ppufile);
@@ -915,6 +923,17 @@ implementation
             ppufile.getderef(pdderef);
             FProcdefDerefList.Add(Pointer(PtrInt(pdderef.dataidx)));
           end;
+         if sp_generic_dummy in symoptions then
+           begin
+             fgenprocsymovlds:=tfpobjectlist.create(false);
+             fgenprocsymovldsderefs:=tfplist.create;
+             symcnt:=ppufile.getword;
+             for i:=1 to symcnt do
+               begin
+                 ppufile.getderef(symderef);
+                 fgenprocsymovldsderefs.add(pointer(ptrint(symderef.dataidx)));
+               end;
+           end;
          ppuload_platform(ppufile);
       end;
 
@@ -924,6 +943,8 @@ implementation
         FProcdefList.Free;
         if assigned(FProcdefDerefList) then
           FProcdefDerefList.Free;
+        fgenprocsymovlds.free;
+        fgenprocsymovldsderefs.free;
         inherited destroy;
       end;
 
@@ -942,6 +963,17 @@ implementation
              d.dataidx:=PtrInt(FProcdefDerefList[i]);
              ppufile.putderef(d);
            end;
+         if sp_generic_dummy in symoptions then
+           begin
+             if not assigned(fgenprocsymovldsderefs) then
+               internalerror(2021010301);
+             ppufile.putword(fgenprocsymovldsderefs.count);
+             for i:=0 to fgenprocsymovldsderefs.count-1 do
+               begin
+                 d.dataidx:=ptrint(fgenprocsymovldsderefs[i]);
+                 ppufile.putderef(d);
+               end;
+           end;
          writeentry(ppufile,ibprocsym);
       end;
 
@@ -996,6 +1028,7 @@ implementation
         i  : longint;
         pd : tprocdef;
         d  : tderef;
+        sym : tprocsym;
       begin
         inherited;
         if not assigned(FProcdefDerefList) then
@@ -1013,6 +1046,21 @@ implementation
                 FProcdefDerefList.Add(Pointer(PtrInt(d.dataidx)));
               end;
           end;
+        if sp_generic_dummy in symoptions then
+          begin
+            if not assigned(fgenprocsymovlds) then
+              internalerror(2021010602);
+            if not assigned(fgenprocsymovldsderefs) then
+              fgenprocsymovldsderefs:=tfplist.create
+            else
+              fgenprocsymovldsderefs.clear;
+            for i:=0 to fgenprocsymovlds.count-1 do
+              begin
+                sym:=tprocsym(fgenprocsymovlds[i]);
+                d.build(sym);
+                fgenprocsymovldsderefs.add(pointer(ptrint(d.dataidx)));
+              end;
+          end;
       end;
 
 
@@ -1021,6 +1069,7 @@ implementation
         i  : longint;
         pd : tprocdef;
         d  : tderef;
+        sym : tsym;
       begin
         { Clear all procdefs }
         ProcdefList.Clear;
@@ -1032,6 +1081,20 @@ implementation
             pd:=tprocdef(d.resolve);
             ProcdefList.Add(pd);
           end;
+        if sp_generic_dummy in symoptions then
+          begin
+            if not assigned(fgenprocsymovlds) then
+              internalerror(2021010603);
+            if not assigned(fgenprocsymovldsderefs) then
+              internalerror(2021010302);
+            fgenprocsymovlds.clear;
+            for i:= 0 to fgenprocsymovldsderefs.count-1 do
+              begin
+                d.dataidx:=ptrint(fgenprocsymovldsderefs[i]);
+                sym:=tprocsym(d.resolve);
+                fgenprocsymovlds.add(sym);
+              end;
+          end;
       end;
 
 
@@ -1398,6 +1461,21 @@ implementation
       end;
 
 
+    procedure tprocsym.add_generic_overload(sym:tprocsym);
+      var
+        i : longint;
+      begin
+        if not (sp_generic_dummy in symoptions) then
+          internalerror(2021010601);
+        if not assigned(fgenprocsymovlds) then
+          fgenprocsymovlds:=tfpobjectlist.create(false);
+        for i:=0 to genprocsymovlds.count-1 do
+          if tprocsym(genprocsymovlds[i])=sym then
+            exit;
+        genprocsymovlds.add(sym);
+      end;
+
+
 {****************************************************************************
                                   TERRORSYM
 ****************************************************************************}

+ 16 - 2
compiler/utils/ppuutils/ppudump.pp

@@ -1705,8 +1705,12 @@ begin
   if symoptions<>[] then
    begin
      if Def <> nil then
-       if sp_internal in symoptions then
-         Def.Visibility:=dvHidden;
+       begin
+         if sp_internal in symoptions then
+           Def.Visibility:=dvHidden;
+         if sp_generic_dummy in symoptions then
+           Def.GenericDummy:=true;
+       end;
      first:=true;
      for i:=1to symopts do
       if (symopt[i].mask in symoptions) then
@@ -3599,6 +3603,16 @@ begin
                 readderef('', def.Ref);
                 _finddef(def);
               end;
+             if def.GenericDummy then
+               begin
+                 len:=ppufile.getword;
+                 for i:=1 to len do
+                   begin
+                     write([space,'     Gen Ovld : ']);
+                     readderef('',def.Ref);
+                     _finddef(def);
+                   end;
+               end;
            end;
 
          ibconstsym :

+ 1 - 0
compiler/utils/ppuutils/ppuout.pp

@@ -127,6 +127,7 @@ type
     // Symbol/definition reference
     Ref: TPpuRef;
     Visibility: TPpuDefVisibility;
+    GenericDummy: Boolean;
     Attrs: array of TPpuAttr;
 
     constructor Create(AParent: TPpuContainerDef); virtual; reintroduce;