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