Bläddra i källkod

* extract checking whether two parameter defs of two procdefs are equal into a separate function

git-svn-id: trunk@45972 -
svenbarth 5 år sedan
förälder
incheckning
fa0c9adbf4
1 ändrade filer med 24 tillägg och 20 borttagningar
  1. 24 20
      compiler/defcmp.pas

+ 24 - 20
compiler/defcmp.pas

@@ -29,7 +29,7 @@ interface
        cclasses,
        cclasses,
        globtype,globals,
        globtype,globals,
        node,
        node,
-       symconst,symtype,symdef;
+       symconst,symtype,symdef,symbase;
 
 
      type
      type
        { if acp is cp_all the var const or nothing are considered equal }
        { if acp is cp_all the var const or nothing are considered equal }
@@ -167,6 +167,11 @@ interface
     { - objectdef: if it inherits from otherdef or they are equal              }
     { - objectdef: if it inherits from otherdef or they are equal              }
     function def_is_related(curdef,otherdef:tdef):boolean;
     function def_is_related(curdef,otherdef:tdef):boolean;
 
 
+    { Checks whether two defs for parameters or result types of a generic }
+    { routine can be considered as equal. Requires the symtables of the   }
+    { procdefs the parameters defs shall belong to.                       }
+    function equal_genfunc_paradefs(fwdef,currdef:tdef;fwpdst,currpdst:tsymtable):boolean;
+
 
 
 implementation
 implementation
 
 
@@ -2097,23 +2102,6 @@ implementation
       var
       var
         currpara1,
         currpara1,
         currpara2 : tparavarsym;
         currpara2 : tparavarsym;
-
-        function equal_genfunc_paradefs(def1,def2:tdef):boolean;
-          begin
-            result:=false;
-            if (sp_generic_para in def1.typesym.symoptions) and
-                (sp_generic_para in def2.typesym.symoptions) and
-                (def1.owner=currpara1.owner) and
-                (def2.owner=currpara2.owner) then
-              begin
-                { the forward declaration may have constraints }
-                if not (df_genconstraint in def2.defoptions) and (def2.typ=undefineddef) and
-                    ((def1.typ=undefineddef) or (df_genconstraint in def1.defoptions)) then
-                  result:=true;
-              end
-          end;
-
-      var
         eq,lowesteq : tequaltype;
         eq,lowesteq : tequaltype;
         hpd       : tprocdef;
         hpd       : tprocdef;
         convtype  : tconverttype;
         convtype  : tconverttype;
@@ -2254,7 +2242,7 @@ implementation
                     end
                     end
                   else if (cpo_generic in cpoptions) then
                   else if (cpo_generic in cpoptions) then
                     begin
                     begin
-                      if equal_genfunc_paradefs(currpara1.vardef,currpara2.vardef) then
+                      if equal_genfunc_paradefs(currpara1.vardef,currpara2.vardef,currpara1.owner,currpara2.owner) then
                         eq:=te_exact
                         eq:=te_exact
                       else
                       else
                         exit;
                         exit;
@@ -2268,7 +2256,7 @@ implementation
                   if is_open_array(currpara1.vardef) and
                   if is_open_array(currpara1.vardef) and
                       is_open_array(currpara2.vardef) then
                       is_open_array(currpara2.vardef) then
                     begin
                     begin
-                      if equal_genfunc_paradefs(tarraydef(currpara1.vardef).elementdef,tarraydef(currpara2.vardef).elementdef) then
+                      if equal_genfunc_paradefs(tarraydef(currpara1.vardef).elementdef,tarraydef(currpara2.vardef).elementdef,currpara1.owner,currpara2.owner) then
                         eq:=te_exact;
                         eq:=te_exact;
                     end
                     end
                   else
                   else
@@ -2611,4 +2599,20 @@ implementation
         end;
         end;
       end;
       end;
 
 
+
+    function equal_genfunc_paradefs(fwdef,currdef:tdef;fwpdst,currpdst:tsymtable): boolean;
+      begin
+        result:=false;
+        if (sp_generic_para in fwdef.typesym.symoptions) and
+            (sp_generic_para in currdef.typesym.symoptions) and
+            (fwdef.owner=fwpdst) and
+            (currdef.owner=currpdst) then
+          begin
+            { the forward declaration may have constraints }
+            if not (df_genconstraint in currdef.defoptions) and (currdef.typ=undefineddef) and
+                ((fwdef.typ=undefineddef) or (df_genconstraint in fwdef.defoptions)) then
+              result:=true;
+          end
+      end;
+
 end.
 end.