From edb11df24743e6058543ba6f4cb1fa210d89b59b Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 7 Jun 2021 11:14:22 +0200 Subject: [PATCH] Added method to print dependencies of the given Container --- source/tlang/compiler/typecheck/dependancy.d | 34 +++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/source/tlang/compiler/typecheck/dependancy.d b/source/tlang/compiler/typecheck/dependancy.d index 2beb24e..8da2765 100644 --- a/source/tlang/compiler/typecheck/dependancy.d +++ b/source/tlang/compiler/typecheck/dependancy.d @@ -17,7 +17,11 @@ public final class StructuralOrganizer this.tc = tc; } - /* TODO: Return a list of Statement, in their init order */ + /** + * Given a container this method will attempt to build + * an implicit dependency tree (by setting the dependencies) + * on the Entities contained within + */ public void checkContainer(Container container) { /* Get all Entities */ @@ -67,6 +71,34 @@ public final class StructuralOrganizer } + public void printDeps(Container container) + { + /* Get all Entities */ + Entity[] entities; + foreach(Statement statement; container.getStatements()) + { + if(statement !is null && cast(Entity)statement) + { + entities ~= cast(Entity)statement; + } + } + + /** + * Print all the dependencies + */ + foreach(Entity entity; entities) + { + /* Print the Entity's dependencies */ + gprintln("Entity ("~entity.getName()~"): "~to!(string)(entity.getDeps())); + + /* if the ENtity is a container then apply recursively */ + if(cast(Container)entity) + { + printDeps(cast(Container)entity); + } + } + } + /** * Given a path determine if it is accessible (in a static context) *