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

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