mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-17 12:39:25 +02:00
* Added new node utility function to search for nodes of a specific type in a node tree
This commit is contained in:
parent
04b0dfc812
commit
a91c1ab627
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user