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

255 lines, 159 significant
1// _gen/data_lang/nil8.asdl.h is generated by asdl_main.py
2
3#ifndef NIL8_ASDL
4#define NIL8_ASDL
5
6#include <cstdint>
7
8#include "mycpp/runtime.h"
9#include "asdl/cpp_runtime.h"
10namespace nil8_asdl {
11
12// use struct instead of namespace so 'using' works consistently
13#define ASDL_NAMES struct
14
15class nvalue_t;
16
17ASDL_NAMES nvalue_e {
18 enum no_name {
19 Null = 1,
20 Bool = 2,
21 Int = 3,
22 Float = 4,
23 Str = 5,
24 Symbol = 6,
25 List = 7,
26 Record = 8,
27 };
28};
29
30BigStr* nvalue_str(int tag, bool dot = true);
31
32class nvalue_t {
33 protected:
34 nvalue_t() {
35 }
36 public:
37 int tag() const {
38 return ObjHeader::FromObject(this)->type_tag;
39 }
40 constexpr int sum_type_id() {
41 return 256;
42 }
43 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
44
45 DISALLOW_COPY_AND_ASSIGN(nvalue_t)
46};
47
48class nvalue__Null : public nvalue_t {
49 public:
50 nvalue__Null() {}
51
52 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
53
54 int type_id() {
55 return this->sum_type_id() + this->tag();
56 }
57
58 static constexpr ObjHeader obj_header() {
59 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Null), 0);
60 }
61
62 DISALLOW_COPY_AND_ASSIGN(nvalue__Null)
63};
64
65class nvalue__Bool : public nvalue_t {
66 public:
67 nvalue__Bool(bool b)
68 : b(b) {
69 }
70
71 static nvalue__Bool* CreateNull(bool alloc_lists = false) {
72 return Alloc<nvalue__Bool>(false);
73 }
74
75 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
76
77 int type_id() {
78 return this->sum_type_id() + this->tag();
79 }
80
81 static constexpr ObjHeader obj_header() {
82 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Bool), 0);
83 }
84 bool b;
85
86 DISALLOW_COPY_AND_ASSIGN(nvalue__Bool)
87};
88
89class nvalue__Int : public nvalue_t {
90 public:
91 nvalue__Int(int i)
92 : i(i) {
93 }
94
95 static nvalue__Int* CreateNull(bool alloc_lists = false) {
96 return Alloc<nvalue__Int>(-1);
97 }
98
99 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
100
101 int type_id() {
102 return this->sum_type_id() + this->tag();
103 }
104
105 static constexpr ObjHeader obj_header() {
106 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Int), 0);
107 }
108 int i;
109
110 DISALLOW_COPY_AND_ASSIGN(nvalue__Int)
111};
112
113class nvalue__Float : public nvalue_t {
114 public:
115 nvalue__Float(double f)
116 : f(f) {
117 }
118
119 static nvalue__Float* CreateNull(bool alloc_lists = false) {
120 return Alloc<nvalue__Float>(0.0);
121 }
122
123 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
124
125 int type_id() {
126 return this->sum_type_id() + this->tag();
127 }
128
129 static constexpr ObjHeader obj_header() {
130 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Float), 0);
131 }
132 double f;
133
134 DISALLOW_COPY_AND_ASSIGN(nvalue__Float)
135};
136
137class nvalue__Str : public nvalue_t {
138 public:
139 nvalue__Str(BigStr* s)
140 : s(s) {
141 }
142
143 static nvalue__Str* CreateNull(bool alloc_lists = false) {
144 return Alloc<nvalue__Str>(kEmptyString);
145 }
146
147 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
148
149 int type_id() {
150 return this->sum_type_id() + this->tag();
151 }
152
153 static constexpr ObjHeader obj_header() {
154 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Str), 1);
155 }
156 BigStr* s;
157
158 DISALLOW_COPY_AND_ASSIGN(nvalue__Str)
159};
160
161class nvalue__Symbol : public nvalue_t {
162 public:
163 nvalue__Symbol(BigStr* s)
164 : s(s) {
165 }
166
167 static nvalue__Symbol* CreateNull(bool alloc_lists = false) {
168 return Alloc<nvalue__Symbol>(kEmptyString);
169 }
170
171 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
172
173 int type_id() {
174 return this->sum_type_id() + this->tag();
175 }
176
177 static constexpr ObjHeader obj_header() {
178 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Symbol), 1);
179 }
180 BigStr* s;
181
182 DISALLOW_COPY_AND_ASSIGN(nvalue__Symbol)
183};
184
185class nvalue__List : public nvalue_t {
186 public:
187 nvalue__List(List<nvalue_t*>* items)
188 : items(items) {
189 }
190
191 static nvalue__List* CreateNull(bool alloc_lists = false) {
192 return Alloc<nvalue__List>(alloc_lists ? Alloc<List<nvalue_t*>>() :
193 nullptr);
194 }
195
196 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
197
198 int type_id() {
199 return this->sum_type_id() + this->tag();
200 }
201
202 static constexpr ObjHeader obj_header() {
203 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::List), 1);
204 }
205 List<nvalue_t*>* items;
206
207 DISALLOW_COPY_AND_ASSIGN(nvalue__List)
208};
209
210class nvalue__Record : public nvalue_t {
211 public:
212 nvalue__Record(BigStr* name, List<nvalue_t*>* args, Dict<BigStr*, nvalue_t*>*
213 named)
214 : name(name),
215 args(args),
216 named(named) {
217 }
218
219 static nvalue__Record* CreateNull(bool alloc_lists = false) {
220 return Alloc<nvalue__Record>(kEmptyString, alloc_lists ?
221 Alloc<List<nvalue_t*>>() : nullptr, nullptr);
222 }
223
224 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
225
226 int type_id() {
227 return this->sum_type_id() + this->tag();
228 }
229
230 static constexpr ObjHeader obj_header() {
231 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Record), 3);
232 }
233 BigStr* name;
234 List<nvalue_t*>* args;
235 Dict<BigStr*, nvalue_t*>* named;
236
237 DISALLOW_COPY_AND_ASSIGN(nvalue__Record)
238};
239
240extern GcGlobal<nvalue__Null> gnvalue__Null;
241ASDL_NAMES nvalue {
242 static nvalue__Null* Null;
243 typedef nvalue__Bool Bool;
244 typedef nvalue__Int Int;
245 typedef nvalue__Float Float;
246 typedef nvalue__Str Str;
247 typedef nvalue__Symbol Symbol;
248 typedef nvalue__List List;
249 typedef nvalue__Record Record;
250};
251
252
253} // namespace nil8_asdl
254
255#endif // NIL8_ASDL