mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-23 06:49:49 +02:00
* extract checking whether two parameter defs of two procdefs are equal into a separate function
git-svn-id: trunk@45972 -
This commit is contained in:
parent
42f2e5f8ad
commit
fa0c9adbf4
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user