| 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 | DISALLOW_COPY_AND_ASSIGN(hnode_t)
|
| 44 | };
|
| 45 |
|
| 46 | class hnode__AlreadySeen : public hnode_t {
|
| 47 | public:
|
| 48 | hnode__AlreadySeen(int heap_id)
|
| 49 | : heap_id(heap_id) {
|
| 50 | }
|
| 51 |
|
| 52 | static hnode__AlreadySeen* CreateNull(bool alloc_lists = false) {
|
| 53 | return Alloc<hnode__AlreadySeen>(-1);
|
| 54 | }
|
| 55 |
|
| 56 | static constexpr ObjHeader obj_header() {
|
| 57 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::AlreadySeen), 0);
|
| 58 | }
|
| 59 |
|
| 60 | int heap_id;
|
| 61 |
|
| 62 | DISALLOW_COPY_AND_ASSIGN(hnode__AlreadySeen)
|
| 63 | };
|
| 64 |
|
| 65 | class hnode__Leaf : public hnode_t {
|
| 66 | public:
|
| 67 | hnode__Leaf(BigStr* s, color_t color)
|
| 68 | : s(s),
|
| 69 | color(color) {
|
| 70 | }
|
| 71 |
|
| 72 | static hnode__Leaf* CreateNull(bool alloc_lists = false) {
|
| 73 | return Alloc<hnode__Leaf>(kEmptyString, color_e::TypeName);
|
| 74 | }
|
| 75 |
|
| 76 | static constexpr ObjHeader obj_header() {
|
| 77 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Leaf), 1);
|
| 78 | }
|
| 79 |
|
| 80 | BigStr* s;
|
| 81 | color_t color;
|
| 82 |
|
| 83 | DISALLOW_COPY_AND_ASSIGN(hnode__Leaf)
|
| 84 | };
|
| 85 |
|
| 86 | class hnode__Array : public hnode_t {
|
| 87 | public:
|
| 88 | hnode__Array(List<hnode_t*>* children)
|
| 89 | : children(children) {
|
| 90 | }
|
| 91 |
|
| 92 | static hnode__Array* CreateNull(bool alloc_lists = false) {
|
| 93 | return Alloc<hnode__Array>(alloc_lists ? Alloc<List<hnode_t*>>() : nullptr);
|
| 94 | }
|
| 95 |
|
| 96 | static constexpr ObjHeader obj_header() {
|
| 97 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Array), 1);
|
| 98 | }
|
| 99 |
|
| 100 | List<hnode_t*>* children;
|
| 101 |
|
| 102 | DISALLOW_COPY_AND_ASSIGN(hnode__Array)
|
| 103 | };
|
| 104 |
|
| 105 | class hnode__Record : public hnode_t {
|
| 106 | public:
|
| 107 | hnode__Record(BigStr* node_type, BigStr* left, BigStr* right, List<Field*>*
|
| 108 | fields, List<hnode_t*>* unnamed_fields)
|
| 109 | : node_type(node_type),
|
| 110 | left(left),
|
| 111 | right(right),
|
| 112 | fields(fields),
|
| 113 | unnamed_fields(unnamed_fields) {
|
| 114 | }
|
| 115 |
|
| 116 | static hnode__Record* CreateNull(bool alloc_lists = false) {
|
| 117 | return Alloc<hnode__Record>(kEmptyString, kEmptyString, kEmptyString,
|
| 118 | alloc_lists ? Alloc<List<Field*>>() : nullptr,
|
| 119 | nullptr);
|
| 120 | }
|
| 121 |
|
| 122 | static constexpr ObjHeader obj_header() {
|
| 123 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Record), 5);
|
| 124 | }
|
| 125 |
|
| 126 | BigStr* node_type;
|
| 127 | BigStr* left;
|
| 128 | BigStr* right;
|
| 129 | List<Field*>* fields;
|
| 130 | List<hnode_t*>* unnamed_fields;
|
| 131 |
|
| 132 | DISALLOW_COPY_AND_ASSIGN(hnode__Record)
|
| 133 | };
|
| 134 |
|
| 135 | ASDL_NAMES hnode {
|
| 136 | typedef hnode__AlreadySeen AlreadySeen;
|
| 137 | typedef hnode__Leaf Leaf;
|
| 138 | typedef hnode__Array Array;
|
| 139 | typedef hnode__Record Record;
|
| 140 | };
|
| 141 |
|
| 142 | enum class alloc_members_e {
|
| 143 | List = 1,
|
| 144 | Dict = 2,
|
| 145 | Struct = 3,
|
| 146 | };
|
| 147 | typedef alloc_members_e alloc_members_t;
|
| 148 |
|
| 149 | class Field {
|
| 150 | public:
|
| 151 | Field(BigStr* name, hnode_t* val)
|
| 152 | : name(name),
|
| 153 | val(val) {
|
| 154 | }
|
| 155 |
|
| 156 | static Field* CreateNull(bool alloc_lists = false) {
|
| 157 | return Alloc<Field>(kEmptyString, nullptr);
|
| 158 | }
|
| 159 |
|
| 160 | static constexpr ObjHeader obj_header() {
|
| 161 | return ObjHeader::AsdlClass(64, 2);
|
| 162 | }
|
| 163 |
|
| 164 | BigStr* name;
|
| 165 | hnode_t* val;
|
| 166 |
|
| 167 | DISALLOW_COPY_AND_ASSIGN(Field)
|
| 168 | };
|
| 169 |
|
| 170 |
|
| 171 | } // namespace hnode_asdl
|
| 172 |
|
| 173 | #endif // HNODE_ASDL
|