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

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