fcl-passrc: fixed a.specialize b<c>, creating tbinary as parent of tinlinespecializeexpr

git-svn-id: trunk@47242 -
This commit is contained in:
Mattias Gaertner 2020-10-28 20:11:02 +00:00
parent 42e48d016b
commit 20a8b05bee
2 changed files with 30 additions and 15 deletions

View File

@ -4729,14 +4729,6 @@ begin
if not IsNameExpr(El) then exit; if not IsNameExpr(El) then exit;
Parent:=El.Parent; Parent:=El.Parent;
if Parent=nil then exit; if Parent=nil then exit;
if Parent.ClassType=TBinaryExpr then
begin
Bin:=TBinaryExpr(Parent);
if (Bin.OpCode<>eopSubIdent) or (Bin.right<>El) then
exit;
El:=Bin;
Parent:=El.Parent;
end;
if Parent.ClassType=TInlineSpecializeExpr then if Parent.ClassType=TInlineSpecializeExpr then
begin begin
InlineSpec:=TInlineSpecializeExpr(Parent); InlineSpec:=TInlineSpecializeExpr(Parent);
@ -4746,6 +4738,14 @@ begin
Parent:=El.Parent; Parent:=El.Parent;
if Parent=nil then exit; if Parent=nil then exit;
end; end;
if Parent.ClassType=TBinaryExpr then
begin
Bin:=TBinaryExpr(Parent);
if (Bin.OpCode<>eopSubIdent) or (Bin.right<>El) then
exit;
El:=Bin;
Parent:=El.Parent;
end;
if Parent.ClassType<>TParamsExpr then exit; if Parent.ClassType<>TParamsExpr then exit;
Params:=TParamsExpr(Parent); Params:=TParamsExpr(Parent);
if Params.Value<>El then exit; if Params.Value<>El then exit;

View File

@ -2541,21 +2541,36 @@ begin
Expr:=Result; Expr:=Result;
if Expr.Kind=pekBinary then if Expr.Kind=pekBinary then
begin begin
if Expr.OpCode<>eopSubIdent then Bin:=TBinaryExpr(Expr);
if Bin.OpCode<>eopSubIdent then
ParseExcSyntaxError; ParseExcSyntaxError;
Expr:=TBinaryExpr(Expr).right; Expr:=Bin.right;
end; end
else
Bin:=nil;
if Expr.Kind<>pekIdent then if Expr.Kind<>pekIdent then
ParseExcSyntaxError; ParseExcSyntaxError;
// read specialized params // read specialized params
ISE:=TInlineSpecializeExpr(CreateElement(TInlineSpecializeExpr,'',AParent,SrcPos)); if Bin<>nil then
ISE:=TInlineSpecializeExpr(CreateElement(TInlineSpecializeExpr,'',Bin,SrcPos))
else
ISE:=TInlineSpecializeExpr(CreateElement(TInlineSpecializeExpr,'',AParent,SrcPos));
ReadSpecializeArguments(ISE,ISE.Params); ReadSpecializeArguments(ISE,ISE.Params);
// A<B> or something.A<B> // A<B> or something.A<B>
ISE.NameExpr:=Result; ISE.NameExpr:=Expr;
Result.Parent:=ISE; Expr.Parent:=ISE;
Result:=ISE; if Bin<>nil then
begin
// something.A<B>
Bin.Right:=ISE;
end
else
begin
// A<B>
Result:=ISE;
end;
ISE:=nil; ISE:=nil;
CanSpecialize:=aCannot; CanSpecialize:=aCannot;
NextToken; NextToken;