OILS / _gen / data_lang / nil8.asdl.h View on Github | oilshell.org

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