OILS / _gen / display / pretty.asdl.h View on Github | oils.pub

278 lines, 178 significant
1// _gen/display/pretty.asdl.h is generated by asdl_main.py
2
3#ifndef PRETTY_ASDL
4#define PRETTY_ASDL
5
6#include <cstdint>
7
8#include "mycpp/runtime.h"
9#include "asdl/cpp_runtime.h"
10namespace pretty_asdl {
11
12// use struct instead of namespace so 'using' works consistently
13#define ASDL_NAMES struct
14
15class MeasuredDoc;
16class Measure;
17class doc_t;
18class DocFragment;
19
20ASDL_NAMES doc_e {
21 enum no_name {
22 Break = 1,
23 Text = 2,
24 Indent = 3,
25 Group = 64,
26 Flat = 5,
27 IfFlat = 6,
28 Concat = 66,
29 };
30};
31
32BigStr* doc_str(int tag, bool dot = true);
33
34class doc_t {
35 protected:
36 doc_t() {
37 }
38 public:
39 int tag() const {
40 return ObjHeader::FromObject(this)->type_tag;
41 }
42 constexpr int sum_type_id() {
43 return 0;
44 }
45 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
46
47 DISALLOW_COPY_AND_ASSIGN(doc_t)
48};
49
50class doc__Break : public doc_t {
51 public:
52 doc__Break(BigStr* string)
53 : string(string) {
54 }
55
56 static doc__Break* CreateNull(bool alloc_lists = false) {
57 return Alloc<doc__Break>(kEmptyString);
58 }
59
60 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
61
62 int type_id() {
63 return this->sum_type_id() + this->tag();
64 }
65
66 static constexpr ObjHeader obj_header() {
67 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Break), 1);
68 }
69 BigStr* string;
70
71 DISALLOW_COPY_AND_ASSIGN(doc__Break)
72};
73
74class doc__Text : public doc_t {
75 public:
76 doc__Text(BigStr* string)
77 : string(string) {
78 }
79
80 static doc__Text* CreateNull(bool alloc_lists = false) {
81 return Alloc<doc__Text>(kEmptyString);
82 }
83
84 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
85
86 int type_id() {
87 return this->sum_type_id() + this->tag();
88 }
89
90 static constexpr ObjHeader obj_header() {
91 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Text), 1);
92 }
93 BigStr* string;
94
95 DISALLOW_COPY_AND_ASSIGN(doc__Text)
96};
97
98class doc__Indent : public doc_t {
99 public:
100 doc__Indent(int indent, MeasuredDoc* mdoc)
101 : mdoc(mdoc),
102 indent(indent) {
103 }
104
105 static doc__Indent* CreateNull(bool alloc_lists = false) {
106 return Alloc<doc__Indent>(-1, nullptr);
107 }
108
109 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
110
111 int type_id() {
112 return this->sum_type_id() + this->tag();
113 }
114
115 static constexpr ObjHeader obj_header() {
116 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Indent), 1);
117 }
118 MeasuredDoc* mdoc;
119 int indent;
120
121 DISALLOW_COPY_AND_ASSIGN(doc__Indent)
122};
123
124class doc__Flat : public doc_t {
125 public:
126 doc__Flat(MeasuredDoc* mdoc)
127 : mdoc(mdoc) {
128 }
129
130 static doc__Flat* CreateNull(bool alloc_lists = false) {
131 return Alloc<doc__Flat>(nullptr);
132 }
133
134 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
135
136 int type_id() {
137 return this->sum_type_id() + this->tag();
138 }
139
140 static constexpr ObjHeader obj_header() {
141 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::Flat), 1);
142 }
143 MeasuredDoc* mdoc;
144
145 DISALLOW_COPY_AND_ASSIGN(doc__Flat)
146};
147
148class doc__IfFlat : public doc_t {
149 public:
150 doc__IfFlat(MeasuredDoc* flat_mdoc, MeasuredDoc* nonflat_mdoc)
151 : flat_mdoc(flat_mdoc),
152 nonflat_mdoc(nonflat_mdoc) {
153 }
154
155 static doc__IfFlat* CreateNull(bool alloc_lists = false) {
156 return Alloc<doc__IfFlat>(nullptr, nullptr);
157 }
158
159 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
160
161 int type_id() {
162 return this->sum_type_id() + this->tag();
163 }
164
165 static constexpr ObjHeader obj_header() {
166 return ObjHeader::AsdlClass(static_cast<uint16_t>(doc_e::IfFlat), 2);
167 }
168 MeasuredDoc* flat_mdoc;
169 MeasuredDoc* nonflat_mdoc;
170
171 DISALLOW_COPY_AND_ASSIGN(doc__IfFlat)
172};
173
174ASDL_NAMES doc {
175 typedef doc__Break Break;
176 typedef doc__Text Text;
177 typedef doc__Indent Indent;
178 typedef doc__Flat Flat;
179 typedef doc__IfFlat IfFlat;
180};
181
182class MeasuredDoc : public doc_t {
183 public:
184 MeasuredDoc(doc_t* doc, Measure* measure)
185 : doc(doc),
186 measure(measure) {
187 }
188
189 static MeasuredDoc* CreateNull(bool alloc_lists = false) {
190 return Alloc<MeasuredDoc>(nullptr, nullptr);
191 }
192
193 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
194
195 static constexpr ObjHeader obj_header() {
196 return ObjHeader::AsdlClass(64, 2);
197 }
198 doc_t* doc;
199 Measure* measure;
200
201 DISALLOW_COPY_AND_ASSIGN(MeasuredDoc)
202};
203
204class Measure {
205 public:
206 Measure(int flat, int nonflat)
207 : flat(flat),
208 nonflat(nonflat) {
209 }
210
211 static Measure* CreateNull(bool alloc_lists = false) {
212 return Alloc<Measure>(-1, -1);
213 }
214
215 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
216
217 static constexpr ObjHeader obj_header() {
218 return ObjHeader::AsdlClass(65, 0);
219 }
220 int flat;
221 int nonflat;
222
223 DISALLOW_COPY_AND_ASSIGN(Measure)
224};
225
226class DocFragment {
227 public:
228 DocFragment(MeasuredDoc* mdoc, int indent, bool is_flat, Measure* measure)
229 : mdoc(mdoc),
230 measure(measure),
231 indent(indent),
232 is_flat(is_flat) {
233 }
234
235 static DocFragment* CreateNull(bool alloc_lists = false) {
236 return Alloc<DocFragment>(nullptr, -1, false, nullptr);
237 }
238
239 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
240
241 static constexpr ObjHeader obj_header() {
242 return ObjHeader::AsdlClass(67, 2);
243 }
244 MeasuredDoc* mdoc;
245 Measure* measure;
246 int indent;
247 bool is_flat;
248
249 DISALLOW_COPY_AND_ASSIGN(DocFragment)
250};
251
252class List_Measured : public doc_t, public List<MeasuredDoc*> {
253 public:
254 List_Measured() : List<MeasuredDoc*>() {
255 }
256 List_Measured(List<MeasuredDoc*>* plain_list) :
257 List<MeasuredDoc*>(plain_list) {
258 }
259 static List_Measured* New() {
260 return Alloc<List_Measured>();
261 }
262 static List_Measured* Take(List<MeasuredDoc*>* plain_list) {
263 auto* result = Alloc<List_Measured>(plain_list);
264 plain_list->SetTaken();
265 return result;
266 }
267 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
268
269 static constexpr ObjHeader obj_header() {
270 return ObjHeader::TaggedSubtype(66, field_mask());
271 }
272 DISALLOW_COPY_AND_ASSIGN(List_Measured)
273};
274
275
276} // namespace pretty_asdl
277
278#endif // PRETTY_ASDL