1
2
3
4
5
6 #include <cmajor/binder/ConstExprFunctionRepository.hpp>
7 #include <cmajor/binder/TypeBinder.hpp>
8 #include <cmajor/binder/BoundCompileUnit.hpp>
9
10 namespace cmajor { namespace binder {
11
12 ConstExprFunctionRepository::ConstExprFunctionRepository(BoundCompileUnit& boundCompileUnit_) : boundCompileUnit(boundCompileUnit_)
13 {
14 }
15
16 FunctionNode* ConstExprFunctionRepository::GetFunctionNodeFor(FunctionSymbol* constExprFunctionSymbol)
17 {
18 Node* node = boundCompileUnit.GetSymbolTable().GetNodeNoThrow(constExprFunctionSymbol);
19 if (!node)
20 {
21 node = constExprFunctionSymbol->GetFunctionNode();
22 }
23 FunctionNode* functionNode = static_cast<FunctionNode*>(node);
24 boundCompileUnit.GetSymbolTable().MapNode(node, constExprFunctionSymbol);
25 if (constExprFunctionSymbol->IsProject() && !constExprFunctionSymbol->IsBound())
26 {
27 TypeBinder typeBinder(boundCompileUnit);
28 typeBinder.SetContainerScope(constExprFunctionSymbol->GetContainerScope());
29 typeBinder.SetCurrentFunctionSymbol(constExprFunctionSymbol);
30 functionNode->Accept(typeBinder);
31 }
32 return functionNode;
33 }
34
35 } }