tlang/source/tlang/compiler/typecheck/dependancy.d

69 lines
1.7 KiB
D
Raw Normal View History

2021-06-06 15:56:31 +00:00
module compiler.typecheck.dependancy;
import gogga;
import compiler.symbols.data;
2021-06-06 16:13:12 +00:00
import compiler.symbols.typing.core;
2021-06-06 15:56:31 +00:00
import compiler.typecheck.core;
2021-06-06 16:13:12 +00:00
2021-06-06 15:56:31 +00:00
import std.conv : to;
2021-06-06 21:10:16 +00:00
public final class StructuralOrganizer
{
2021-06-06 21:10:16 +00:00
/* The associated TypeChecker */
private TypeChecker tc;
2021-06-06 21:10:16 +00:00
this(TypeChecker tc)
{
2021-06-06 21:10:16 +00:00
this.tc = tc;
}
2021-06-06 21:10:16 +00:00
/* TODO: Return a list of Statement, in their init order */
public void checkContainer(Container container)
{
2021-06-06 21:10:16 +00:00
/* Get all Entities */
Entity[] entities;
foreach(Statement statement; container.getStatements())
{
2021-06-06 21:10:16 +00:00
if(statement !is null && cast(Entity)statement)
2021-06-06 20:48:04 +00:00
{
2021-06-06 21:10:16 +00:00
entities ~= cast(Entity)statement;
2021-06-06 20:48:04 +00:00
}
2021-06-06 15:56:31 +00:00
}
2021-06-06 16:13:12 +00:00
/**
2021-06-06 21:10:16 +00:00
* Process entities
2021-06-06 16:13:12 +00:00
*/
2021-06-06 21:10:16 +00:00
foreach(Entity entity; entities)
2021-06-06 16:13:12 +00:00
{
/**
2021-06-06 21:10:16 +00:00
* Variable declaration
2021-06-06 16:13:12 +00:00
*/
if(cast(Variable)entity)
{
2021-06-06 21:10:16 +00:00
/* Variable being declared */
2021-06-06 16:13:12 +00:00
Variable variable = cast(Variable)entity;
/* Get the variable's type */
2021-06-06 21:10:16 +00:00
Type type = tc.getType(container, variable.getType());
2021-06-06 16:13:12 +00:00
2021-06-06 21:10:16 +00:00
/* If the variable has a class-type */
if(cast(Clazz)type)
{
2021-06-06 21:10:16 +00:00
/* Get the class-type */
Clazz classType = cast(Clazz)type;
2021-06-06 21:10:16 +00:00
/* TODO: Ensure that we set dependences as A.B.C with A B C all static */
}
2021-06-06 21:10:16 +00:00
/* TODO: Handle assignment case */
2021-06-06 16:13:12 +00:00
if(variable.getAssignment())
{
2021-06-06 21:10:16 +00:00
/* TODO: Implement me */
2021-06-06 16:13:12 +00:00
}
}
}
}
2021-06-06 15:56:31 +00:00
}