MStatementSearchable

- Added `bool isPresent(Statement statement)`
This commit is contained in:
Tristan B. Velloza Kildaire 2024-05-10 15:04:51 +02:00
parent 217189c8e3
commit 1c827854cd
1 changed files with 27 additions and 0 deletions

View File

@ -30,6 +30,33 @@ public interface MStatementSearchable
* Returns: an array of `Statement` (a `Statement[]`)
*/
public Statement[] search(TypeInfo_Class clazzType);
/**
* Searches to see if a given AST
* node is present.
*
* This basically uses the type
* of the node to search,
* then filters based on that.
*
* Params:
* statement = the AST node
* Returns: `true` if found,
* `false` otherwise
*/
public final bool isPresent(Statement statement)
{
Statement[] typeMatches = search(statement.classinfo);
foreach(Statement stmt; typeMatches)
{
if(stmt == statement)
{
return true;
}
}
return false;
}
}
/**