1
2
3
4
5
6 #ifndef SNGCPP_AST_TEMPLATE_INCLUDED
7 #define SNGCPP_AST_TEMPLATE_INCLUDED
8 #include <sngcpp/ast/Expression.hpp>
9
10 namespace sngcpp { namespace ast {
11
12 class TypeParameterNode : public Node
13 {
14 public:
15 TypeParameterNode();
16 TypeParameterNode(const Span& span_, const std::u32string& id_, Node* defaultTemplateParameter_, bool typenameUsed_);
17 void Accept(Visitor& visitor) override;
18 void Write(Writer& writer) override;
19 void Read(Reader& reader) override;
20 const std::u32string& Id() const { return id; }
21 Node* DefaultTemplateParameter() { return defaultTemplateParameter.get(); }
22 bool TypenameUsed() const { return typenameUsed; }
23 private:
24 std::u32string id;
25 std::unique_ptr<Node> defaultTemplateParameter;
26 bool typenameUsed;
27 };
28
29 class TemplateParameterSequenceNode : public BinaryNode
30 {
31 public:
32 TemplateParameterSequenceNode();
33 TemplateParameterSequenceNode(const Span& span_, Node* left_, Node* right_);
34 void Accept(Visitor& visitor) override;
35 };
36
37 class TemplateDeclarationNode : public Node
38 {
39 public:
40 TemplateDeclarationNode();
41 TemplateDeclarationNode(const Span& span_, Node* templateParameters_, Node* declaration_);
42 void Accept(Visitor& visitor) override;
43 void Write(Writer& writer) override;
44 void Read(Reader& reader) override;
45 Node* TemplateParameters() { return templateParameters.get(); }
46 Node* Declaration() { return declaration.get(); }
47 private:
48 std::unique_ptr<Node> templateParameters;
49 std::unique_ptr<Node> declaration;
50 };
51
52 class TemplateArgumentSequenceNode : public BinaryNode
53 {
54 public:
55 TemplateArgumentSequenceNode();
56 TemplateArgumentSequenceNode(const Span& span_, Node* left_, Node* right_);
57 bool IsTemplateArgumentSequenceNode() const override { return true; }
58 void Accept(Visitor& visitor) override;
59 };
60
61 class TemplateIdNode : public Node
62 {
63 public:
64 TemplateIdNode();
65 TemplateIdNode(const Span& span_, IdentifierNode* id_, Node* templateArguments_, int arity_);
66 bool IsTemplateIdNode() const override { return true; }
67 void Accept(Visitor& visitor) override;
68 void Write(Writer& writer) override;
69 void Read(Reader& reader) override;
70 IdentifierNode* Id() { return id.get(); }
71 Node* TemplateArguments() { return templateArguments.get(); }
72 int Arity() const { return arity; }
73 private:
74 std::unique_ptr<IdentifierNode> id;
75 std::unique_ptr<Node> templateArguments;
76 int arity;
77 };
78
79 class TemplateArgumentNode : public Node
80 {
81 public:
82 TemplateArgumentNode();
83 TemplateArgumentNode(const Span& span_, Node* arg_);
84 void Accept(Visitor& visitor) override;
85 void Write(Writer& writer) override;
86 void Read(Reader& reader) override;
87 Node* Arg() { return arg.get(); }
88 private:
89 std::unique_ptr<Node> arg;
90 };
91
92 class ExplicitInstantiationNode : public UnaryNode
93 {
94 public:
95 ExplicitInstantiationNode();
96 ExplicitInstantiationNode(const Span& span_, Node* declaration_);
97 void Accept(Visitor& visitor) override;
98 };
99
100 class ExplicitSpecializationNode : public UnaryNode
101 {
102 public:
103 ExplicitSpecializationNode();
104 ExplicitSpecializationNode(const Span& span_, Node* declaration_);
105 void Accept(Visitor& visitor) override;
106 };
107
108 } }
109
110 #endif // SNGCPP_AST_TEMPLATE_INCLUDED