1
2
3
4
5
6 #include <sngcm/ast/Comment.hpp>
7 #include <sngcm/ast/Visitor.hpp>
8 #include <sngcm/ast/AstWriter.hpp>
9 #include <sngcm/ast/AstReader.hpp>
10
11 namespace sngcm { namespace ast {
12
13 CommentNode::CommentNode(const Span& span_) : Node(NodeType::commentNode, span_)
14 {
15 }
16
17 CommentNode::CommentNode(const Span& span_, const std::u32string& comment_) : Node(NodeType::commentNode, span_), comment(comment_)
18 {
19 }
20
21 Node* CommentNode::Clone(CloneContext& cloneContext) const
22 {
23 return new CommentNode(GetSpan(), comment);
24 }
25
26 void CommentNode::Accept(Visitor& visitor)
27 {
28 visitor.Visit(*this);
29 }
30
31 void CommentNode::Write(AstWriter& writer)
32 {
33 Node::Write(writer);
34 writer.GetBinaryWriter().Write(comment);
35 }
36
37 void CommentNode::Read(AstReader& reader)
38 {
39 Node::Read(reader);
40 comment = reader.GetBinaryReader().ReadUtf32String();
41 }
42
43 } }