|
@@ -1038,6 +1038,14 @@ type
|
|
pmNoReturn, pmFar, pmFinal);
|
|
pmNoReturn, pmFar, pmFinal);
|
|
TProcedureModifiers = Set of TProcedureModifier;
|
|
TProcedureModifiers = Set of TProcedureModifier;
|
|
TProcedureMessageType = (pmtNone,pmtInteger,pmtString);
|
|
TProcedureMessageType = (pmtNone,pmtInteger,pmtString);
|
|
|
|
+
|
|
|
|
+ { TProcedureNamePart }
|
|
|
|
+
|
|
|
|
+ TProcedureNamePart = record
|
|
|
|
+ Name: string;
|
|
|
|
+ Templates: TFPList; // optional list of TPasGenericTemplateType, can nil!
|
|
|
|
+ end;
|
|
|
|
+ TProcedureNameParts = array of TProcedureNamePart;
|
|
|
|
|
|
TProcedureBody = class;
|
|
TProcedureBody = class;
|
|
|
|
|
|
@@ -1067,6 +1075,7 @@ type
|
|
AliasName : String;
|
|
AliasName : String;
|
|
ProcType : TPasProcedureType;
|
|
ProcType : TPasProcedureType;
|
|
Body : TProcedureBody;
|
|
Body : TProcedureBody;
|
|
|
|
+ NameParts: TProcedureNameParts; // only used for generic functions
|
|
Procedure AddModifier(AModifier : TProcedureModifier);
|
|
Procedure AddModifier(AModifier : TProcedureModifier);
|
|
Function IsVirtual : Boolean;
|
|
Function IsVirtual : Boolean;
|
|
Function IsDynamic : Boolean;
|
|
Function IsDynamic : Boolean;
|
|
@@ -1080,6 +1089,7 @@ type
|
|
Function IsStatic : Boolean;
|
|
Function IsStatic : Boolean;
|
|
Function IsForward: Boolean;
|
|
Function IsForward: Boolean;
|
|
Function GetProcTypeEnum: TProcType; virtual;
|
|
Function GetProcTypeEnum: TProcType; virtual;
|
|
|
|
+ procedure SetNameParts(var Parts: TProcedureNameParts);
|
|
Property Modifiers : TProcedureModifiers Read FModifiers Write FModifiers;
|
|
Property Modifiers : TProcedureModifiers Read FModifiers Write FModifiers;
|
|
Property CallingConvention : TCallingConvention Read GetCallingConvention Write SetCallingConvention;
|
|
Property CallingConvention : TCallingConvention Read GetCallingConvention Write SetCallingConvention;
|
|
Property MessageName : String Read FMessageName Write FMessageName;
|
|
Property MessageName : String Read FMessageName Write FMessageName;
|
|
@@ -1724,12 +1734,15 @@ const
|
|
= ('cvar', 'external', 'public', 'export', 'class', 'static');
|
|
= ('cvar', 'external', 'public', 'export', 'class', 'static');
|
|
|
|
|
|
procedure ReleaseAndNil(var El: TPasElement {$IFDEF CheckPasTreeRefCount}; const Id: string{$ENDIF}); overload;
|
|
procedure ReleaseAndNil(var El: TPasElement {$IFDEF CheckPasTreeRefCount}; const Id: string{$ENDIF}); overload;
|
|
|
|
+function GenericTemplateTypesAsString(List: TFPList): string;
|
|
|
|
|
|
{$IFDEF HasPTDumpStack}
|
|
{$IFDEF HasPTDumpStack}
|
|
procedure PTDumpStack;
|
|
procedure PTDumpStack;
|
|
function GetPTDumpStack: string;
|
|
function GetPTDumpStack: string;
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
+procedure ReleaseProcNameParts(var NameParts: TProcedureNameParts);
|
|
|
|
+
|
|
implementation
|
|
implementation
|
|
|
|
|
|
uses SysUtils;
|
|
uses SysUtils;
|
|
@@ -1742,6 +1755,54 @@ begin
|
|
El:=nil;
|
|
El:=nil;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function GenericTemplateTypesAsString(List: TFPList): string;
|
|
|
|
+var
|
|
|
|
+ i, j: Integer;
|
|
|
|
+ T: TPasGenericTemplateType;
|
|
|
|
+begin
|
|
|
|
+ Result:='';
|
|
|
|
+ for i:=0 to List.Count-1 do
|
|
|
|
+ begin
|
|
|
|
+ if i>0 then
|
|
|
|
+ Result:=Result+',';
|
|
|
|
+ T:=TPasGenericTemplateType(List[i]);
|
|
|
|
+ Result:=Result+T.Name;
|
|
|
|
+ if length(T.Constraints)>0 then
|
|
|
|
+ begin
|
|
|
|
+ Result:=Result+':';
|
|
|
|
+ for j:=0 to length(T.Constraints)-1 do
|
|
|
|
+ begin
|
|
|
|
+ if j>0 then
|
|
|
|
+ Result:=Result+',';
|
|
|
|
+ Result:=Result+T.GetDeclaration(false);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ Result:='<'+Result+'>';
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure ReleaseProcNameParts(var NameParts: TProcedureNameParts);
|
|
|
|
+var
|
|
|
|
+ El: TPasElement;
|
|
|
|
+ i, j: Integer;
|
|
|
|
+begin
|
|
|
|
+ for i := 0 to length(NameParts)-1 do
|
|
|
|
+ begin
|
|
|
|
+ with NameParts[i] do
|
|
|
|
+ if Templates<>nil then
|
|
|
|
+ begin
|
|
|
|
+ for j:=0 to Templates.Count-1 do
|
|
|
|
+ begin
|
|
|
|
+ El:=TPasGenericTemplateType(Templates[j]);
|
|
|
|
+ El.Parent:=nil;
|
|
|
|
+ El.Release{$IFDEF CheckPasTreeRefCount}('TPasProcedure.NameParts'){$ENDIF};
|
|
|
|
+ end;
|
|
|
|
+ Templates.Free;
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ NameParts:=nil;
|
|
|
|
+end;
|
|
|
|
+
|
|
Function IndentStrings(S : TStrings; indent : Integer) : string;
|
|
Function IndentStrings(S : TStrings; indent : Integer) : string;
|
|
Var
|
|
Var
|
|
I,CurrLen,CurrPos : Integer;
|
|
I,CurrLen,CurrPos : Integer;
|
|
@@ -3496,6 +3557,7 @@ begin
|
|
ReleaseAndNil(TPasElement(MessageExpr){$IFDEF CheckPasTreeRefCount},'TPasProcedure.MessageExpr'{$ENDIF});
|
|
ReleaseAndNil(TPasElement(MessageExpr){$IFDEF CheckPasTreeRefCount},'TPasProcedure.MessageExpr'{$ENDIF});
|
|
ReleaseAndNil(TPasElement(ProcType){$IFDEF CheckPasTreeRefCount},'TPasProcedure.ProcType'{$ENDIF});
|
|
ReleaseAndNil(TPasElement(ProcType){$IFDEF CheckPasTreeRefCount},'TPasProcedure.ProcType'{$ENDIF});
|
|
ReleaseAndNil(TPasElement(Body){$IFDEF CheckPasTreeRefCount},'TPasProcedure.Body'{$ENDIF});
|
|
ReleaseAndNil(TPasElement(Body){$IFDEF CheckPasTreeRefCount},'TPasProcedure.Body'{$ENDIF});
|
|
|
|
+ ReleaseProcNameParts(NameParts);
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -4164,7 +4226,7 @@ var
|
|
begin
|
|
begin
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
for i:=0 to GenericTemplateTypes.Count-1 do
|
|
for i:=0 to GenericTemplateTypes.Count-1 do
|
|
- ForEachChildCall(aMethodCall,Arg,TPasElement(GenericTemplateTypes[i]),true);
|
|
|
|
|
|
+ ForEachChildCall(aMethodCall,Arg,TPasElement(GenericTemplateTypes[i]),false);
|
|
for i:=0 to Members.Count-1 do
|
|
for i:=0 to Members.Count-1 do
|
|
ForEachChildCall(aMethodCall,Arg,TPasElement(Members[i]),false);
|
|
ForEachChildCall(aMethodCall,Arg,TPasElement(Members[i]),false);
|
|
end;
|
|
end;
|
|
@@ -4256,7 +4318,12 @@ begin
|
|
else
|
|
else
|
|
Temp:='packed '+Temp;
|
|
Temp:='packed '+Temp;
|
|
If Full and (Name<>'') then
|
|
If Full and (Name<>'') then
|
|
- Temp:=Name+' = '+Temp;
|
|
|
|
|
|
+ begin
|
|
|
|
+ if GenericTemplateTypes.Count>0 then
|
|
|
|
+ Temp:=Name+GenericTemplateTypesAsString(GenericTemplateTypes)+' = '+Temp
|
|
|
|
+ else
|
|
|
|
+ Temp:=Name+' = '+Temp;
|
|
|
|
+ end;
|
|
S.Add(Temp);
|
|
S.Add(Temp);
|
|
GetMembers(S);
|
|
GetMembers(S);
|
|
S.Add('end');
|
|
S.Add('end');
|
|
@@ -4562,8 +4629,15 @@ end;
|
|
|
|
|
|
procedure TPasProcedure.ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
procedure TPasProcedure.ForEachCall(const aMethodCall: TOnForEachPasElement;
|
|
const Arg: Pointer);
|
|
const Arg: Pointer);
|
|
|
|
+var
|
|
|
|
+ i, j: Integer;
|
|
begin
|
|
begin
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
inherited ForEachCall(aMethodCall, Arg);
|
|
|
|
+ for i:=0 to length(NameParts)-1 do
|
|
|
|
+ with NameParts[i] do
|
|
|
|
+ if Templates<>nil then
|
|
|
|
+ for j:=0 to Templates.Count-1 do
|
|
|
|
+ ForEachChildCall(aMethodCall,Arg,TPasElement(Templates[i]),false);
|
|
ForEachChildCall(aMethodCall,Arg,ProcType,false);
|
|
ForEachChildCall(aMethodCall,Arg,ProcType,false);
|
|
ForEachChildCall(aMethodCall,Arg,PublicName,false);
|
|
ForEachChildCall(aMethodCall,Arg,PublicName,false);
|
|
ForEachChildCall(aMethodCall,Arg,LibraryExpr,false);
|
|
ForEachChildCall(aMethodCall,Arg,LibraryExpr,false);
|
|
@@ -4573,7 +4647,6 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TPasProcedure.AddModifier(AModifier: TProcedureModifier);
|
|
procedure TPasProcedure.AddModifier(AModifier: TProcedureModifier);
|
|
-
|
|
|
|
begin
|
|
begin
|
|
Include(FModifiers,AModifier);
|
|
Include(FModifiers,AModifier);
|
|
end;
|
|
end;
|
|
@@ -4639,17 +4712,52 @@ begin
|
|
Result:=ptProcedure;
|
|
Result:=ptProcedure;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPasProcedure.SetNameParts(var Parts: TProcedureNameParts);
|
|
|
|
+var
|
|
|
|
+ i, j: Integer;
|
|
|
|
+ El: TPasElement;
|
|
|
|
+begin
|
|
|
|
+ if length(NameParts)>0 then
|
|
|
|
+ ReleaseProcNameParts(NameParts);
|
|
|
|
+ NameParts:=Parts;
|
|
|
|
+ Parts:=nil;
|
|
|
|
+ for i:=0 to length(NameParts)-1 do
|
|
|
|
+ with NameParts[i] do
|
|
|
|
+ if Templates<>nil then
|
|
|
|
+ for j:=0 to Templates.Count-1 do
|
|
|
|
+ begin
|
|
|
|
+ El:=TPasElement(Templates[j]);
|
|
|
|
+ El.Parent:=Self;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TPasProcedure.GetDeclaration(full: Boolean): string;
|
|
function TPasProcedure.GetDeclaration(full: Boolean): string;
|
|
Var
|
|
Var
|
|
S : TStringList;
|
|
S : TStringList;
|
|
T: String;
|
|
T: String;
|
|
|
|
+ i: Integer;
|
|
begin
|
|
begin
|
|
S:=TStringList.Create;
|
|
S:=TStringList.Create;
|
|
try
|
|
try
|
|
If Full then
|
|
If Full then
|
|
begin
|
|
begin
|
|
T:=TypeName;
|
|
T:=TypeName;
|
|
- if Name<>'' then
|
|
|
|
|
|
+ if length(NameParts)>0 then
|
|
|
|
+ begin
|
|
|
|
+ T:=T+' ';
|
|
|
|
+ for i:=0 to length(NameParts)-1 do
|
|
|
|
+ begin
|
|
|
|
+ if i>0 then
|
|
|
|
+ T:=T+'.';
|
|
|
|
+ with NameParts[i] do
|
|
|
|
+ begin
|
|
|
|
+ T:=T+Name;
|
|
|
|
+ if Templates<>nil then
|
|
|
|
+ T:=T+GenericTemplateTypesAsString(Templates);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ end
|
|
|
|
+ else if Name<>'' then
|
|
T:=T+' '+Name;
|
|
T:=T+' '+Name;
|
|
S.Add(T);
|
|
S.Add(T);
|
|
end;
|
|
end;
|