Browse Source

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

git-svn-id: trunk@47242 -
Mattias Gaertner 4 years ago
parent
commit
20a8b05bee
2 changed files with 30 additions and 15 deletions
  1. 8 8
      packages/fcl-passrc/src/pasresolver.pp
  2. 22 7
      packages/fcl-passrc/src/pparser.pp

+ 8 - 8
packages/fcl-passrc/src/pasresolver.pp

@@ -4729,14 +4729,6 @@ begin
   if not IsNameExpr(El) then exit;
   Parent:=El.Parent;
   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
     begin
     InlineSpec:=TInlineSpecializeExpr(Parent);
@@ -4746,6 +4738,14 @@ begin
     Parent:=El.Parent;
     if Parent=nil then exit;
     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;
   Params:=TParamsExpr(Parent);
   if Params.Value<>El then exit;

+ 22 - 7
packages/fcl-passrc/src/pparser.pp

@@ -2541,21 +2541,36 @@ begin
           Expr:=Result;
           if Expr.Kind=pekBinary then
             begin
-            if Expr.OpCode<>eopSubIdent then
+            Bin:=TBinaryExpr(Expr);
+            if Bin.OpCode<>eopSubIdent then
               ParseExcSyntaxError;
-            Expr:=TBinaryExpr(Expr).right;
-            end;
+            Expr:=Bin.right;
+            end
+          else
+            Bin:=nil;
           if Expr.Kind<>pekIdent then
             ParseExcSyntaxError;
 
           // 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);
 
           // A<B>  or  something.A<B>
-          ISE.NameExpr:=Result;
-          Result.Parent:=ISE;
-          Result:=ISE;
+          ISE.NameExpr:=Expr;
+          Expr.Parent:=ISE;
+          if Bin<>nil then
+            begin
+            // something.A<B>
+            Bin.Right:=ISE;
+            end
+          else
+            begin
+            // A<B>
+            Result:=ISE;
+            end;
           ISE:=nil;
           CanSpecialize:=aCannot;
           NextToken;