1
2
3
4
5
6 #ifndef CMAJOR_SYMBOLS_TEMPLATE_SYMBOL_INCLUDED
7 #define CMAJOR_SYMBOLS_TEMPLATE_SYMBOL_INCLUDED
8 #include <cmajor/symbols/TypeSymbol.hpp>
9
10 namespace cmajor { namespace symbols {
11
12 class TemplateParameterSymbol : public TypeSymbol
13 {
14 public:
15 TemplateParameterSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId_, const std::u32string& name_);
16 std::u32string FullName() const override { return Name(); }
17 void Write(SymbolWriter& writer) override;
18 void Read(SymbolReader& reader) override;
19 void EmplaceType(TypeSymbol* typeSymbol, int index) override;
20 void* IrType(Emitter& emitter) override { Assert(false, "tried to get ir type of template parameter"); return nullptr; }
21 void* CreateDefaultIrValue(Emitter& emitter) override { Assert(false, "tried to create defualt ir value of template parameter"); return nullptr; }
22 TypeSymbol* Unify(TypeSymbol* type, const Span& span, const boost::uuids::uuid& moduleId) override;
23 bool ContainsTemplateParameter() const override { return true; }
24 bool HasDefault() const { return hasDefault; }
25 void SetHasDefault() { hasDefault = true; }
26 void SetDefaultType(TypeSymbol* defaultType_) { defaultType = defaultType_; }
27 TypeSymbol* DefaultType() { return defaultType; }
28 TypeSymbol* UnifyTemplateArgumentType(SymbolTable& symbolTable, const std::std::unordered_map<TemplateParameterSymbol*, TypeSymbol*>&templateParameterMap, constSpan&span, constboost::uuids::uuid&moduleId) override;
29 std::u32string Info() const override { return Name(); }
30 const char* ClassName() const override { return "TemplateParameterSymbol"; }
31 std::string GetSymbolCategoryStr() const override { return "TP"; }
32 std::string GetSymbolCategoryDescription() const override { return "template parameter"; }
33 private:
34 bool hasDefault;
35 TypeSymbol* defaultType;
36 };
37
38 class BoundTemplateParameterSymbol : public Symbol
39 {
40 public:
41 BoundTemplateParameterSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId_, const std::u32string& name_);
42 std::u32string FullName() const override { return Name(); }
43 void Write(SymbolWriter& writer) override;
44 void Read(SymbolReader& reader) override;
45 TypeSymbol* GetType() const { return type; }
46 void SetType(TypeSymbol* type_) { type = type_; }
47 std::unique_ptr<sngxml::dom::Element> CreateDomElement(TypeMap& typeMap) override;
48 std::u32string Info() const override { return Name(); }
49 const char* ClassName() const override { return "BoundTemplateParameterSymbol"; }
50 void Check() override;
51 private:
52 TypeSymbol* type;
53 };
54
55 } }
56
57 #endif // CMAJOR_SYMBOLS_TEMPLATE_SYMBOL_INCLUDED