Refactor tobjectdef.find_implemented_interface out into unit defcmp so that the recently introduced cycle between symdef and defcmp can be broken again.

defcmp.pas:
  + add function "find_implemented_interface"
  * change method call of "find_implemented_interface" into function call
symdef.pas:
  - tobjectdef: remove method "find_implemented_interface"
  - remove use of unit "defcmp"
pgenutil.pas:
  * change method call of "find_implemented_interface" into function call
  + add use of unit "defcmp"
ncgcnv.pas, ncnv.pas, pdecobj.pas, pdecsub.pas, pdecvar.pas:
  * change method call of "find_implemented_interface" into function call

git-svn-id: trunk@25844 -
This commit is contained in:
svenbarth 2013-10-23 19:05:00 +00:00
parent 555634b755
commit 76f6de5cf1
8 changed files with 37 additions and 31 deletions

View File

@ -152,6 +152,10 @@ interface
{ parentdef's resultdef }
function compatible_childmethod_resultdef(parentretdef, childretdef: tdef): boolean;
{ Checks whether the class impldef or one of its parent classes implements }
{ the interface intfdef and returns the corresponding "implementation link }
function find_implemented_interface(impldef,intfdef:tobjectdef):timplementedinterface;
implementation
@ -1588,7 +1592,7 @@ implementation
hobjdef:=tobjectdef(def_from);
while assigned(hobjdef) do
begin
if hobjdef.find_implemented_interface(tobjectdef(def_to))<>nil then
if find_implemented_interface(hobjdef,tobjectdef(def_to))<>nil then
begin
if is_interface(def_to) then
doconv:=tc_class_2_intf
@ -2193,4 +2197,27 @@ implementation
end;
function find_implemented_interface(impldef,intfdef:tobjectdef):timplementedinterface;
var
implintf : timplementedinterface;
i : longint;
begin
if not assigned(impldef) then
internalerror(2013102301);
if not assigned(intfdef) then
internalerror(2013102302);
result:=nil;
if not assigned(impldef.implementedinterfaces) then
exit;
for i:=0 to impldef.implementedinterfaces.count-1 do
begin
implintf:=timplementedinterface(impldef.implementedinterfaces[i]);
if equal_defs(implintf.intfdef,intfdef) then
begin
result:=implintf;
exit;
end;
end;
end;
end.

View File

@ -708,7 +708,7 @@ interface
hd:=tobjectdef(left.resultdef);
while assigned(hd) do
begin
ImplIntf:=hd.find_implemented_interface(tobjectdef(resultdef));
ImplIntf:=find_implemented_interface(hd,tobjectdef(resultdef));
if assigned(ImplIntf) then
begin
case ImplIntf.IType of

View File

@ -3241,7 +3241,7 @@ implementation
hd:=tobjectdef(left.resultdef);
while assigned(hd) do
begin
ImplIntf:=hd.find_implemented_interface(tobjectdef(resultdef));
ImplIntf:=find_implemented_interface(hd,tobjectdef(resultdef));
if assigned(ImplIntf) then
begin
case ImplIntf.IType of

View File

@ -321,7 +321,7 @@ implementation
Message1(parser_e_forward_intf_declaration_must_be_resolved,intfdef.objrealname^);
exit;
end;
if current_objectdef.find_implemented_interface(intfdef)<>nil then
if find_implemented_interface(current_objectdef,intfdef)<>nil then
Message1(sym_e_duplicate_id,intfdef.objname^)
else
begin
@ -361,7 +361,7 @@ implementation
Message1(parser_e_forward_intf_declaration_must_be_resolved,intfdef.objrealname^);
exit;
end;
if current_objectdef.find_implemented_interface(intfdef)<>nil then
if find_implemented_interface(current_objectdef,intfdef)<>nil then
Message1(sym_e_duplicate_id,intfdef.objname^)
else
begin

View File

@ -783,7 +783,7 @@ implementation
ImplIntf:=nil;
if (srsym.typ=typesym) and
(ttypesym(srsym).typedef.typ=objectdef) then
ImplIntf:=tobjectdef(astruct).find_implemented_interface(tobjectdef(ttypesym(srsym).typedef));
ImplIntf:=find_implemented_interface(tobjectdef(astruct),tobjectdef(ttypesym(srsym).typedef));
if ImplIntf=nil then
Message(parser_e_interface_id_expected)
else

View File

@ -831,7 +831,7 @@ implementation
end
else if is_class(p.propdef) then
begin
ImplIntf:=tobjectdef(p.propdef).find_implemented_interface(tobjectdef(def));
ImplIntf:=find_implemented_interface(tobjectdef(p.propdef),tobjectdef(def));
if assigned(ImplIntf) then
begin
if compare_defs(ImplIntf.IntfDef,def,nothingn)<te_equal then

View File

@ -63,7 +63,7 @@ uses
{ global }
globals,tokens,verbose,finput,
{ symtable }
symconst,symsym,symtable,
symconst,symsym,symtable,defcmp,
{ modules }
fmodule,
{ pass 1 }
@ -238,7 +238,7 @@ uses
while assigned(objdef) do
begin
intffound:=assigned(
objdef.find_implemented_interface(
find_implemented_interface(objdef,
timplementedinterface(formalobjdef.implementedinterfaces[j]).intfdef
)
);

View File

@ -396,7 +396,6 @@ interface
function alignment:shortint;override;
function vmtmethodoffset(index:longint):longint;
function members_need_inittable : boolean;
function find_implemented_interface(aintfdef:tobjectdef):TImplementedInterface;
{ this should be called when this class implements an interface }
procedure prepareguid;
function is_publishable : boolean;override;
@ -1087,7 +1086,7 @@ implementation
{ target }
systems,paramgr,
{ symtable }
symsym,symtable,defutil,objcdef,defcmp,
symsym,symtable,defutil,objcdef,
{$ifdef jvm}
jvmdef,
{$endif}
@ -6477,26 +6476,6 @@ implementation
end;
function tobjectdef.find_implemented_interface(aintfdef:tobjectdef):TImplementedInterface;
var
ImplIntf : TImplementedInterface;
i : longint;
begin
result:=nil;
if not assigned(ImplementedInterfaces) then
exit;
for i:=0 to ImplementedInterfaces.Count-1 do
begin
ImplIntf:=TImplementedInterface(ImplementedInterfaces[i]);
if equal_defs(implintf.intfdef,aintfdef) then
begin
result:=ImplIntf;
exit;
end;
end;
end;
function tobjectdef.is_publishable : boolean;
begin
is_publishable:=objecttype in [odt_class,odt_interfacecom,odt_interfacecorba,odt_dispinterface];