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

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