|
@@ -54,6 +54,7 @@ type
|
|
procedure AddRef;
|
|
procedure AddRef;
|
|
procedure DecRef;
|
|
procedure DecRef;
|
|
procedure SetExtUsed(ExtDef: TDef; AUsed: boolean; var HasRef: boolean);
|
|
procedure SetExtUsed(ExtDef: TDef; AUsed: boolean; var HasRef: boolean);
|
|
|
|
+ function ShouldUseChild(d: TDef): boolean; virtual;
|
|
public
|
|
public
|
|
DefType: TDefType;
|
|
DefType: TDefType;
|
|
DefId: integer;
|
|
DefId: integer;
|
|
@@ -87,6 +88,7 @@ type
|
|
FHasClassRef: boolean;
|
|
FHasClassRef: boolean;
|
|
protected
|
|
protected
|
|
procedure SetIsUsed(const AValue: boolean); override;
|
|
procedure SetIsUsed(const AValue: boolean); override;
|
|
|
|
+ function ShouldUseChild(d: TDef): boolean; override;
|
|
public
|
|
public
|
|
CType: TClassType;
|
|
CType: TClassType;
|
|
AncestorClass: TClassDef;
|
|
AncestorClass: TClassDef;
|
|
@@ -169,6 +171,7 @@ type
|
|
FHasRetTypeRef: boolean;
|
|
FHasRetTypeRef: boolean;
|
|
protected
|
|
protected
|
|
procedure SetIsUsed(const AValue: boolean); override;
|
|
procedure SetIsUsed(const AValue: boolean); override;
|
|
|
|
+ function ShouldUseChild(d: TDef): boolean; override;
|
|
public
|
|
public
|
|
ProcType: TProcType;
|
|
ProcType: TProcType;
|
|
ReturnType: TDef;
|
|
ReturnType: TDef;
|
|
@@ -224,6 +227,9 @@ type
|
|
const
|
|
const
|
|
ReplDefs = [dtField, dtProp, dtProc];
|
|
ReplDefs = [dtField, dtProp, dtProc];
|
|
|
|
|
|
|
|
+var
|
|
|
|
+ OnCanUseDef: function (def, refdef: TDef): boolean;
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
function IsSameType(t1, t2: TDef): boolean;
|
|
function IsSameType(t1, t2: TDef): boolean;
|
|
@@ -370,6 +376,11 @@ begin
|
|
SetExtUsed(ReturnType, AValue, FHasRetTypeRef);
|
|
SetExtUsed(ReturnType, AValue, FHasRetTypeRef);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TProcDef.ShouldUseChild(d: TDef): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=d.DefType in [dtParam];
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TProcDef.ResolveDefs;
|
|
procedure TProcDef.ResolveDefs;
|
|
begin
|
|
begin
|
|
inherited ResolveDefs;
|
|
inherited ResolveDefs;
|
|
@@ -407,6 +418,11 @@ begin
|
|
SetExtUsed(AncestorClass, AValue, FHasClassRef);
|
|
SetExtUsed(AncestorClass, AValue, FHasClassRef);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TClassDef.ShouldUseChild(d: TDef): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=d.DefType in [dtProc, dtField, dtProp];
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TClassDef.ResolveDefs;
|
|
procedure TClassDef.ResolveDefs;
|
|
begin
|
|
begin
|
|
inherited ResolveDefs;
|
|
inherited ResolveDefs;
|
|
@@ -486,10 +502,13 @@ procedure TDef.SetIsUsed(const AValue: boolean);
|
|
var
|
|
var
|
|
i: integer;
|
|
i: integer;
|
|
f: boolean;
|
|
f: boolean;
|
|
|
|
+ d: TDef;
|
|
begin
|
|
begin
|
|
if FInSetUsed or (DefType = dtNone) or IsPrivate then
|
|
if FInSetUsed or (DefType = dtNone) or IsPrivate then
|
|
exit;
|
|
exit;
|
|
if AValue then begin
|
|
if AValue then begin
|
|
|
|
+ if Assigned(OnCanUseDef) and not OnCanUseDef(Self, Parent) then
|
|
|
|
+ exit;
|
|
AddRef;
|
|
AddRef;
|
|
f:=FRefCnt = 1;
|
|
f:=FRefCnt = 1;
|
|
end
|
|
end
|
|
@@ -503,8 +522,11 @@ begin
|
|
// Update used mark of children only once
|
|
// Update used mark of children only once
|
|
FInSetUsed:=True;
|
|
FInSetUsed:=True;
|
|
try
|
|
try
|
|
- for i:=0 to Count - 1 do
|
|
|
|
- Items[i].IsUsed:=AValue;
|
|
|
|
|
|
+ for i:=0 to Count - 1 do begin
|
|
|
|
+ d:=Items[i];
|
|
|
|
+ if ShouldUseChild(d) then
|
|
|
|
+ d.IsUsed:=AValue;
|
|
|
|
+ end;
|
|
finally
|
|
finally
|
|
FInSetUsed:=False;
|
|
FInSetUsed:=False;
|
|
end;
|
|
end;
|
|
@@ -550,6 +572,8 @@ begin
|
|
if AUsed then begin
|
|
if AUsed then begin
|
|
if HasRef then
|
|
if HasRef then
|
|
exit;
|
|
exit;
|
|
|
|
+ if Assigned(OnCanUseDef) and not OnCanUseDef(ExtDef, Self) then
|
|
|
|
+ exit;
|
|
OldRefCnt:=ExtDef.RefCnt;
|
|
OldRefCnt:=ExtDef.RefCnt;
|
|
ExtDef.IsUsed:=True;
|
|
ExtDef.IsUsed:=True;
|
|
HasRef:=OldRefCnt <> ExtDef.RefCnt;
|
|
HasRef:=OldRefCnt <> ExtDef.RefCnt;
|
|
@@ -561,6 +585,11 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TDef.ShouldUseChild(d: TDef): boolean;
|
|
|
|
+begin
|
|
|
|
+ Result:=True;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TDef.SetItem(Index: Integer; const AValue: TDef);
|
|
procedure TDef.SetItem(Index: Integer; const AValue: TDef);
|
|
begin
|
|
begin
|
|
CheckItems;
|
|
CheckItems;
|