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 | Record = 2,
|
30 | Array = 3,
|
31 | Subtype = 4,
|
32 | Leaf = 5,
|
33 | External = 6,
|
34 | };
|
35 | };
|
36 |
|
37 | class hnode_t {
|
38 | protected:
|
39 | hnode_t() {
|
40 | }
|
41 | public:
|
42 | int tag() const {
|
43 | return ObjHeader::FromObject(this)->type_tag;
|
44 | }
|
45 | DISALLOW_COPY_AND_ASSIGN(hnode_t)
|
46 | };
|
47 |
|
48 | class hnode__AlreadySeen : public hnode_t {
|
49 | public:
|
50 | hnode__AlreadySeen(int heap_id)
|
51 | : heap_id(heap_id) {
|
52 | }
|
53 |
|
54 | static hnode__AlreadySeen* CreateNull(bool alloc_lists = false) {
|
55 | return Alloc<hnode__AlreadySeen>(-1);
|
56 | }
|
57 |
|
58 | static constexpr ObjHeader obj_header() {
|
59 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::AlreadySeen), 0);
|
60 | }
|
61 |
|
62 | int heap_id;
|
63 |
|
64 | DISALLOW_COPY_AND_ASSIGN(hnode__AlreadySeen)
|
65 | };
|
66 |
|
67 | class hnode__Record : public hnode_t {
|
68 | public:
|
69 | hnode__Record(BigStr* node_type, List<Field*>* fields, bool abbrev, BigStr*
|
70 | left, BigStr* right, List<hnode_t*>* unnamed_fields)
|
71 | : node_type(node_type),
|
72 | fields(fields),
|
73 | left(left),
|
74 | right(right),
|
75 | unnamed_fields(unnamed_fields),
|
76 | abbrev(abbrev) {
|
77 | }
|
78 |
|
79 | static hnode__Record* CreateNull(bool alloc_lists = false) {
|
80 | return Alloc<hnode__Record>(kEmptyString, alloc_lists ?
|
81 | Alloc<List<Field*>>() : nullptr, false,
|
82 | kEmptyString, kEmptyString, alloc_lists ?
|
83 | Alloc<List<hnode_t*>>() : nullptr);
|
84 | }
|
85 |
|
86 | static constexpr ObjHeader obj_header() {
|
87 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Record), 5);
|
88 | }
|
89 |
|
90 | BigStr* node_type;
|
91 | List<Field*>* fields;
|
92 | BigStr* left;
|
93 | BigStr* right;
|
94 | List<hnode_t*>* unnamed_fields;
|
95 | bool abbrev;
|
96 |
|
97 | DISALLOW_COPY_AND_ASSIGN(hnode__Record)
|
98 | };
|
99 |
|
100 | class hnode__Array : public hnode_t {
|
101 | public:
|
102 | hnode__Array(List<hnode_t*>* children)
|
103 | : children(children) {
|
104 | }
|
105 |
|
106 | static hnode__Array* CreateNull(bool alloc_lists = false) {
|
107 | return Alloc<hnode__Array>(alloc_lists ? Alloc<List<hnode_t*>>() : nullptr);
|
108 | }
|
109 |
|
110 | static constexpr ObjHeader obj_header() {
|
111 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Array), 1);
|
112 | }
|
113 |
|
114 | List<hnode_t*>* children;
|
115 |
|
116 | DISALLOW_COPY_AND_ASSIGN(hnode__Array)
|
117 | };
|
118 |
|
119 | class hnode__Subtype : public hnode_t {
|
120 | public:
|
121 | hnode__Subtype(BigStr* node_type, List<hnode_t*>* children)
|
122 | : node_type(node_type),
|
123 | children(children) {
|
124 | }
|
125 |
|
126 | static hnode__Subtype* CreateNull(bool alloc_lists = false) {
|
127 | return Alloc<hnode__Subtype>(kEmptyString, alloc_lists ?
|
128 | Alloc<List<hnode_t*>>() : nullptr);
|
129 | }
|
130 |
|
131 | static constexpr ObjHeader obj_header() {
|
132 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Subtype), 2);
|
133 | }
|
134 |
|
135 | BigStr* node_type;
|
136 | List<hnode_t*>* children;
|
137 |
|
138 | DISALLOW_COPY_AND_ASSIGN(hnode__Subtype)
|
139 | };
|
140 |
|
141 | class hnode__Leaf : public hnode_t {
|
142 | public:
|
143 | hnode__Leaf(BigStr* s, color_t color)
|
144 | : s(s),
|
145 | color(color) {
|
146 | }
|
147 |
|
148 | static hnode__Leaf* CreateNull(bool alloc_lists = false) {
|
149 | return Alloc<hnode__Leaf>(kEmptyString, color_e::TypeName);
|
150 | }
|
151 |
|
152 | static constexpr ObjHeader obj_header() {
|
153 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::Leaf), 1);
|
154 | }
|
155 |
|
156 | BigStr* s;
|
157 | color_t color;
|
158 |
|
159 | DISALLOW_COPY_AND_ASSIGN(hnode__Leaf)
|
160 | };
|
161 |
|
162 | class hnode__External : public hnode_t {
|
163 | public:
|
164 | hnode__External(void* obj)
|
165 | : obj(obj) {
|
166 | }
|
167 |
|
168 | static hnode__External* CreateNull(bool alloc_lists = false) {
|
169 | return Alloc<hnode__External>(nullptr);
|
170 | }
|
171 |
|
172 | static constexpr ObjHeader obj_header() {
|
173 | return ObjHeader::AsdlClass(static_cast<uint16_t>(hnode_e::External), 1);
|
174 | }
|
175 |
|
176 | void* obj;
|
177 |
|
178 | DISALLOW_COPY_AND_ASSIGN(hnode__External)
|
179 | };
|
180 |
|
181 | ASDL_NAMES hnode {
|
182 | typedef hnode__AlreadySeen AlreadySeen;
|
183 | typedef hnode__Record Record;
|
184 | typedef hnode__Array Array;
|
185 | typedef hnode__Subtype Subtype;
|
186 | typedef hnode__Leaf Leaf;
|
187 | typedef hnode__External External;
|
188 | };
|
189 |
|
190 | enum class alloc_members_e {
|
191 | List = 1,
|
192 | Dict = 2,
|
193 | Struct = 3,
|
194 | };
|
195 | typedef alloc_members_e alloc_members_t;
|
196 |
|
197 | class Field {
|
198 | public:
|
199 | Field(BigStr* name, hnode_t* val)
|
200 | : name(name),
|
201 | val(val) {
|
202 | }
|
203 |
|
204 | static Field* CreateNull(bool alloc_lists = false) {
|
205 | return Alloc<Field>(kEmptyString, nullptr);
|
206 | }
|
207 |
|
208 | static constexpr ObjHeader obj_header() {
|
209 | return ObjHeader::AsdlClass(64, 2);
|
210 | }
|
211 |
|
212 | BigStr* name;
|
213 | hnode_t* val;
|
214 |
|
215 | DISALLOW_COPY_AND_ASSIGN(Field)
|
216 | };
|
217 |
|
218 |
|
219 | } // namespace hnode_asdl
|
220 |
|
221 | #endif // HNODE_ASDL
|