From 0d9948a61b3392bfd02182976dad182a2e3a4017 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 07:58:58 +0000 Subject: [PATCH] + 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 - --- compiler/symsym.pas | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/compiler/symsym.pas b/compiler/symsym.pas index 59cea985b6..8122f5d894 100644 --- a/compiler/symsym.pas +++ b/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;