Skip to content

Commit

Permalink
FuncDefStore
Browse files Browse the repository at this point in the history
- The constructor now takes in a `TypeChecker` instance
- Implemented `addFunctionDef(Function func)`
  • Loading branch information
deavmi committed Dec 8, 2023
1 parent 098d9a8 commit ba980fe
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions source/tlang/compiler/typecheck/dependency/store/impls.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module tlang.compiler.typecheck.dependency.store.impls;
import tlang.compiler.typecheck.dependency.store.interfaces : IFuncDefStore;
import tlang.compiler.symbols.data : Function;

import tlang.compiler.typecheck.dependency.core : FunctionData;
import tlang.compiler.typecheck.dependency.core : FunctionData, DFunctionInnerGenerator;
import tlang.compiler.typecheck.core : TypeChecker;

public final class FuncDefStore : IFuncDefStore
{
Expand All @@ -12,6 +13,21 @@ public final class FuncDefStore : IFuncDefStore
*/
private FunctionData[string] functions;

/**
* The type checker instance
*/
private TypeChecker tc;

/**
*
* Params:
* typeChecker =
*/
this(TypeChecker typeChecker)
{
this.tc = typeChecker;
}

/**
* Adds the function definition
* to the store
Expand All @@ -21,7 +37,29 @@ public final class FuncDefStore : IFuncDefStore
*/
public void addFunctionDef(Function func)
{
// TODO: Implement me
/* (Sanity Check) This should never be called again */
foreach(string cFuncKey; functions.keys())
{
FunctionData cFuncData = functions[cFuncKey];
Function cFunc = cFuncData.func;

if(cFunc == func)
{
assert(false);
}
}

/**
* Create the FunctionData, coupled with it own DNodeGenerator
* context etc.
*/
FunctionData funcData;
funcData.ownGenerator = new DFunctionInnerGenerator(tc, func);
funcData.name = func.getName();
funcData.func = func;


functions[funcData.name] = funcData;
}

/**
Expand Down

0 comments on commit ba980fe

Please sign in to comment.