1
2
3
4
5
6 #ifndef SNGCM_AST_GLOBAL_VARIABLE_INCLUDED
7 #define SNGCM_AST_GLOBAL_VARIABLE_INCLUDED
8 #include <sngcm/ast/Node.hpp>
9 #include <sngcm/ast/Specifier.hpp>
10
11 namespace sngcm { namespace ast {
12
13 class IdentifierNode;
14 class CompileUnitNode;
15
16 class GlobalVariableNode : public Node
17 {
18 public:
19 GlobalVariableNode(const Span& span_);
20 GlobalVariableNode(const Span& span_, Specifiers specifiers_, Node* typeExpr_, IdentifierNode* id_, CompileUnitNode* cu_);
21 Node* Clone(CloneContext& cloneContext) const override;
22 void Accept(Visitor& visitor) override;
23 void Write(AstWriter& writer) override;
24 void Read(AstReader& reader) override;
25 Specifiers GetSpecifiers() const override { return specifiers; }
26 const Node* TypeExpr() const { return typeExpr.get(); }
27 Node* TypeExpr() { return typeExpr.get(); }
28 const IdentifierNode* Id() const { return id.get(); }
29 IdentifierNode* Id() { return id.get(); }
30 Node* Initializer() { return initializer.get(); }
31 void SetInitializer(Node* initializer_);
32 CompileUnitNode* CompileUnit() const { return cu; }
33 private:
34 Specifiers specifiers;
35 std::unique_ptr<Node> typeExpr;
36 std::unique_ptr<IdentifierNode> id;
37 std::unique_ptr<Node> initializer;
38 CompileUnitNode* cu;
39 };
40
41 } }
42
43 #endif // SNGCM_AST_GLOBAL_VARIABLE_INCLUDED