Ver código fonte

+ tprocsym.find_procdef_bypara_no_rettype() that looks for a procdef
based on the parameters, but ignoring the result type. Used to
find out whether a function/procedures with these parameters
can still be added in terms of overloading (since overloading
ignores different result types, it only depends on the parameters)

git-svn-id: branches/jvmbackend@18430 -

Jonas Maebe 14 anos atrás
pai
commit
0d9948a61b
1 arquivos alterados com 27 adições e 5 exclusões
  1. 27 5
      compiler/symsym.pas

+ 27 - 5
compiler/symsym.pas

@@ -101,6 +101,7 @@ interface
           procedure buildderef;override;
           procedure deref;override;
           function find_procdef_bytype(pt:Tproctypeoption):Tprocdef;
+          function find_procdef_bypara_no_rettype(para:TFPObjectList;cpoptions:tcompare_paras_options):Tprocdef;
           function find_procdef_bypara(para:TFPObjectList;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
           function find_procdef_bytype_and_para(pt:Tproctypeoption;para:TFPObjectList;retdef:tdef;cpoptions:tcompare_paras_options):Tprocdef;
           function find_procdef_byoptions(ops:tprocoptions): Tprocdef;
@@ -654,13 +655,18 @@ implementation
 
 
     function check_procdef_paras(pd:tprocdef;para:TFPObjectList;retdef:tdef;
-                                            cpoptions:tcompare_paras_options): tprocdef;
+                                            cpoptions:tcompare_paras_options; checkrettype: boolean): tprocdef;
       var
         eq: tequaltype;
       begin
         result:=nil;
-        if assigned(retdef) then
-          eq:=compare_defs(retdef,pd.returndef,nothingn)
+        if checkrettype then
+          begin
+            if assigned(retdef) then
+              eq:=compare_defs(retdef,pd.returndef,nothingn)
+            else
+              eq:=te_equal;
+          end
         else
           eq:=te_equal;
         if (eq>=te_equal) or
@@ -677,6 +683,22 @@ implementation
       end;
 
 
+    function tprocsym.find_procdef_bypara_no_rettype(para: TFPObjectList; cpoptions: tcompare_paras_options): Tprocdef;
+      var
+        i: longint;
+        pd: tprocdef;
+      begin
+        result:=nil;
+        for i:=0 to ProcdefList.Count-1 do
+          begin
+            pd:=tprocdef(ProcdefList[i]);
+            result:=check_procdef_paras(pd,para,nil,cpoptions,false);
+            if assigned(result) then
+              exit;
+          end;
+      end;
+
+
     function Tprocsym.Find_procdef_bypara(para:TFPObjectList;retdef:tdef;
                                             cpoptions:tcompare_paras_options):Tprocdef;
       var
@@ -687,7 +709,7 @@ implementation
         for i:=0 to ProcdefList.Count-1 do
           begin
             pd:=tprocdef(ProcdefList[i]);
-            result:=check_procdef_paras(pd,para,retdef,cpoptions);
+            result:=check_procdef_paras(pd,para,retdef,cpoptions,true);
             if assigned(result) then
               exit;
           end;
@@ -706,7 +728,7 @@ implementation
             pd:=tprocdef(ProcdefList[i]);
             if pd.proctypeoption=pt then
               begin
-                result:=check_procdef_paras(pd,para,retdef,cpoptions);
+                result:=check_procdef_paras(pd,para,retdef,cpoptions,true);
                 if assigned(result) then
                   exit;
               end;