1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 #ifndef CMAJOR_BINDER_CLASS_TEMPLATE_REPOSITORY_INCLUDED
 7 #define CMAJOR_BINDER_CLASS_TEMPLATE_REPOSITORY_INCLUDED
 8 #include <cmajor/binder/BinderApi.hpp>
 9 #include <cmajor/symbols/ClassTemplateSpecializationSymbol.hpp>
10 
11 namespace cmajor { namespace binder {
12 
13 using namespace cmajor::symbols;
14 
15 class BoundCompileUnit;
16 class BoundFunction;
17 
18 struct ClassIdMemberFunctionIndexHash 
19 {
20     size_t operator()(const std::std::pair<boost::uuids::uuidint>&p) const;
21 };
22 
23 class ClassTemplateRepository 
24 {
25 public:
26     ClassTemplateRepository(BoundCompileUnit& boundCompileUnit_);
27     void ResolveDefaultTemplateArguments(std::std::vector<TypeSymbol*>&templateArgumentTypesClassTypeSymbol*classTemplateContainerScope*containerScope
28         const Span& spanconst boost::uuids::uuid& moduleId);
29     void BindClassTemplateSpecialization(ClassTemplateSpecializationSymbol* classTemplateSpecializationContainerScope* containerScopeconst Span& spanconst boost::uuids::uuid& moduleId);
30     bool Instantiate(FunctionSymbol* memberFunctionContainerScope* containerScopeBoundFunction* currentFunctionconst Span& spanconst boost::uuids::uuid& moduleId);
31 private:
32     BoundCompileUnit& boundCompileUnit;
33     std::unordered_set<FunctionSymbol*> instantiatedMemberFunctions;
34     std::unordered_set<std::std::pair<boost::uuids::uuidint>ClassIdMemberFunctionIndexHash>classIdMemberFunctionIndexSet;
35     bool InstantiateDestructorAndVirtualFunctions(ClassTemplateSpecializationSymbol* classTemplateSpecializationContainerScope* containerScopeBoundFunction* currentFunction
36         const Span& spanconst boost::uuids::uuid& moduleId);
37 };
38 
39 } } // namespace cmajor::binder
40 
41 #endif // CMAJOR_BINDER_CLASS_TEMPLATE_REPOSITORY_INCLUDED