I wonder if that worked

This commit is contained in:
Tristan B. Kildaire 2021-06-07 14:27:36 +02:00
parent 00920ad43b
commit 8da6d94212
2 changed files with 82 additions and 1 deletions

View File

@ -276,8 +276,61 @@ public final class StructuralOrganizer
{ {
gprintln(node, DebugType.WARNING); gprintln(node, DebugType.WARNING);
} }
foreach(TreeNode node; nodePool)
{
figureOut(node);
}
gprintln("InitQueue: "~to!(string)(initQueue));
} }
public Entity[] initQueue;
public void figureOut(TreeNode node)
{
/**
* If there are no dependencies then
* initialize it now (mark as completed)
* and add to init queue
*/
if(!hasDeps(node))
{
node.markCompleted();
initQueue ~= node.getEntity();
}
/**
* If there are dependencies then mark it
* as busy
*/
else
{
node.markBusy();
/* Get the dependencies */
TreeNode[] nodeDeps = node.getDeps();
/**
*
*/
foreach(TreeNode nodeDep; nodeDeps)
{
/* Initialize any non-busy node */
if(!nodeDep.isBusy())
{
figureOut(nodeDep);
}
}
}
}
public bool hasDeps(TreeNode node)
{
return cast(bool)node.getDeps().length;
}
/** /**
* Given a path determine if it is accessible (in a static context) * Given a path determine if it is accessible (in a static context)
* *
@ -293,6 +346,28 @@ public class TreeNode
private Entity entity; private Entity entity;
private TreeNode[] deps; private TreeNode[] deps;
private TypeChecker tc; private TypeChecker tc;
private bool isBusyB;
private bool isCompletedB;
public bool isCompleted()
{
return isCompletedB;
}
public void markCompleted()
{
isCompletedB = true;
}
public bool isBusy()
{
return isBusyB;
}
public void markBusy()
{
isBusyB = true;
}
this(TypeChecker tc, Entity entity) this(TypeChecker tc, Entity entity)
{ {
@ -332,6 +407,11 @@ public class TreeNode
return entity; return entity;
} }
public TreeNode[] getDeps()
{
return deps;
}
public override string toString() public override string toString()
{ {
string[] names; string[] names;

View File

@ -25,7 +25,8 @@ TODO List
## Typechecking ## Typechecking
- [ ] Dependency generation - [ ] Dependency generation
- [ ] Classes declared at the module level should be ~~marked~~ seen as static in `parse()` (not in `parseBody()` <- this is a note we don't do this) - [ ] Classes declared at the module level should be marked as static in `parse()`
- [ ] `parseClass()` should not use
- [ ] Structs declared at the module level should be marked as ~~marked~~ seen in `parse()` (not in `parseBody()` <- this is a note we don't do this) - [ ] Structs declared at the module level should be marked as ~~marked~~ seen in `parse()` (not in `parseBody()` <- this is a note we don't do this)
- [ ] Functions (?) declared at the module level should be ~~marked~~ seen as static in `parse()` (not in `parseBody()` <- this is a note we don't do this) - [ ] Functions (?) declared at the module level should be ~~marked~~ seen as static in `parse()` (not in `parseBody()` <- this is a note we don't do this)
- [ ] Variables declared at the module level should be marked as ~~marked~~ seen in `parse()` (not in `parseBody()` <- this is a note we don't do this) - [ ] Variables declared at the module level should be marked as ~~marked~~ seen in `parse()` (not in `parseBody()` <- this is a note we don't do this)