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

This commit is contained in:
J. Gareth "Curious Kit" Moreton 2024-05-09 21:04:11 +01:00 committed by FPK
parent 04b0dfc812
commit a91c1ab627

View File

@ -210,6 +210,10 @@ interface
}
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
uses
@ -1760,4 +1764,18 @@ implementation
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.