| 1 | // _gen/asdl/hnode.asdl.h is generated by asdl_main.py
|
| 2 |
|
| 3 | #ifndef HNODE_ASDL
|
| 4 | #define HNODE_ASDL
|
| 5 |
|
| 6 | #include <cstdint>
|
| 7 |
|
| 8 | #include "mycpp/runtime.h"
|
| 9 | namespace hnode_asdl {
|
| 10 |
|
| 11 | // use struct instead of namespace so 'using' works consistently
|
| 12 | #define ASDL_NAMES struct
|
| 13 |
|
| 14 | class Field;
|
| 15 | class hnode_t;
|
| 16 |
|
| 17 | enum class color_e {
|
| 18 | TypeName = 1,
|
| 19 | StringConst = 2,
|
| 20 | OtherConst = 3,
|
| 21 | UserType = 4,
|
| 22 | External = 5,
|
| 23 | };
|
| 24 | typedef color_e color_t;
|
| 25 |
|
| 26 | ASDL_NAMES hnode_e {
|
| 27 | enum no_name {
|
| 28 | AlreadySeen = 1,
|
| 29 | Leaf = 2,
|
| 30 | Array = 3,
|
| 31 | Record = 4,
|
| 32 | };
|
| 33 | };
|
| 34 |
|
| 35 | class hnode_t {
|
| 36 | protected:
|
| 37 | hnode_t() {
|
| 38 | }
|
| 39 | public:
|
| 40 | int tag() const {
|
| 41 | return ObjHeader::FromObject(this)->type_tag;
|
| 42 | }
|
| 43 | constexpr int sum_type_id() {
|
| 44 | return 0;
|
| 45 | }
|
| 46 | DISALLOW_COPY_AND_ASSIGN(hnode_t)
|
| 47 | };
|
| 48 |
|
| 49 | class hnode__AlreadySeen : public hnode_t {
|
| 50 | public:
|
| 51 | hnode__AlreadySeen(int heap_id)
|
| 52 | : heap_id(heap_id) {
|
| 53 | }
|
| 54 |
|
| 55 | static hnode__AlreadySeen* CreateNull(bool alloc_lists = false) {
|
| 56 | return Alloc<hnode__AlreadySeen>(-1);
|
| 57 | }
|
| 58 |
|
| 59 | static constexpr ObjHeader obj_header() {
|
| 60 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::AlreadySeen), 0);
|
| 61 | }
|
| 62 |
|
| 63 | int heap_id;
|
| 64 |
|
| 65 | DISALLOW_COPY_AND_ASSIGN(hnode__AlreadySeen)
|
| 66 | };
|
| 67 |
|
| 68 | class hnode__Leaf : public hnode_t {
|
| 69 | public:
|
| 70 | hnode__Leaf(BigStr* s, color_t color)
|
| 71 | : s(s),
|
| 72 | color(color) {
|
| 73 | }
|
| 74 |
|
| 75 | static hnode__Leaf* CreateNull(bool alloc_lists = false) {
|
| 76 | return Alloc<hnode__Leaf>(kEmptyString, color_e::TypeName);
|
| 77 | }
|
| 78 |
|
| 79 | static constexpr ObjHeader obj_header() {
|
| 80 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Leaf), 1);
|
| 81 | }
|
| 82 |
|
| 83 | BigStr* s;
|
| 84 | color_t color;
|
| 85 |
|
| 86 | DISALLOW_COPY_AND_ASSIGN(hnode__Leaf)
|
| 87 | };
|
| 88 |
|
| 89 | class hnode__Array : public hnode_t {
|
| 90 | public:
|
| 91 | hnode__Array(List<hnode_t*>* children)
|
| 92 | : children(children) {
|
| 93 | }
|
| 94 |
|
| 95 | static hnode__Array* CreateNull(bool alloc_lists = false) {
|
| 96 | return Alloc<hnode__Array>(alloc_lists ? Alloc<List<hnode_t*>>() : nullptr);
|
| 97 | }
|
| 98 |
|
| 99 | static constexpr ObjHeader obj_header() {
|
| 100 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Array), 1);
|
| 101 | }
|
| 102 |
|
| 103 | List<hnode_t*>* children;
|
| 104 |
|
| 105 | DISALLOW_COPY_AND_ASSIGN(hnode__Array)
|
| 106 | };
|
| 107 |
|
| 108 | class hnode__Record : public hnode_t {
|
| 109 | public:
|
| 110 | hnode__Record(BigStr* node_type, BigStr* left, BigStr* right, List<Field*>*
|
| 111 | fields, List<hnode_t*>* unnamed_fields)
|
| 112 | : node_type(node_type),
|
| 113 | left(left),
|
| 114 | right(right),
|
| 115 | fields(fields),
|
| 116 | unnamed_fields(unnamed_fields) {
|
| 117 | }
|
| 118 |
|
| 119 | static hnode__Record* CreateNull(bool alloc_lists = false) {
|
| 120 | return Alloc<hnode__Record>(kEmptyString, kEmptyString, kEmptyString,
|
| 121 | alloc_lists ? Alloc<List<Field*>>() : nullptr,
|
| 122 | nullptr);
|
| 123 | }
|
| 124 |
|
| 125 | static constexpr ObjHeader obj_header() {
|
| 126 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Record), 5);
|
| 127 | }
|
| 128 |
|
| 129 | BigStr* node_type;
|
| 130 | BigStr* left;
|
| 131 | BigStr* right;
|
| 132 | List<Field*>* fields;
|
| 133 | List<hnode_t*>* unnamed_fields;
|
| 134 |
|
| 135 | DISALLOW_COPY_AND_ASSIGN(hnode__Record)
|
| 136 | };
|
| 137 |
|
| 138 | ASDL_NAMES hnode {
|
| 139 | typedef hnode__AlreadySeen AlreadySeen;
|
| 140 | typedef hnode__Leaf Leaf;
|
| 141 | typedef hnode__Array Array;
|
| 142 | typedef hnode__Record Record;
|
| 143 | };
|
| 144 |
|
| 145 | enum class alloc_members_e {
|
| 146 | List = 1,
|
| 147 | Dict = 2,
|
| 148 | Struct = 3,
|
| 149 | };
|
| 150 | typedef alloc_members_e alloc_members_t;
|
| 151 |
|
| 152 | class Field {
|
| 153 | public:
|
| 154 | Field(BigStr* name, hnode_t* val)
|
| 155 | : name(name),
|
| 156 | val(val) {
|
| 157 | }
|
| 158 |
|
| 159 | static Field* CreateNull(bool alloc_lists = false) {
|
| 160 | return Alloc<Field>(kEmptyString, nullptr);
|
| 161 | }
|
| 162 |
|
| 163 | static constexpr ObjHeader obj_header() {
|
| 164 | return ObjHeader::AsdlClass(64, 2);
|
| 165 | }
|
| 166 |
|
| 167 | BigStr* name;
|
| 168 | hnode_t* val;
|
| 169 |
|
| 170 | DISALLOW_COPY_AND_ASSIGN(Field)
|
| 171 | };
|
| 172 |
|
| 173 |
|
| 174 | } // namespace hnode_asdl
|
| 175 |
|
| 176 | #endif // HNODE_ASDL
|