1
2
3
4
5
6 #include <sngcpp/ast/Writer.hpp>
7
8 namespace sngcpp { namespace ast {
9
10 Writer::Writer(const std::std::vector<soulng::lexer::Lexer*>&lexers_, soulng::util::BinaryWriter&binaryWriter_):lexers(lexers_), binaryWriter(binaryWriter_)
11 {
12 }
13
14 void Writer::Write(soulng::lexer::Span& span)
15 {
16 if (span.fileIndex != -1)
17 {
18 soulng::lexer::Lexer* lexer = lexers[span.fileIndex];
19 lexer->ConvertExternal(span);
20 }
21 binaryWriter.Write(int32_t(span.fileIndex));
22 binaryWriter.Write(int32_t(span.line));
23 binaryWriter.Write(int32_t(span.start));
24 binaryWriter.Write(int32_t(span.end));
25 }
26
27 void Writer::Write(SimpleTypeSpecifier specifier)
28 {
29 binaryWriter.Write(uint8_t(specifier));
30 }
31
32 void Writer::Write(NodeType nodeType)
33 {
34 binaryWriter.Write(uint8_t(nodeType));
35 }
36
37 void Writer::Write(Specifier specifiers)
38 {
39 binaryWriter.Write(uint32_t(specifiers));
40 }
41
42 void Writer::Write(ClassKey classKey)
43 {
44 binaryWriter.Write(uint8_t(classKey));
45 }
46
47 void Writer::Write(EnumKey enumKey)
48 {
49 binaryWriter.Write(uint8_t(enumKey));
50 }
51
52 void Writer::Write(Operator op)
53 {
54 binaryWriter.Write(uint8_t(op));
55 }
56
57 void Writer::Write(Suffix suffix)
58 {
59 binaryWriter.Write(uint8_t(suffix));
60 }
61
62 void Writer::Write(Base base)
63 {
64 binaryWriter.Write(uint8_t(base));
65 }
66
67 } }