|
@@ -1789,6 +1789,7 @@ function GenericTemplateTypesAsString(List: TFPList): string;
|
|
|
procedure ReleaseProcNameParts(var NameParts: TProcedureNameParts);
|
|
|
|
|
|
function dbgs(const s: TProcTypeModifiers): string; overload;
|
|
|
+function WritePasElTree(Expr: TPasExpr; FollowPrefix: string = ''): string;
|
|
|
|
|
|
{$IFDEF HasPTDumpStack}
|
|
|
procedure PTDumpStack;
|
|
@@ -1903,6 +1904,77 @@ begin
|
|
|
Result:='['+Result+']';
|
|
|
end;
|
|
|
|
|
|
+function WritePasElTree(Expr: TPasExpr; FollowPrefix: string): string;
|
|
|
+{ TBinary Kind= OpCode=
|
|
|
+ +Left=TBinary Kind= OpCode=
|
|
|
+ | +Left=TParamsExpr[]
|
|
|
+ | | +Value=Prim Kind= Value=
|
|
|
+ | | +Params[1]=Prim Kind= Value=
|
|
|
+ +Right=Prim
|
|
|
+}
|
|
|
+var
|
|
|
+ C: TClass;
|
|
|
+ s: string;
|
|
|
+ ParamsExpr: TParamsExpr;
|
|
|
+ InlineSpecExpr: TInlineSpecializeExpr;
|
|
|
+ SubEl: TPasElement;
|
|
|
+ ArrayValues: TArrayValues;
|
|
|
+ i: Integer;
|
|
|
+begin
|
|
|
+ if Expr=nil then exit('nil');
|
|
|
+ C:=Expr.ClassType;
|
|
|
+
|
|
|
+ Result:=C.ClassName;
|
|
|
+ str(Expr.Kind,s);
|
|
|
+ Result:=Result+' '+s;
|
|
|
+ str(Expr.OpCode,s);
|
|
|
+ Result:=Result+' '+s;
|
|
|
+
|
|
|
+ if C=TPrimitiveExpr then
|
|
|
+ Result:=Result+' Value="'+TPrimitiveExpr(Expr).Value+'"'
|
|
|
+ else if C=TUnaryExpr then
|
|
|
+ Result:=Result+' Operand='+WritePasElTree(TUnaryExpr(Expr).Operand,FollowPrefix)
|
|
|
+ else if C=TBoolConstExpr then
|
|
|
+ Result:=Result+' Value='+BoolToStr(TBoolConstExpr(Expr).Value,'True','False')
|
|
|
+ else if C=TArrayValues then
|
|
|
+ begin
|
|
|
+ ArrayValues:=TArrayValues(Expr);
|
|
|
+ for i:=0 to length(ArrayValues.Values)-1 do
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Values['+IntToStr(i)+']='+WritePasElTree(ArrayValues.Values[i],FollowPrefix+'| ');
|
|
|
+ end
|
|
|
+ else if C=TBinaryExpr then
|
|
|
+ begin
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Left='+WritePasElTree(TBinaryExpr(Expr).left,FollowPrefix+'| ');
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Right='+WritePasElTree(TBinaryExpr(Expr).right,FollowPrefix+'| ');
|
|
|
+ end
|
|
|
+ else if C=TParamsExpr then
|
|
|
+ begin
|
|
|
+ ParamsExpr:=TParamsExpr(Expr);
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Value='+WritePasElTree(ParamsExpr.Value,FollowPrefix+'| ');
|
|
|
+ for i:=0 to length(ParamsExpr.Params)-1 do
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Params['+IntToStr(i)+']='+WritePasElTree(ParamsExpr.Params[i],FollowPrefix+'| ');
|
|
|
+ end
|
|
|
+ else if C=TInlineSpecializeExpr then
|
|
|
+ begin
|
|
|
+ InlineSpecExpr:=TInlineSpecializeExpr(Expr);
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Name='+WritePasElTree(InlineSpecExpr.NameExpr,FollowPrefix+'| ');
|
|
|
+ if InlineSpecExpr.Params<>nil then
|
|
|
+ for i:=0 to InlineSpecExpr.Params.Count-1 do
|
|
|
+ begin
|
|
|
+ Result:=Result+sLineBreak+FollowPrefix+'+Params['+IntToStr(i)+']=';
|
|
|
+ SubEl:=TPasElement(InlineSpecExpr.Params[i]);
|
|
|
+ if SubEl=nil then
|
|
|
+ Result:=Result+'nil'
|
|
|
+ else if SubEl is TPasExpr then
|
|
|
+ Result:=Result+WritePasElTree(TPasExpr(SubEl),FollowPrefix+'| ')
|
|
|
+ else
|
|
|
+ Result:=Result+SubEl.Name+':'+SubEl.ClassName;
|
|
|
+ end;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ Result:=C.ClassName+' Kind=';
|
|
|
+end;
|
|
|
+
|
|
|
Function IndentStrings(S : TStrings; indent : Integer) : string;
|
|
|
Var
|
|
|
I,CurrLen,CurrPos : Integer;
|