Pool the Module and make it depend on variables

typecheck_reliancetree
Tristan B. Kildaire 2021-06-07 13:48:14 +02:00
parent 547f25b835
commit d9566698d2
2 changed files with 39 additions and 14 deletions

View File

@ -22,8 +22,8 @@ public final class StructuralOrganizer
public void generate() public void generate()
{ {
TreeNode node = checkContainer(tc.getModule()); root = poolNode(tc.getModule());
//root.addDep(node); checkContainer(tc.getModule());
} }
/** /**
@ -31,7 +31,7 @@ public final class StructuralOrganizer
* an implicit dependency tree (by setting the dependencies) * an implicit dependency tree (by setting the dependencies)
* on the Entities contained within * on the Entities contained within
*/ */
public TreeNode checkContainer(Container container) public void checkContainer(Container container)
{ {
/* Get all Entities */ /* Get all Entities */
Entity[] entities; Entity[] entities;
@ -69,12 +69,14 @@ public final class StructuralOrganizer
/* Statically initialize the class */ /* Statically initialize the class */
TreeNode classWalkInitDep = staticInitializeClass(classType); TreeNode classWalkInitDep = staticInitializeClass(classType);
root.addDep(classWalkInitDep);
/* Make the variable dependent on this */ /* Make the variable dependent on this */
TreeNode varNode = poolNode(variable); TreeNode varNode = poolNode(variable);
root.addDep(varNode);
/* Mark the variable as dependent on having sttaic init for class-type class */ // /* Mark the variable as dependent on having sttaic init for class-type class */
varNode.addDep(classWalkInitDep); // varNode.addDep(classWalkInitDep);
} }
@ -87,9 +89,6 @@ public final class StructuralOrganizer
} }
} }
} }
return null;
} }
private TreeNode[] nodePool; private TreeNode[] nodePool;
@ -110,6 +109,19 @@ public final class StructuralOrganizer
return node; return node;
} }
public bool isPooled(Entity entity)
{
foreach(TreeNode node; nodePool)
{
if(node.getEntity() == entity)
{
return true;
}
}
return false;
}
/** /**
* Statically initialize a class * Statically initialize a class
* *
@ -122,7 +134,21 @@ public final class StructuralOrganizer
/** /**
* This Class's TreeNode * This Class's TreeNode
*/ */
TreeNode treeNode = poolNode(clazz); TreeNode treeNode;
if(isPooled(clazz))
{
treeNode = poolNode(clazz);
return treeNode;
// goto static_initialization_completed;
}
else
{
treeNode = poolNode(clazz);
}
/** /**
* Check if the current Clazz has a parent Container * Check if the current Clazz has a parent Container
@ -208,7 +234,7 @@ public final class StructuralOrganizer
} }
} }
static_initialization_completed:
return treeNode; return treeNode;
} }
@ -228,8 +254,7 @@ public final class StructuralOrganizer
{ {
foreach(TreeNode node; nodePool) foreach(TreeNode node; nodePool)
{ {
gprintln(node is null); gprintln(node, DebugType.WARNING);
gprintln(node);
} }
} }

View File

@ -1,7 +1,7 @@
module typeChecking1; module typeChecking1;
B bInstance;
A aInstance = 1; A aInstance = 1;
B bInstance;
A.C cInstance; A.C cInstance;
int jNumber; int jNumber;
@ -24,6 +24,6 @@ class A
class B class B
{ {
static int kStatic; static int kStatic;
static A ds;
} }