Removed unused method (older method before generalPass())

This commit is contained in:
Tristan B. Velloza Kildaire 2022-10-01 20:56:42 +02:00
parent a8630b5939
commit 69572ff02c
1 changed files with 0 additions and 223 deletions

View File

@ -1274,229 +1274,6 @@ public class DNodeGenerator
return node;
}
/**
* Can we some how generalise this?
*/
private DNode modulePass_disabled(Module modulle)
{
/* Get a DNode for the Module */
DNode moduleDNode = pool(modulle);
root = moduleDNode;
/**
* Get the Entities
*/
Statement[] entities;
foreach(Statement statement; modulle.getStatements())
{
if(!(statement is null))// && cast(Entity)statement)
{
entities ~= cast(Statement)statement;
}
}
/**
* Process each Entity
*
* TODO: Non entities later
*/
foreach(Statement entity; entities)
{
gprintln("modulePass(): Processing entity: "~entity.toString());
/**
* Variable declarations
*/
if(cast(Variable)entity)
{
/* Get the Variable and information */
Variable variable = cast(Variable)entity;
/* TODO: 25Oct new */
Context d = new Context( cast(Container)modulle, InitScope.STATIC);
entity.setContext(d);
/* TODO: Above 25oct new */
Type variableType = tc.getType(modulle, variable.getType());
assert(variableType); /* TODO: Handle invalid variable type */
DNode variableDNode = poolT!(ModuleVariableDeclaration, Variable)(variable);
/* Basic type */
if(cast(Primitive)variableType)
{
/* Do nothing */
}
/* Class-type */
else if(cast(Clazz)variableType)
{
/* Get the static class dependency */
ClassStaticNode classDependency = classPassStatic(cast(Clazz)variableType);
/* Make this variable declaration depend on static initalization of the class */
variableDNode.needs(classDependency);
}
/* Struct-type */
else if(cast(Struct)variableType)
{
}
/* Anything else */
else
{
/* This should never happen */
assert(false);
}
/* Set this variable as a dependency of this module */
moduleDNode.needs(variableDNode);
/* Set as visited */
variableDNode.markVisited();
/* If there is an assignment attached to this */
if(variable.getAssignment())
{
/* (TODO) Process the assignment */
VariableAssignment varAssign = variable.getAssignment();
DNode expression = expressionPass(varAssign.getExpression(), new Context(modulle, InitScope.STATIC));
VariableAssignmentNode varAssignNode = new VariableAssignmentNode(this, varAssign);
varAssignNode.needs(expression);
variableDNode.needs(varAssignNode);
}
}
/**
* Variable asignments
*/
else if(cast(VariableAssignmentStdAlone)entity)
{
VariableAssignmentStdAlone vAsStdAl = cast(VariableAssignmentStdAlone)entity;
/* TODO: CHeck avriable name even */
gprintln("VAGINA");
assert(tc.getResolver().resolveWithin(cast(Container)modulle, vAsStdAl.getVariableName()));
gprintln("VAGINA");
Variable variable = cast(Variable)tc.getResolver().resolveWithin(cast(Container)modulle, vAsStdAl.getVariableName());
assert(variable);
/* Pool the variable */
DNode varDecDNode = pool(variable);
/* TODO: Make sure a DNode exists (implying it's been declared already) */
if(varDecDNode.isVisisted())
{
/* Pool varass stdalone */
DNode vStdAlDNode = pool(vAsStdAl);
moduleDNode.needs(vStdAlDNode);
DNode expression = expressionPass(vAsStdAl.getExpression(), new Context(modulle, InitScope.STATIC));
vStdAlDNode.needs(expression);
}
else
{
Parser.expect("Cannot reference variable "~vAsStdAl.getVariableName()~" which exists but has not been declared yet");
}
}
/**
* Function declarations
* Status: Not done (TODO)
*/
else if(cast(Function)entity)
{
// /* Grab the function */
Function func = cast(Function)entity;
// /* Set the context to be STATIC and relative to this Module */
// Context d = new Context( cast(Container)modulle, InitScope.STATIC);
// func.setContext(d);
// /* Pass the function declaration */
// DNode funcDep = FunctionPass(func);
// /* TODO: Surely we only require the module, it doesn't need us? */
// /* TODO: Perhaps, no, it needs us to make it into the tree */
// /* TODO: But NOT it's subcompnents */
// funcDep.needs(moduleDNode);
// moduleDNode.needs(funcDep); /* TODO: Nah fam looks weird */
/**
* TODO:
*
* Perhaps all function calls should look up this node
* via pooling it and then they should depend on it
* which depends on module init
*
* Then whatever depends on function call will have module dependent
* on it, which does this but morr round about but seems to make more
* sense, idk
*/
/**
* SOLUTION
*
* DOn;'t process declarations
* Process function calls, then look up the Function (declaration)
* and go through it pooling and seeing it's needs
*/
/**
* Other SOLUTION
*
* We go through and process the declaration and get
* what each variable depends on, we then return this
* And we have a function that does that for us
* but WE DON'T IMPLEMENT THAT HERE IN modulePass()
*
* Rather each call will do it, and because we pool
* we will add DNOdes that then flatten out
*/
/**
* EVEN BETTER (+PREVIOUS SOLUTION)
*
* We process it here yet we do not
* add thre entity themselves as dnodes
* only their dependents and return that
* Accounting ONLY for external dependencies
* WE STORE THIS INA FUNCTIONMAP
*
* We DO call this here
*
* On a FUNCTION **CALL** do a normal pass on
* the FUNCTIONMAP entity, in a way that doesn't
* add to our tree for Modulle. Effectively
* giving us a uniue dependecny tree per call
* which is fine for checking things and also
* for (what is to come - code generation) AS
* THEN we want duplication. Calling something
* twice means two sets of instructions, not one
* (as a result from pooled dependencies or USING
* the same pool)
*/
/* Add funtion definition */
gprintln("Hello");
addFunctionDef(tc, func);
}
}
return moduleDNode;
}
import compiler.typecheck.dependency.classes.classStaticDep;
private ClassStaticNode poolClassStatic(Clazz clazz)
{