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

230 lines, 143 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 0;
42 }
43 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
44 DISALLOW_COPY_AND_ASSIGN(nvalue_t)
45};
46
47class nvalue__Null : public nvalue_t {
48 public:
49 nvalue__Null() {}
50
51 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
52
53 static constexpr ObjHeader obj_header() {
54 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Null), 0);
55 }
56
57
58 DISALLOW_COPY_AND_ASSIGN(nvalue__Null)
59};
60
61class nvalue__Bool : public nvalue_t {
62 public:
63 nvalue__Bool(bool b)
64 : b(b) {
65 }
66
67 static nvalue__Bool* CreateNull(bool alloc_lists = false) {
68 return Alloc<nvalue__Bool>(false);
69 }
70
71 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
72
73 static constexpr ObjHeader obj_header() {
74 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Bool), 0);
75 }
76
77 bool b;
78
79 DISALLOW_COPY_AND_ASSIGN(nvalue__Bool)
80};
81
82class nvalue__Int : public nvalue_t {
83 public:
84 nvalue__Int(int i)
85 : i(i) {
86 }
87
88 static nvalue__Int* CreateNull(bool alloc_lists = false) {
89 return Alloc<nvalue__Int>(-1);
90 }
91
92 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
93
94 static constexpr ObjHeader obj_header() {
95 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Int), 0);
96 }
97
98 int i;
99
100 DISALLOW_COPY_AND_ASSIGN(nvalue__Int)
101};
102
103class nvalue__Float : public nvalue_t {
104 public:
105 nvalue__Float(double f)
106 : f(f) {
107 }
108
109 static nvalue__Float* CreateNull(bool alloc_lists = false) {
110 return Alloc<nvalue__Float>(0.0);
111 }
112
113 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
114
115 static constexpr ObjHeader obj_header() {
116 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Float), 0);
117 }
118
119 double f;
120
121 DISALLOW_COPY_AND_ASSIGN(nvalue__Float)
122};
123
124class nvalue__Str : public nvalue_t {
125 public:
126 nvalue__Str(BigStr* s)
127 : s(s) {
128 }
129
130 static nvalue__Str* CreateNull(bool alloc_lists = false) {
131 return Alloc<nvalue__Str>(kEmptyString);
132 }
133
134 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
135
136 static constexpr ObjHeader obj_header() {
137 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Str), 1);
138 }
139
140 BigStr* s;
141
142 DISALLOW_COPY_AND_ASSIGN(nvalue__Str)
143};
144
145class nvalue__Symbol : public nvalue_t {
146 public:
147 nvalue__Symbol(BigStr* s)
148 : s(s) {
149 }
150
151 static nvalue__Symbol* CreateNull(bool alloc_lists = false) {
152 return Alloc<nvalue__Symbol>(kEmptyString);
153 }
154
155 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
156
157 static constexpr ObjHeader obj_header() {
158 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Symbol), 1);
159 }
160
161 BigStr* s;
162
163 DISALLOW_COPY_AND_ASSIGN(nvalue__Symbol)
164};
165
166class nvalue__List : public nvalue_t {
167 public:
168 nvalue__List(List<nvalue_t*>* items)
169 : items(items) {
170 }
171
172 static nvalue__List* CreateNull(bool alloc_lists = false) {
173 return Alloc<nvalue__List>(alloc_lists ? Alloc<List<nvalue_t*>>() :
174 nullptr);
175 }
176
177 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
178
179 static constexpr ObjHeader obj_header() {
180 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::List), 1);
181 }
182
183 List<nvalue_t*>* items;
184
185 DISALLOW_COPY_AND_ASSIGN(nvalue__List)
186};
187
188class nvalue__Record : public nvalue_t {
189 public:
190 nvalue__Record(BigStr* name, List<nvalue_t*>* args, Dict<BigStr*, nvalue_t*>*
191 named)
192 : name(name),
193 args(args),
194 named(named) {
195 }
196
197 static nvalue__Record* CreateNull(bool alloc_lists = false) {
198 return Alloc<nvalue__Record>(kEmptyString, alloc_lists ?
199 Alloc<List<nvalue_t*>>() : nullptr, nullptr);
200 }
201
202 hnode_t* PrettyTree(bool do_abbrev, Dict<int, bool>* seen = nullptr);
203
204 static constexpr ObjHeader obj_header() {
205 return ObjHeader::AsdlClass(static_cast<uint16_t>(nvalue_e::Record), 3);
206 }
207
208 BigStr* name;
209 List<nvalue_t*>* args;
210 Dict<BigStr*, nvalue_t*>* named;
211
212 DISALLOW_COPY_AND_ASSIGN(nvalue__Record)
213};
214
215extern GcGlobal<nvalue__Null> gnvalue__Null;
216ASDL_NAMES nvalue {
217 static nvalue__Null* Null;
218 typedef nvalue__Bool Bool;
219 typedef nvalue__Int Int;
220 typedef nvalue__Float Float;
221 typedef nvalue__Str Str;
222 typedef nvalue__Symbol Symbol;
223 typedef nvalue__List List;
224 typedef nvalue__Record Record;
225};
226
227
228} // namespace nil8_asdl
229
230#endif // NIL8_ASDL