|
@@ -133,6 +133,7 @@ type
|
|
FHintMessage : String;
|
|
FHintMessage : String;
|
|
protected
|
|
protected
|
|
procedure ProcessHints(const ASemiColonPrefix: boolean; var AResult: string); virtual;
|
|
procedure ProcessHints(const ASemiColonPrefix: boolean; var AResult: string); virtual;
|
|
|
|
+ procedure SetParent(const AValue: TPasElement); virtual;
|
|
public
|
|
public
|
|
SourceFilename: string;
|
|
SourceFilename: string;
|
|
SourceLinenumber: Integer;
|
|
SourceLinenumber: Integer;
|
|
@@ -156,10 +157,11 @@ type
|
|
Function HintsString : String;
|
|
Function HintsString : String;
|
|
function GetDeclaration(full : Boolean) : string; virtual;
|
|
function GetDeclaration(full : Boolean) : string; virtual;
|
|
procedure Accept(Visitor: TPassTreeVisitor); override;
|
|
procedure Accept(Visitor: TPassTreeVisitor); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); virtual;
|
|
function HasParent(aParent: TPasElement): boolean;
|
|
function HasParent(aParent: TPasElement): boolean;
|
|
property RefCount: LongWord read FRefCount;
|
|
property RefCount: LongWord read FRefCount;
|
|
property Name: string read FName write FName;
|
|
property Name: string read FName write FName;
|
|
- property Parent: TPasElement read FParent Write FParent;
|
|
|
|
|
|
+ property Parent: TPasElement read FParent Write SetParent;
|
|
Property Hints : TPasMemberHints Read FHints Write FHints;
|
|
Property Hints : TPasMemberHints Read FHints Write FHints;
|
|
Property HintMessage : String Read FHintMessage Write FHintMessage;
|
|
Property HintMessage : String Read FHintMessage Write FHintMessage;
|
|
Property DocComment : String Read FDocComment Write FDocComment;
|
|
Property DocComment : String Read FDocComment Write FDocComment;
|
|
@@ -478,12 +480,15 @@ type
|
|
{ TPasAliasType }
|
|
{ TPasAliasType }
|
|
|
|
|
|
TPasAliasType = class(TPasType)
|
|
TPasAliasType = class(TPasType)
|
|
|
|
+ protected
|
|
|
|
+ procedure SetParent(const AValue: TPasElement); override;
|
|
public
|
|
public
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
function ElementTypeName: string; override;
|
|
function ElementTypeName: string; override;
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
DestType: TPasType;
|
|
DestType: TPasType;
|
|
Expr: TPasExpr;
|
|
Expr: TPasExpr;
|
|
@@ -492,12 +497,15 @@ type
|
|
{ TPasPointerType - todo: change it TPasAliasType }
|
|
{ TPasPointerType - todo: change it TPasAliasType }
|
|
|
|
|
|
TPasPointerType = class(TPasType)
|
|
TPasPointerType = class(TPasType)
|
|
|
|
+ protected
|
|
|
|
+ procedure SetParent(const AValue: TPasElement); override;
|
|
public
|
|
public
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
function ElementTypeName: string; override;
|
|
function ElementTypeName: string; override;
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
DestType: TPasType;
|
|
DestType: TPasType;
|
|
end;
|
|
end;
|
|
@@ -539,6 +547,7 @@ type
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
function GetDeclaration(full : Boolean): string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
DestType: TPasType;
|
|
DestType: TPasType;
|
|
end;
|
|
end;
|
|
@@ -657,7 +666,10 @@ type
|
|
|
|
|
|
TPasRecordType = class(TPasType)
|
|
TPasRecordType = class(TPasType)
|
|
private
|
|
private
|
|
|
|
+ procedure ClearChildReferences(El: TPasElement; arg: pointer);
|
|
procedure GetMembers(S: TStrings);
|
|
procedure GetMembers(S: TStrings);
|
|
|
|
+ protected
|
|
|
|
+ procedure SetParent(const AValue: TPasElement); override;
|
|
public
|
|
public
|
|
constructor Create(const AName: string; AParent: TPasElement); override;
|
|
constructor Create(const AName: string; AParent: TPasElement); override;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -693,6 +705,10 @@ type
|
|
{ TPasClassType }
|
|
{ TPasClassType }
|
|
|
|
|
|
TPasClassType = class(TPasType)
|
|
TPasClassType = class(TPasType)
|
|
|
|
+ private
|
|
|
|
+ procedure ClearChildReferences(El: TPasElement; arg: pointer);
|
|
|
|
+ protected
|
|
|
|
+ procedure SetParent(const AValue: TPasElement); override;
|
|
public
|
|
public
|
|
constructor Create(const AName: string; AParent: TPasElement); override;
|
|
constructor Create(const AName: string; AParent: TPasElement); override;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -739,6 +755,7 @@ type
|
|
function GetDeclaration(full : boolean) : string; override;
|
|
function GetDeclaration(full : boolean) : string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
Access: TArgumentAccess;
|
|
Access: TArgumentAccess;
|
|
ArgType: TPasType; // can be nil, when Access<>argDefault
|
|
ArgType: TPasType; // can be nil, when Access<>argDefault
|
|
@@ -784,6 +801,7 @@ type
|
|
function ElementTypeName : string; override;
|
|
function ElementTypeName : string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
ResultType: TPasType;
|
|
ResultType: TPasType;
|
|
end;
|
|
end;
|
|
@@ -849,6 +867,7 @@ type
|
|
function GetDeclaration(full : boolean) : string; override;
|
|
function GetDeclaration(full : boolean) : string; override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
VarType: TPasType;
|
|
VarType: TPasType;
|
|
VarModifiers : TVariableModifiers;
|
|
VarModifiers : TVariableModifiers;
|
|
@@ -1460,6 +1479,7 @@ Type
|
|
procedure AddElement(Element: TPasImplElement); override;
|
|
procedure AddElement(Element: TPasImplElement); override;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer); override;
|
|
const Arg: Pointer); override;
|
|
|
|
+ procedure ClearTypeReferences(aType: TPasElement); override;
|
|
public
|
|
public
|
|
VarEl: TPasVariable; // can be nil
|
|
VarEl: TPasVariable; // can be nil
|
|
TypeEl : TPasType;
|
|
TypeEl : TPasType;
|
|
@@ -1662,6 +1682,12 @@ begin
|
|
DestType.ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
DestType.ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TInlineTypeExpr.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if DestType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(DestType));
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TPasSpecializeType }
|
|
{ TPasSpecializeType }
|
|
|
|
|
|
constructor TPasSpecializeType.Create(const AName: string; AParent: TPasElement
|
|
constructor TPasSpecializeType.Create(const AName: string; AParent: TPasElement
|
|
@@ -2074,6 +2100,12 @@ begin
|
|
ForEachChildCall(aMethodCall,Arg,ResultType,true);
|
|
ForEachChildCall(aMethodCall,Arg,ResultType,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasResultElement.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if ResultType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(ResultType));
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasFunctionType.ElementTypeName: string; begin Result := SPasTreeFunctionType end;
|
|
function TPasFunctionType.ElementTypeName: string; begin Result := SPasTreeFunctionType end;
|
|
function TPasUnresolvedTypeRef.ElementTypeName: string; begin Result := SPasTreeUnresolvedTypeRef end;
|
|
function TPasUnresolvedTypeRef.ElementTypeName: string; begin Result := SPasTreeUnresolvedTypeRef end;
|
|
function TPasVariable.ElementTypeName: string; begin Result := SPasTreeVariable end;
|
|
function TPasVariable.ElementTypeName: string; begin Result := SPasTreeVariable end;
|
|
@@ -2208,6 +2240,11 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasElement.SetParent(const AValue: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ FParent:=AValue;
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TPasElement.Create(const AName: string; AParent: TPasElement);
|
|
constructor TPasElement.Create(const AName: string; AParent: TPasElement);
|
|
begin
|
|
begin
|
|
inherited Create;
|
|
inherited Create;
|
|
@@ -2372,6 +2409,11 @@ begin
|
|
Visitor.Visit(Self);
|
|
Visitor.Visit(Self);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasElement.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if aType=nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasElement.HasParent(aParent: TPasElement): boolean;
|
|
function TPasElement.HasParent(aParent: TPasElement): boolean;
|
|
var
|
|
var
|
|
El: TPasElement;
|
|
El: TPasElement;
|
|
@@ -2402,6 +2444,7 @@ end;
|
|
destructor TPasDeclarations.Destroy;
|
|
destructor TPasDeclarations.Destroy;
|
|
var
|
|
var
|
|
i: Integer;
|
|
i: Integer;
|
|
|
|
+ Child: TPasElement;
|
|
begin
|
|
begin
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy START');{$ENDIF}
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy START');{$ENDIF}
|
|
FreeAndNil(ExportSymbols);
|
|
FreeAndNil(ExportSymbols);
|
|
@@ -2414,7 +2457,11 @@ begin
|
|
FreeAndNil(ResStrings);
|
|
FreeAndNil(ResStrings);
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy Declarations');{$ENDIF}
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy Declarations');{$ENDIF}
|
|
for i := 0 to Declarations.Count - 1 do
|
|
for i := 0 to Declarations.Count - 1 do
|
|
- TPasElement(Declarations[i]).Release;
|
|
|
|
|
|
+ begin
|
|
|
|
+ Child:=TPasElement(Declarations[i]);
|
|
|
|
+ Child.Parent:=nil;
|
|
|
|
+ Child.Release;
|
|
|
|
+ end;
|
|
FreeAndNil(Declarations);
|
|
FreeAndNil(Declarations);
|
|
|
|
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy inherited');{$ENDIF}
|
|
{$IFDEF VerbosePasTreeMem}writeln('TPasDeclarations.Destroy inherited');{$ENDIF}
|
|
@@ -2459,6 +2506,18 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasPointerType.SetParent(const AValue: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if (AValue=nil) and (Parent<>nil) and (DestType<>nil)
|
|
|
|
+ and (DestType.Parent=Parent) then
|
|
|
|
+ begin
|
|
|
|
+ // DestType in same type section can create a loop
|
|
|
|
+ // -> break loop when type section is closed
|
|
|
|
+ DestType.Release;
|
|
|
|
+ DestType:=nil;
|
|
|
|
+ end;
|
|
|
|
+ inherited SetParent(AValue);
|
|
|
|
+end;
|
|
|
|
|
|
destructor TPasPointerType.Destroy;
|
|
destructor TPasPointerType.Destroy;
|
|
begin
|
|
begin
|
|
@@ -2467,6 +2526,18 @@ begin
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasAliasType.SetParent(const AValue: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if (AValue=nil) and (Parent<>nil) and (DestType<>nil)
|
|
|
|
+ and (DestType.Parent=Parent) then
|
|
|
|
+ begin
|
|
|
|
+ // DestType in same type section can create a loop
|
|
|
|
+ // -> break loop when type section is closed
|
|
|
|
+ DestType.Release;
|
|
|
|
+ DestType:=nil;
|
|
|
|
+ end;
|
|
|
|
+ inherited SetParent(AValue);
|
|
|
|
+end;
|
|
|
|
|
|
destructor TPasAliasType.Destroy;
|
|
destructor TPasAliasType.Destroy;
|
|
begin
|
|
begin
|
|
@@ -2628,6 +2699,23 @@ end;
|
|
|
|
|
|
{ TPasClassType }
|
|
{ TPasClassType }
|
|
|
|
|
|
|
|
+procedure TPasClassType.ClearChildReferences(El: TPasElement; arg: pointer);
|
|
|
|
+begin
|
|
|
|
+ El.ClearTypeReferences(Self);
|
|
|
|
+ if arg=nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TPasClassType.SetParent(const AValue: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if (AValue=nil) and (Parent<>nil) then
|
|
|
|
+ begin
|
|
|
|
+ // parent is cleared
|
|
|
|
+ // -> clear all child references to this class (releasing loops)
|
|
|
|
+ ForEachCall(@ClearChildReferences,nil);
|
|
|
|
+ end;
|
|
|
|
+ inherited SetParent(AValue);
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TPasClassType.Create(const AName: string; AParent: TPasElement);
|
|
constructor TPasClassType.Create(const AName: string; AParent: TPasElement);
|
|
begin
|
|
begin
|
|
inherited Create(AName, AParent);
|
|
inherited Create(AName, AParent);
|
|
@@ -2914,6 +3002,7 @@ begin
|
|
ReleaseAndNil(TPasElement(Expr));
|
|
ReleaseAndNil(TPasElement(Expr));
|
|
ReleaseAndNil(TPasElement(LibraryName));
|
|
ReleaseAndNil(TPasElement(LibraryName));
|
|
ReleaseAndNil(TPasElement(ExportName));
|
|
ReleaseAndNil(TPasElement(ExportName));
|
|
|
|
+ ReleaseAndNil(TPasElement(AbsoluteExpr));
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -3422,6 +3511,12 @@ begin
|
|
ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasPointerType.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if DestType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(DestType));
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasAliasType.GetDeclaration(full: Boolean): string;
|
|
function TPasAliasType.GetDeclaration(full: Boolean): string;
|
|
begin
|
|
begin
|
|
Result:=DestType.Name;
|
|
Result:=DestType.Name;
|
|
@@ -3436,6 +3531,12 @@ begin
|
|
ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
ForEachChildCall(aMethodCall,Arg,DestType,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasAliasType.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if DestType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(DestType));
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasClassOfType.GetDeclaration (full : boolean) : string;
|
|
function TPasClassOfType.GetDeclaration (full : boolean) : string;
|
|
begin
|
|
begin
|
|
Result:='Class of '+DestType.Name;
|
|
Result:='Class of '+DestType.Name;
|
|
@@ -3625,6 +3726,12 @@ begin
|
|
ForEachChildCall(aMethodCall,Arg,EnumType,true);
|
|
ForEachChildCall(aMethodCall,Arg,EnumType,true);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasRecordType.ClearChildReferences(El: TPasElement; arg: pointer);
|
|
|
|
+begin
|
|
|
|
+ El.ClearTypeReferences(Self);
|
|
|
|
+ if arg=nil then ;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TPasRecordType.GetMembers(S: TStrings);
|
|
procedure TPasRecordType.GetMembers(S: TStrings);
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -3681,6 +3788,17 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasRecordType.SetParent(const AValue: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if (AValue=nil) and (Parent<>nil) then
|
|
|
|
+ begin
|
|
|
|
+ // parent is cleared
|
|
|
|
+ // -> clear all child references to this class (releasing loops)
|
|
|
|
+ ForEachCall(@ClearChildReferences,nil);
|
|
|
|
+ end;
|
|
|
|
+ inherited SetParent(AValue);
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasRecordType.GetDeclaration (full : boolean) : string;
|
|
function TPasRecordType.GetDeclaration (full : boolean) : string;
|
|
|
|
|
|
Var
|
|
Var
|
|
@@ -3877,6 +3995,15 @@ begin
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
ForEachChildCall(aMethodCall,Arg,VarType,true);
|
|
ForEachChildCall(aMethodCall,Arg,VarType,true);
|
|
ForEachChildCall(aMethodCall,Arg,Expr,false);
|
|
ForEachChildCall(aMethodCall,Arg,Expr,false);
|
|
|
|
+ ForEachChildCall(aMethodCall,Arg,LibraryName,false);
|
|
|
|
+ ForEachChildCall(aMethodCall,Arg,ExportName,false);
|
|
|
|
+ ForEachChildCall(aMethodCall,Arg,AbsoluteExpr,false);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TPasVariable.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if VarType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(VarType));
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -4235,6 +4362,12 @@ begin
|
|
ForEachChildCall(aMethodCall,Arg,ValueExpr,false);
|
|
ForEachChildCall(aMethodCall,Arg,ValueExpr,false);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasArgument.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if ArgType=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(ArgType));
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasArgument.Value: String;
|
|
function TPasArgument.Value: String;
|
|
begin
|
|
begin
|
|
If Assigned(ValueExpr) then
|
|
If Assigned(ValueExpr) then
|
|
@@ -4596,6 +4729,12 @@ begin
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasImplExceptOn.ClearTypeReferences(aType: TPasElement);
|
|
|
|
+begin
|
|
|
|
+ if TypeEl=aType then
|
|
|
|
+ ReleaseAndNil(TPasElement(TypeEl));
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasImplExceptOn.VariableName: String;
|
|
function TPasImplExceptOn.VariableName: String;
|
|
begin
|
|
begin
|
|
If assigned(VarEl) then
|
|
If assigned(VarEl) then
|