فهرست منبع

* Added new node utility function to search for nodes of a specific type in a node tree

J. Gareth "Curious Kit" Moreton 1 سال پیش
والد
کامیت
a91c1ab627
1فایلهای تغییر یافته به همراه18 افزوده شده و 0 حذف شده
  1. 18 0
      compiler/nutils.pas

+ 18 - 0
compiler/nutils.pas

@@ -210,6 +210,10 @@ interface
     }
     }
     procedure node_reset_pass1_write(n: tnode);
     procedure node_reset_pass1_write(n: tnode);
 
 
+    { Returns True if n one of its children has a type that appears in TypeList }
+    function has_node_of_type(n: TNode; TypeList: TNodeTypeSet): Boolean; {$IFDEF USEINLINE}inline;{$ENDIF USEINLINE}
+
+
 implementation
 implementation
 
 
     uses
     uses
@@ -1760,4 +1764,18 @@ implementation
        end;
        end;
 
 
 
 
+     function node_in_list(var n: tnode; arg: pointer): foreachnoderesult;
+       begin
+         if (n.nodetype in PNodeTypeSet(arg)^) then
+           result := fen_norecurse_true
+         else
+           result := fen_false;
+       end;
+
+
+     function has_node_of_type(n: TNode; TypeList: TNodeTypeSet): Boolean;
+       begin
+         Result := foreachnodestatic(n, @node_in_list, @TypeList);
+       end;
+
 end.
 end.