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)

static_support
Tristan B. V. Kildaire 2021-06-04 11:55:22 +02:00
parent 6c0a0ec69e
commit e5873fecb3
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,2 @@
module compiler.symbols.typing.visitor;

View File

@ -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 */