1
2
3
4
5
6 #ifndef CMAJOR_SYMBOLS_CONCEPT_SYMBOL_INCLUDED
7 #define CMAJOR_SYMBOLS_CONCEPT_SYMBOL_INCLUDED
8 #include <cmajor/symbols/ContainerSymbol.hpp>
9 #include <cmajor/symbols/TemplateSymbol.hpp>
10 #include <unordered_map>
11
12 namespace cmajor { namespace symbols {
13
14 class ConceptSymbol;
15
16 class ConceptGroupSymbol : public Symbol
17 {
18 public:
19 ConceptGroupSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId_, const std::u32string& name_);
20 std::string TypeString() const override { return "concept_group"; }
21 bool IsExportSymbol() const override { return false; }
22 SymbolAccess DeclaredAccess() const override { return SymbolAccess::public_; }
23 void AddConcept(ConceptSymbol* conceptSymbol);
24 void RemoveConcept(ConceptSymbol* conceptSymbol);
25 bool IsEmpty() const;
26 ConceptSymbol* GetConcept(int arity);
27 bool HasProjectMembers() const override;
28 void AppendChildElements(sngxml::dom::Element* element, TypeMap& typeMap) const override;
29 std::u32string Info() const override { return Name(); }
30 const char* ClassName() const override { return "ConceptGroupSymbol"; }
31 void Check() override;
32 std::string GetSymbolCategoryStr() const override { return "CO"; }
33 std::string GetSymbolCategoryDescription() const override { return "concept"; }
34 std::string GetSymbolHelp() const override;
35 private:
36 std::unordered_map<int, ConceptSymbol*> arityConceptMap;
37 };
38
39 class ConceptSymbol : public ContainerSymbol
40 {
41 public:
42 ConceptSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId_, const std::u32string& name_);
43 bool IsParentSymbol() const override { return true; }
44 void Write(SymbolWriter& writer) override;
45 void Read(SymbolReader& reader) override;
46 void EmplaceConcept(ConceptSymbol* conceptSymbol) override;
47 void EmplaceType(TypeSymbol* typeSymbol, int index) override;
48 void Accept(SymbolCollector* collector) override;
49 void Dump(CodeFormatter& formatter) override;
50 void AddMember(Symbol* member) override;
51 std::string TypeString() const override { return "concept"; }
52 std::u32string SimpleName() const override { return groupName; }
53 void ComputeName();
54 void SetSpecifiers(Specifiers specifiers);
55 void SetTypeId(const boost::uuids::uuid& typeId_) { typeId = typeId_; }
56 const boost::uuids::uuid& TypeId() const { return typeId; }
57 const std::u32string& GroupName() const { return groupName; }
58 void SetGroupName(const std::u32string& groupName_) { groupName = groupName_; }
59 std::u32string CodeName() const override { return groupName; }
60 int Arity() const { return templateParameters.size(); }
61 ConceptNode* GetConceptNode() { return conceptNode.get(); }
62 ConceptSymbol* RefinedConcept() const { return refinedConcept; }
63 void SetRefinedConcept(ConceptSymbol* refinedConcept_) { refinedConcept = refinedConcept_; }
64 const std::std::vector<TemplateParameterSymbol*>&TemplateParameters() const{returntemplateParameters;}
65 std::u32string Info() const override { return groupName; }
66 const char* ClassName() const override { return "ConceptSymbol"; }
67 bool HasSource() const { return hasSource; }
68 void SetHasSource() { hasSource = true; }
69 void Check() override;
70 void SetConceptGroup(ConceptGroupSymbol* conceptGroup_) { conceptGroup = conceptGroup_; }
71 std::unique_ptr<Symbol> RemoveFromParent() override;
72 std::string GetSymbolCategoryStr() const override { return "CO"; }
73 std::string GetSymbolCategoryDescription() const override { return "concept"; }
74 private:
75 boost::uuids::uuid typeId;
76 std::u32string groupName;
77 std::vector<TemplateParameterSymbol*> templateParameters;
78 std::unique_ptr<ConceptNode> conceptNode;
79 ConceptSymbol* refinedConcept;
80 bool hasSource;
81 ConceptGroupSymbol* conceptGroup;
82 };
83
84 class AxiomSymbol : public ContainerSymbol
85 {
86 public:
87 AxiomSymbol(const Span& span_, const boost::uuids::uuid& sourceModuleId, const std::u32string& name_);
88 SymbolAccess DeclaredAccess() const override { return SymbolAccess::public_; }
89 bool IsExportSymbol() const override { return false; }
90 std::u32string Info() const override { return Name(); }
91 const char* ClassName() const override { return "AxiomSymbol"; }
92 };
93
94 } }
95
96 #endif // CMAJOR_SYMBOLS_CONCEPT_SYMBOL_INCLUDED