From e5873fecb333472a46b06a762c6d7ce53adb0cb2 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Fri, 4 Jun 2021 11:55:22 +0200 Subject: [PATCH] Idea: Added visitation, we don't need marking tbh , we checking visitaion, marking is implcii in that if there is an error, we exit compiation rpocess, else we continue (which implies marked i.e. the type checking succeeded) --- .../tlang/compiler/symbols/typing/visitor.d | 2 ++ source/tlang/compiler/typecheck/core.d | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 source/tlang/compiler/symbols/typing/visitor.d diff --git a/source/tlang/compiler/symbols/typing/visitor.d b/source/tlang/compiler/symbols/typing/visitor.d new file mode 100644 index 0000000..b3522d2 --- /dev/null +++ b/source/tlang/compiler/symbols/typing/visitor.d @@ -0,0 +1,2 @@ +module compiler.symbols.typing.visitor; + diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index bbc2821..7a332ff 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -37,6 +37,26 @@ public final class TypeChecker } + + private Statement[] visistedStatements; + public void visit(Statement statement) + { + visistedStatements ~= statement; + } + + public bool hasVisited(Statement statementInQuestion) + { + foreach(Statement statement; visistedStatements) + { + if(statement == statementInQuestion) + { + return true; + } + } + + return false; + } + /** * I guess this should be called rather * when processing assignments but I also @@ -127,6 +147,8 @@ public final class TypeChecker gprintln("Type: "~to!(string)(type)); + /* TODO: Visit it (mark it as such) */ + visit(type); /* TODO: Check type here */ @@ -156,6 +178,11 @@ public final class TypeChecker /* TODO: In that case mark the entity as fine */ clazzType.mark(); } + /* If the type is visited already (good for rwcuasiev case mutal class references) */ + else if(hasVisited(clazzType)) + { + /* TODO: This could actually solve the abive too? */ + } else { /* TODO: Also make it fine? mmuutal recusive refernce */