1
2
3
4
5
6 #include <sngcpp/ast/Namespace.hpp>
7 #include <sngcpp/ast/Visitor.hpp>
8 #include <sngcpp/ast/Writer.hpp>
9 #include <sngcpp/ast/Reader.hpp>
10
11 namespace sngcpp { namespace ast {
12
13 NamespaceNode::NamespaceNode() : UnaryNode(NodeType::namespaceNode)
14 {
15 }
16
17 NamespaceNode::NamespaceNode(const Span& span_) : UnaryNode(NodeType::namespaceNode, span_), namespaceName()
18 {
19 }
20
21 NamespaceNode::NamespaceNode(const Span& span_, const std::u32string& namespaceName_) : UnaryNode(NodeType::namespaceNode, span_), namespaceName(namespaceName_)
22 {
23 }
24
25 void NamespaceNode::Accept(Visitor& visitor)
26 {
27 visitor.Visit(*this);
28 }
29
30 void NamespaceNode::Write(Writer& writer)
31 {
32 UnaryNode::Write(writer);
33 writer.GetBinaryWriter().Write(namespaceName);
34 }
35
36 void NamespaceNode::Read(Reader& reader)
37 {
38 UnaryNode::Read(reader);
39 namespaceName = reader.GetBinaryReader().ReadUtf32String();
40 }
41
42 void NamespaceNode::AddMember(const Span& span, Node* member)
43 {
44 if (Child())
45 {
46 SetChild(new DeclarationSequenceNode(span, ReleaseChild(), member));
47 }
48 else
49 {
50 SetChild(member);
51 }
52 }
53
54 } }