1 | // prebuilt/asdl/runtime.mycpp.h: GENERATED by mycpp
|
2 |
|
3 | #ifndef ASDL_RUNTIME_MYCPP_H
|
4 | #define ASDL_RUNTIME_MYCPP_H
|
5 |
|
6 | #include "_gen/asdl/hnode.asdl.h"
|
7 | #include "_gen/display/pretty.asdl.h"
|
8 | #include "cpp/data_lang.h"
|
9 | #include "mycpp/runtime.h"
|
10 |
|
11 | #include "_gen/display/pretty.asdl.h"
|
12 |
|
13 | using pretty_asdl::doc; // ad hoc
|
14 |
|
15 | namespace runtime { // forward declare
|
16 |
|
17 | class TraversalState;
|
18 |
|
19 | } // forward declare namespace runtime
|
20 |
|
21 | namespace format { // forward declare
|
22 |
|
23 | class ColorOutput;
|
24 | class TextOutput;
|
25 | class HtmlOutput;
|
26 | class AnsiOutput;
|
27 | class _PrettyPrinter;
|
28 |
|
29 | } // forward declare namespace format
|
30 |
|
31 | namespace runtime { // declare
|
32 |
|
33 | using hnode_asdl::hnode;
|
34 | extern int NO_SPID;
|
35 | hnode::Record* NewRecord(BigStr* node_type);
|
36 | hnode::Leaf* NewLeaf(BigStr* s, hnode_asdl::color_t e_color);
|
37 | class TraversalState {
|
38 | public:
|
39 | TraversalState();
|
40 | Dict<int, bool>* seen;
|
41 | Dict<int, int>* ref_count;
|
42 |
|
43 | static constexpr ObjHeader obj_header() {
|
44 | return ObjHeader::ClassScanned(2, sizeof(TraversalState));
|
45 | }
|
46 |
|
47 | DISALLOW_COPY_AND_ASSIGN(TraversalState)
|
48 | };
|
49 |
|
50 | extern BigStr* TRUE_STR;
|
51 | extern BigStr* FALSE_STR;
|
52 |
|
53 | } // declare namespace runtime
|
54 |
|
55 | namespace format { // declare
|
56 |
|
57 | using hnode_asdl::hnode;
|
58 | format::ColorOutput* DetectConsoleOutput(mylib::Writer* f);
|
59 | class ColorOutput {
|
60 | public:
|
61 | ColorOutput(mylib::Writer* f);
|
62 | virtual format::ColorOutput* NewTempBuffer();
|
63 | virtual void FileHeader();
|
64 | virtual void FileFooter();
|
65 | virtual void PushColor(hnode_asdl::color_t e_color);
|
66 | virtual void PopColor();
|
67 | virtual void write(BigStr* s);
|
68 | void WriteRaw(Tuple2<BigStr*, int>* raw);
|
69 | int NumChars();
|
70 | Tuple2<BigStr*, int> GetRaw();
|
71 | mylib::Writer* f;
|
72 | int num_chars;
|
73 |
|
74 | static constexpr uint32_t field_mask() {
|
75 | return maskbit(offsetof(ColorOutput, f));
|
76 | }
|
77 |
|
78 | static constexpr ObjHeader obj_header() {
|
79 | return ObjHeader::ClassFixed(field_mask(), sizeof(ColorOutput));
|
80 | }
|
81 |
|
82 | DISALLOW_COPY_AND_ASSIGN(ColorOutput)
|
83 | };
|
84 |
|
85 | class TextOutput : public ::format::ColorOutput {
|
86 | public:
|
87 | TextOutput(mylib::Writer* f);
|
88 | virtual format::TextOutput* NewTempBuffer();
|
89 | virtual void PushColor(hnode_asdl::color_t e_color);
|
90 | virtual void PopColor();
|
91 |
|
92 | static constexpr uint32_t field_mask() {
|
93 | return ::format::ColorOutput::field_mask();
|
94 | }
|
95 |
|
96 | static constexpr ObjHeader obj_header() {
|
97 | return ObjHeader::ClassFixed(field_mask(), sizeof(TextOutput));
|
98 | }
|
99 |
|
100 | DISALLOW_COPY_AND_ASSIGN(TextOutput)
|
101 | };
|
102 |
|
103 | class HtmlOutput : public ::format::ColorOutput {
|
104 | public:
|
105 | HtmlOutput(mylib::Writer* f);
|
106 | virtual format::HtmlOutput* NewTempBuffer();
|
107 | virtual void FileHeader();
|
108 | virtual void FileFooter();
|
109 | virtual void PushColor(hnode_asdl::color_t e_color);
|
110 | virtual void PopColor();
|
111 | virtual void write(BigStr* s);
|
112 |
|
113 | static constexpr uint32_t field_mask() {
|
114 | return ::format::ColorOutput::field_mask();
|
115 | }
|
116 |
|
117 | static constexpr ObjHeader obj_header() {
|
118 | return ObjHeader::ClassFixed(field_mask(), sizeof(HtmlOutput));
|
119 | }
|
120 |
|
121 | DISALLOW_COPY_AND_ASSIGN(HtmlOutput)
|
122 | };
|
123 |
|
124 | class AnsiOutput : public ::format::ColorOutput {
|
125 | public:
|
126 | AnsiOutput(mylib::Writer* f);
|
127 | virtual format::AnsiOutput* NewTempBuffer();
|
128 | virtual void PushColor(hnode_asdl::color_t e_color);
|
129 | virtual void PopColor();
|
130 |
|
131 | static constexpr uint32_t field_mask() {
|
132 | return ::format::ColorOutput::field_mask();
|
133 | }
|
134 |
|
135 | static constexpr ObjHeader obj_header() {
|
136 | return ObjHeader::ClassFixed(field_mask(), sizeof(AnsiOutput));
|
137 | }
|
138 |
|
139 | DISALLOW_COPY_AND_ASSIGN(AnsiOutput)
|
140 | };
|
141 |
|
142 | extern int INDENT;
|
143 | class _PrettyPrinter {
|
144 | public:
|
145 | _PrettyPrinter(int max_col);
|
146 | bool _PrintWrappedArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
|
147 | bool _PrintWholeArray(List<hnode_asdl::hnode_t*>* array, int prefix_len, format::ColorOutput* f, int indent);
|
148 | void _PrintRecord(hnode::Record* node, format::ColorOutput* f, int indent);
|
149 | void PrintNode(hnode_asdl::hnode_t* node, format::ColorOutput* f, int indent);
|
150 | int max_col;
|
151 |
|
152 | static constexpr ObjHeader obj_header() {
|
153 | return ObjHeader::ClassScanned(0, sizeof(_PrettyPrinter));
|
154 | }
|
155 |
|
156 | DISALLOW_COPY_AND_ASSIGN(_PrettyPrinter)
|
157 | };
|
158 |
|
159 | bool _TrySingleLineObj(hnode::Record* node, format::ColorOutput* f, int max_chars);
|
160 | bool _TrySingleLine(hnode_asdl::hnode_t* node, format::ColorOutput* f, int max_chars);
|
161 | void PrintTree(hnode_asdl::hnode_t* node, format::ColorOutput* f);
|
162 | void PrintTree2(hnode_asdl::hnode_t* node, format::ColorOutput* f);
|
163 |
|
164 | } // declare namespace format
|
165 |
|
166 | #endif // ASDL_RUNTIME_MYCPP_H
|