Disabled a lot of old typechecking code that we either don't need or I am not working with right now

This commit is contained in:
Tristan B. Kildaire 2021-11-02 09:32:52 +02:00
parent cf03601eec
commit 71be300582
1 changed files with 144 additions and 144 deletions

View File

@ -35,40 +35,40 @@ public final class TypeChecker
this.modulle = modulle;
resolver = new Resolver(this);
/* TODO: Module check?!?!? */
initTrees();
// initTrees();
}
import compiler.typecheck.visitor;
private VTreeNode root;
// import compiler.typecheck.visitor;
// private VTreeNode root;
/**
* Root of reliance (dependency) tree
*/
import compiler.typecheck.reliance;
private RelianceNode relianceRootNode;
// /**
// * Root of reliance (dependency) tree
// */
// import compiler.typecheck.reliance;
// private RelianceNode relianceRootNode;
private void initTrees()
{
root = new VTreeNode(modulle);
// private void initTrees()
// {
// // root = new VTreeNode(modulle);
/* Create a reliance node with no dependancies for the module */
relianceRootNode = new RelianceNode(modulle);
}
// /* Create a reliance node with no dependancies for the module */
// relianceRootNode = new RelianceNode(modulle);
// }
// private Statement[] visistedStatements;
public void visit(VTreeNode level, Statement statement)
{
// visistedStatements ~= statement;
level.addChild(new VTreeNode(statement));
}
// // private Statement[] visistedStatements;
// public void visit(VTreeNode level, Statement statement)
// {
// // visistedStatements ~= statement;
// level.addChild(new VTreeNode(statement));
// }
public VTreeNode hasVisited(Statement statementInQuestion)
{
return root.isInTree(statementInQuestion);
}
// public VTreeNode hasVisited(Statement statementInQuestion)
// {
// return root.isInTree(statementInQuestion);
// }
/**
* I guess this should be called rather
@ -520,7 +520,7 @@ public final class TypeChecker
/* TODO: Check things ithin */
checkTypedEntitiesTypeNames(clazz);
// checkTypedEntitiesTypeNames(clazz);
}
@ -537,165 +537,165 @@ public final class TypeChecker
* mmmmh
*/
// private VTreeNode currentNode;
private void checkTypedEntitiesTypeNames(Container c)
{
/* This VTreeNode */
VTreeNode thisNode;
// private void checkTypedEntitiesTypeNames(Container c)
// {
// /* This VTreeNode */
// VTreeNode thisNode;
if(c == modulle)
{
thisNode = root;
}
else
{
/* Create a VTreeNode for this Statement */
assert(cast(Statement)c);
thisNode = new VTreeNode(cast(Statement)c);
// if(c == modulle)
// {
// thisNode = root;
// }
// else
// {
// /* Create a VTreeNode for this Statement */
// assert(cast(Statement)c);
// thisNode = new VTreeNode(cast(Statement)c);
gprintln("dsdf");
// gprintln("dsdf");
/* Get my parent's VTreeNode */
/* TODO: This parent of, ah we should make functions be containers, like we gonna need that for constutcor processing etc, and fucntions, mutual recursion there too */
Statement cS = cast(Statement)c;
VTreeNode parentNode = hasVisited(cast(Statement)cS.parentOf());
// /* Get my parent's VTreeNode */
// /* TODO: This parent of, ah we should make functions be containers, like we gonna need that for constutcor processing etc, and fucntions, mutual recursion there too */
// Statement cS = cast(Statement)c;
// VTreeNode parentNode = hasVisited(cast(Statement)cS.parentOf());
gprintln("dsdf");
gprintln(parentNode);
gprintln(c);
// gprintln("dsdf");
// gprintln(parentNode);
// gprintln(c);
/* TODO: My grand resolver fuuuuck the parent is not in da tree */
/* TODO: Static classes moment */
// /* TODO: My grand resolver fuuuuck the parent is not in da tree */
// /* TODO: Static classes moment */
/* TODO: We should do this recursively rather, because we exit it is fine technically so the tree will be valid */
// /* TODO: We should do this recursively rather, because we exit it is fine technically so the tree will be valid */
/* Child-self to parent VTreeNode */
parentNode.addChild(thisNode);
gprintln("dsdf");
// /* Child-self to parent VTreeNode */
// parentNode.addChild(thisNode);
// gprintln("dsdf");
}
// }
TypedEntity[] typedEntities;
// TypedEntity[] typedEntities;
foreach (Statement statement; c.getStatements())
{
if (statement !is null && cast(TypedEntity) statement)
{
typedEntities ~= cast(TypedEntity) statement;
}
}
// foreach (Statement statement; c.getStatements())
// {
// if (statement !is null && cast(TypedEntity) statement)
// {
// typedEntities ~= cast(TypedEntity) statement;
// }
// }
/* Attempt to resolve the types of the variables */
foreach(TypedEntity typedEntity; typedEntities)
{
/* TypedEntity's type */
string typeString = typedEntity.getType();
// /* Attempt to resolve the types of the variables */
// foreach(TypedEntity typedEntity; typedEntities)
// {
// /* TypedEntity's type */
// string typeString = typedEntity.getType();
/* TODO: Resolve type here (either built-in or class type) */
Type type = getType(c, typeString);
// /* TODO: Resolve type here (either built-in or class type) */
// Type type = getType(c, typeString);
/* Make sure type is valid */
if(!type)
{
Parser.expect("Invalid type \""~typeString~"\"");
}
// /* Make sure type is valid */
// if(!type)
// {
// Parser.expect("Invalid type \""~typeString~"\"");
// }
gprintln("Type: "~to!(string)(type));
// gprintln("Type: "~to!(string)(type));
/* TODO: Visit it (mark it as such) */
VTreeNode thisEntity = new VTreeNode(typedEntity);
// /* TODO: Visit it (mark it as such) */
// VTreeNode thisEntity = new VTreeNode(typedEntity);
/* TODO: Check type here */
// /* TODO: Check type here */
/* If it is primitive then no further checking */
if(cast(Number)type)
{
/* TODO: Mark it as ready-for-reference */
// /* If it is primitive then no further checking */
// if(cast(Number)type)
// {
// /* TODO: Mark it as ready-for-reference */
/* TODO: Expression checking */
thisNode.addChild(thisEntity);
// /* TODO: Expression checking */
// thisNode.addChild(thisEntity);
}
else
{
/* If it is a Class type */
if(cast(Clazz)type)
{
Clazz clazzType = cast(Clazz)type;
// }
// else
// {
// /* If it is a Class type */
// if(cast(Clazz)type)
// {
// Clazz clazzType = cast(Clazz)type;
/* TODO: Check constructor */
// /* TODO: Check constructor */
/* TODO: We need to start marking things */
/* TODO: Do actual checks here now */
// /* TODO: We need to start marking things */
// /* TODO: Do actual checks here now */
/* TODO: If the type is of the current class we are in then it is fine? */
if(clazzType == c)
{
gprintln("Container we are in matches type of TypedEdntity being processed");
// /* TODO: If the type is of the current class we are in then it is fine? */
// if(clazzType == c)
// {
// gprintln("Container we are in matches type of TypedEdntity being processed");
/* TODO: In that case mark the entity as fine */
thisNode.addChild(thisEntity);
// 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? */
/* This is basically saying the TypedEntity's type is a CLass that has been visited so we can assume it is safe to add */
/* We don't wanna visit it again (as stackoevrflow) from mutaul recursion then */
thisNode.addChild(thisEntity);
}
else
{
/* TODO: Also make it fine? mmuutal recusive refernce */
/* TODO: Got it, we NEED a dependency tree, to know chihs is being processed previosuly */
// /* TODO: In that case mark the entity as fine */
// thisNode.addChild(thisEntity);
// // 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? */
// /* This is basically saying the TypedEntity's type is a CLass that has been visited so we can assume it is safe to add */
// /* We don't wanna visit it again (as stackoevrflow) from mutaul recursion then */
// thisNode.addChild(thisEntity);
// }
// else
// {
// /* TODO: Also make it fine? mmuutal recusive refernce */
// /* TODO: Got it, we NEED a dependency tree, to know chihs is being processed previosuly */
/* TODO: Now check this class and follow it's path */
checkClass(clazzType);
}
// /* TODO: Now check this class and follow it's path */
// checkClass(clazzType);
// }
}
}
// }
// }
}
// }
// /**
// * Get all classes
// */
// Clazz[] classes;
// foreach (Statement statement; c.getStatements())
// {
// if (statement !is null && cast(Clazz) statement)
// {
// classes ~= cast(Clazz) statement;
// }
// }
// // /**
// // * Get all classes
// // */
// // Clazz[] classes;
// // foreach (Statement statement; c.getStatements())
// // {
// // if (statement !is null && cast(Clazz) statement)
// // {
// // classes ~= cast(Clazz) statement;
// // }
// // }
// /**
// * TODO: Here I am testing on dependeny constrtuction
// * 1. Only for classes
// * 2. Only for their static member (assignment is assumed not to happen)
// */
// foreach(Clazz currentClass; classes)
// {
// gprintln("DependencyConstruction: Class Container found '"~to!(string)(currentClass)~"'");
// // /**
// // * TODO: Here I am testing on dependeny constrtuction
// // * 1. Only for classes
// // * 2. Only for their static member (assignment is assumed not to happen)
// // */
// // foreach(Clazz currentClass; classes)
// // {
// // gprintln("DependencyConstruction: Class Container found '"~to!(string)(currentClass)~"'");
// /* Mark this as reliant on modulle (then) */
// // /* Mark this as reliant on modulle (then) */
// /* Check recursively */
// checkClass_DepTest(currentClass);
// }
// // /* Check recursively */
// // checkClass_DepTest(currentClass);
// // }
}
// }
/**
@ -792,7 +792,7 @@ public final class TypeChecker
private void checkDefinitionTypes(Container c)
{
/* Check variables and functions (TypedEntities) declarations */
checkTypedEntitiesTypeNames(c);
// checkTypedEntitiesTypeNames(c);