Browse Source

* Flags specific to TAssignmentNode have been moved to their own field

J. Gareth "Curious Kit" Moreton 1 year ago
parent
commit
ecc16278f0
6 changed files with 44 additions and 13 deletions
  1. 4 4
      compiler/nadd.pas
  2. 1 1
      compiler/ncal.pas
  3. 1 1
      compiler/ncgld.pas
  4. 36 2
      compiler/nld.pas
  5. 0 3
      compiler/node.pas
  6. 2 2
      compiler/nopt.pas

+ 4 - 4
compiler/nadd.pas

@@ -2002,7 +2002,7 @@ implementation
                         elem,nil)));
 
             result:=cinlinenode.create(in_insert_x_y_z,false,para);
-            include(aktassignmentnode.flags,nf_assign_done_in_right);
+            include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
           end;
 
       begin
@@ -3402,7 +3402,7 @@ implementation
                             'fpc_'+tstringdef(resultdef).stringtypname+'_concat',
                             para
                           );
-                  include(aktassignmentnode.flags,nf_assign_done_in_right);
+                  include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
                   firstpass(result);
                 end
               else
@@ -3546,7 +3546,7 @@ implementation
               left:=nil;
               right:=nil;
 
-              include(aktassignmentnode.flags,nf_assign_done_in_right);
+              include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
               firstpass(result);
             end
           else
@@ -3759,7 +3759,7 @@ implementation
                             'fpc_dynarray_concat',
                             para
                           );
-                  include(aktassignmentnode.flags,nf_assign_done_in_right);
+                  include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
                   firstpass(result);
                 end
               else

+ 1 - 1
compiler/ncal.pas

@@ -3466,7 +3466,7 @@ implementation
                 funcretnode:=aktassignmentnode.left.getcopy;
                 include(funcretnode.flags,nf_is_funcret);
                 { notify the assignment node that the assignment can be removed }
-                include(aktassignmentnode.flags,nf_assign_done_in_right);
+                include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
               end
             else
               begin

+ 1 - 1
compiler/ncgld.pas

@@ -807,7 +807,7 @@ implementation
                (right.nodetype in [blockn,calln]) then
               begin
                 { verify that we indeed have nothing to do }
-                if not(nf_assign_done_in_right in flags) then
+                if not(anf_assign_done_in_right in assignmentnodeflags) then
                   internalerror(2015042201);
               end
             { empty constant string }

+ 36 - 2
compiler/nld.pas

@@ -85,10 +85,17 @@ interface
        { different assignment types }
        tassigntype = (at_normal,at_plus,at_minus,at_star,at_slash);
 
+       TAssignmentNodeFlag = (
+         anf_assign_done_in_right
+       );
+
+       TAssignmentNodeFlags = set of TAssignmentNodeFlag;
+
        tassignmentnode = class(tbinarynode)
          protected
           function direct_shortstring_assignment: boolean; virtual;
          public
+          assignmentnodeflags: TAssignmentNodeFlags;
           assigntype : tassigntype;
           constructor create(l,r : tnode);virtual;
           { no checks for validity of assignment }
@@ -104,6 +111,7 @@ interface
        {$endif state_tracking}
           function docompare(p: tnode): boolean; override;
 {$ifdef DEBUG_NODE_XML}
+          procedure XMLPrintNodeInfo(var T: Text); override;
           procedure XMLPrintNodeData(var T: Text); override;
 {$endif DEBUG_NODE_XML}
        end;
@@ -616,6 +624,7 @@ implementation
 
       begin
          inherited create(assignn,l,r);
+         assignmentnodeflags := [];
          assigntype:=at_normal;
          if r.nodetype = typeconvn then
            ttypeconvnode(r).warn_pointer_to_signed:=false;
@@ -632,6 +641,7 @@ implementation
     constructor tassignmentnode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
       begin
         inherited ppuload(t,ppufile);
+        ppufile.getset(tppuset1(assignmentnodeflags));
         assigntype:=tassigntype(ppufile.getbyte);
       end;
 
@@ -639,6 +649,7 @@ implementation
     procedure tassignmentnode.ppuwrite(ppufile:tcompilerppufile);
       begin
         inherited ppuwrite(ppufile);
+        ppufile.putset(tppuset1(assignmentnodeflags));
         ppufile.putbyte(byte(assigntype));
       end;
 
@@ -650,6 +661,7 @@ implementation
 
       begin
          n:=tassignmentnode(inherited dogetcopy);
+         n.assignmentnodeflags := assignmentnodeflags;
          n.assigntype:=assigntype;
          result:=n;
       end;
@@ -707,7 +719,7 @@ implementation
           exit;
 
         { just in case the typecheckpass of right optimized something here }
-        if nf_assign_done_in_right in flags then
+        if anf_assign_done_in_right in assignmentnodeflags then
           begin
             result:=right;
             right:=nil;
@@ -916,7 +928,7 @@ implementation
          aktassignmentnode:=self;
          firstpass(right);
          aktassignmentnode:=oldassignmentnode;
-         if nf_assign_done_in_right in flags then
+         if anf_assign_done_in_right in assignmentnodeflags then
            begin
              result:=right;
              right:=nil;
@@ -1079,6 +1091,28 @@ implementation
 
 
 {$ifdef DEBUG_NODE_XML}
+    procedure TAssignmentNode.XMLPrintNodeInfo(var T: Text);
+      var
+        i: TAssignmentNodeFlag;
+        First: Boolean;
+      begin
+        inherited XMLPrintNodeInfo(T);
+        First := True;
+        for i in assignmentnodeflags do
+          begin
+            if First then
+              begin
+                Write(T, ' assignmentnodeflags="', i);
+                First := False;
+              end
+            else
+              Write(T, ',', i)
+          end;
+        if not First then
+          Write(T, '"');
+      end;
+
+
     procedure TAssignmentNode.XMLPrintNodeData(var T: Text);
       begin
         { For assignments, put the left and right branches on the same level for clarity }

+ 0 - 3
compiler/node.pas

@@ -243,9 +243,6 @@ interface
          { if the result type of a node is currency, then this flag denotes, that the value is already mulitplied by 10000 }
          nf_is_currency,
 
-         { tassignmentnode }
-         nf_assign_done_in_right,
-
          { tarrayconstructnode }
          nf_forcevaria,
          nf_novariaallowed,

+ 2 - 2
compiler/nopt.pas

@@ -370,7 +370,7 @@ begin
                 'fpc_'+tstringdef(p.resultdef).stringtypname+'_concat_multi',
                 para
               );
-      include(aktassignmentnode.flags,nf_assign_done_in_right);
+      include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
     end
   else
     begin
@@ -469,7 +469,7 @@ begin
                 'fpc_dynarray_concat_multi',
                 para
               );
-      include(aktassignmentnode.flags,nf_assign_done_in_right);
+      include(aktassignmentnode.assignmentnodeflags,anf_assign_done_in_right);
     end
   else
     begin