From b04060af80078f9cd60bf310dced24056b168052 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 21 Mar 2021 22:01:38 +0200 Subject: [PATCH] Added getAllOf(Type) function --- source/tlang/compiler/symbols.d | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/tlang/compiler/symbols.d b/source/tlang/compiler/symbols.d index 2a8532e..6dc2159 100644 --- a/source/tlang/compiler/symbols.d +++ b/source/tlang/compiler/symbols.d @@ -341,6 +341,22 @@ public class Program statements ~= statement; } + public StatementType[] getAllOf(StatementType)(StatementType) + { + StatementType[] statementsMatched; + + foreach(Statement statement; statements) + { + /* TODO: Remove null, this is for unimpemented */ + if(statement !is null && typeid(statement) == typeid(StatementType)) + { + statementsMatched ~= cast(StatementType)statement; + } + } + + return statementsMatched; + } + public Variable[] getGlobals() { Variable[] variables;