1
2
3
4
5
6 #ifndef SNGCM_AST_TEMPLATE_INCLUDED
7 #define SNGCM_AST_TEMPLATE_INCLUDED
8 #include <sngcm/ast/Node.hpp>
9 #include <sngcm/ast/NodeList.hpp>
10
11 namespace sngcm { namespace ast {
12
13 class IdentifierNode;
14
15 class TemplateIdNode : public Node
16 {
17 public:
18 TemplateIdNode(const Span& span_, const boost::uuids::uuid& moduleId_);
19 TemplateIdNode(const Span& span_, const boost::uuids::uuid& moduleId_, Node* primary_);
20 Node* Clone(CloneContext& cloneContext) const override;
21 void Accept(Visitor& visitor) override;
22 void Write(AstWriter& writer) override;
23 void Read(AstReader& reader) override;
24 std::string ToString() const override;
25 Node* Primary() { return primary.get(); }
26 void AddTemplateArgument(Node* templateArgument);
27 const NodeList<Node>& TemplateArguments() const { return templateArguments; }
28 private:
29 std::unique_ptr<Node> primary;
30 NodeList<Node> templateArguments;
31 };
32
33 class TemplateParameterNode : public Node
34 {
35 public:
36 TemplateParameterNode(const Span& span_, const boost::uuids::uuid& moduleId_);
37 TemplateParameterNode(const Span& span_, const boost::uuids::uuid& moduleId_, IdentifierNode* id_, Node* defaultTemplateArgument_);
38 Node* Clone(CloneContext& cloneContext) const override;
39 void Accept(Visitor& visitor) override;
40 void Write(AstWriter& writer) override;
41 void Read(AstReader& reader) override;
42 const IdentifierNode* Id() const { return id.get(); }
43 IdentifierNode* Id() { return id.get(); }
44 const Node* DefaultTemplateArgument() const { return defaultTemplateArgument.get(); }
45 Node* DefaultTemplateArgument() { return defaultTemplateArgument.get(); }
46 private:
47 std::unique_ptr<IdentifierNode> id;
48 std::unique_ptr<Node> defaultTemplateArgument;
49 };
50
51 class FullInstantiationRequestNode : public Node
52 {
53 public:
54 FullInstantiationRequestNode(const Span& span_, const boost::uuids::uuid& moduleId_);
55 FullInstantiationRequestNode(const Span& span_, const boost::uuids::uuid& moduleId_, TemplateIdNode* templateId_);
56 Node* Clone(CloneContext& cloneContext) const override;
57 void Accept(Visitor& visitor) override;
58 void Write(AstWriter& writer) override;
59 void Read(AstReader& reader) override;
60 TemplateIdNode* TemplateId() const { return templateId.get(); }
61 private:
62 std::unique_ptr<TemplateIdNode> templateId;
63 };
64
65 } }
66
67 #endif // SNGCM_AST_TEMPLATE_INCLUDED