@@ -52,7 +52,7 @@ JsonObjects::JsonObjects() {
52
52
field_aliases = insert_array_field (toplevel, " field_aliases" );
53
53
}
54
54
55
- Util::JsonArray* JsonObjects::get_field_list_contents (unsigned id) const {
55
+ Util::JsonArray * JsonObjects::get_field_list_contents (unsigned id) const {
56
56
for (auto e : *field_lists) {
57
57
auto obj = e->to <Util::JsonObject>();
58
58
auto val = obj->get (" id" )->to <Util::JsonValue>();
@@ -63,7 +63,7 @@ Util::JsonArray* JsonObjects::get_field_list_contents(unsigned id) const {
63
63
return nullptr ;
64
64
}
65
65
66
- Util::JsonObject* JsonObjects::find_object_by_name (Util::JsonArray* array, const cstring& name) {
66
+ Util::JsonObject * JsonObjects::find_object_by_name (Util::JsonArray * array, const cstring & name) {
67
67
for (auto e : *array) {
68
68
auto obj = e->to <Util::JsonObject>();
69
69
auto val = obj->get (" name" )->to <Util::JsonValue>();
@@ -75,25 +75,25 @@ Util::JsonObject* JsonObjects::find_object_by_name(Util::JsonArray* array, const
75
75
}
76
76
77
77
// / Insert a json array to a parent object under key 'name'.
78
- Util::JsonArray* JsonObjects::insert_array_field (Util::JsonObject* parent, cstring name) {
78
+ Util::JsonArray * JsonObjects::insert_array_field (Util::JsonObject * parent, cstring name) {
79
79
auto result = new Util::JsonArray ();
80
80
parent->emplace (name, result);
81
81
return result;
82
82
}
83
83
84
84
// / Append a json array to a parent json array.
85
- Util::JsonArray* JsonObjects::append_array (Util::JsonArray* parent) {
85
+ Util::JsonArray * JsonObjects::append_array (Util::JsonArray * parent) {
86
86
auto result = new Util::JsonArray ();
87
87
parent->append (result);
88
88
return result;
89
89
}
90
90
91
91
// / Insert a json array named 'parameters' in a parent json object.
92
- Util::JsonArray* JsonObjects::create_parameters (Util::JsonObject* object) {
92
+ Util::JsonArray * JsonObjects::create_parameters (Util::JsonObject * object) {
93
93
return insert_array_field (object, " parameters" );
94
94
}
95
95
96
- void JsonObjects::add_program_info (const cstring& name) { toplevel->emplace (" program" , name); }
96
+ void JsonObjects::add_program_info (const cstring & name) { toplevel->emplace (" program" , name); }
97
97
98
98
void JsonObjects::add_meta_info () {
99
99
static constexpr int version_major = JSON_MAJOR_VERSION;
@@ -113,7 +113,7 @@ void JsonObjects::add_meta_info() {
113
113
* if 0 header does not contain varbit fields
114
114
* @param fields a JsonArray for the fields in the header
115
115
*/
116
- unsigned JsonObjects::add_header_type (const cstring& name, Util::JsonArray*& fields,
116
+ unsigned JsonObjects::add_header_type (const cstring & name, Util::JsonArray *& fields,
117
117
unsigned max_length) {
118
118
std::string sname (name, name.size ());
119
119
auto header_type_id_it = header_type_id.find (sname);
@@ -136,7 +136,7 @@ unsigned JsonObjects::add_header_type(const cstring& name, Util::JsonArray*& fie
136
136
return id;
137
137
}
138
138
139
- unsigned JsonObjects::add_union_type (const cstring& name, Util::JsonArray*& fields) {
139
+ unsigned JsonObjects::add_union_type (const cstring & name, Util::JsonArray *& fields) {
140
140
std::string sname (name, name.size ());
141
141
auto it = union_type_id.find (sname);
142
142
if (it != union_type_id.end ()) return it->second ;
@@ -156,7 +156,7 @@ unsigned JsonObjects::add_union_type(const cstring& name, Util::JsonArray*& fiel
156
156
}
157
157
158
158
// / Create a header type with empty field list.
159
- unsigned JsonObjects::add_header_type (const cstring& name) {
159
+ unsigned JsonObjects::add_header_type (const cstring & name) {
160
160
std::string sname (name, name.size ());
161
161
auto header_type_id_it = header_type_id.find (sname);
162
162
if (header_type_id_it != header_type_id.end ()) {
@@ -175,16 +175,16 @@ unsigned JsonObjects::add_header_type(const cstring& name) {
175
175
176
176
// / Create a set of fields to an existing header type.
177
177
// / The header type is decribed by the name.
178
- void JsonObjects::add_header_field (const cstring& name, Util::JsonArray*& field) {
178
+ void JsonObjects::add_header_field (const cstring & name, Util::JsonArray *& field) {
179
179
CHECK_NULL (field);
180
- Util::JsonObject* headerType = find_object_by_name (header_types, name);
181
- Util::JsonArray* fields = headerType->get (" fields" )->to <Util::JsonArray>();
180
+ Util::JsonObject * headerType = find_object_by_name (header_types, name);
181
+ Util::JsonArray * fields = headerType->get (" fields" )->to <Util::JsonArray>();
182
182
BUG_CHECK (fields != nullptr , " header '%1%' not found" , name);
183
183
fields->append (field);
184
184
}
185
185
186
186
// / Create a header instance in json.
187
- unsigned JsonObjects::add_header (const cstring& type, const cstring& name) {
187
+ unsigned JsonObjects::add_header (const cstring & type, const cstring & name) {
188
188
auto header = new Util::JsonObject ();
189
189
unsigned id = BMV2::nextId (" headers" );
190
190
LOG1 (" add header id " << id);
@@ -198,8 +198,8 @@ unsigned JsonObjects::add_header(const cstring& type, const cstring& name) {
198
198
}
199
199
200
200
// / Create a header_union instance in json.
201
- unsigned JsonObjects::add_union (const cstring& type, Util::JsonArray*& headers,
202
- const cstring& name) {
201
+ unsigned JsonObjects::add_union (const cstring & type, Util::JsonArray *& headers,
202
+ const cstring & name) {
203
203
auto u = new Util::JsonObject ();
204
204
unsigned id = BMV2::nextId (" header_unions" );
205
205
LOG3 (" add header_union id " << id);
@@ -212,7 +212,7 @@ unsigned JsonObjects::add_union(const cstring& type, Util::JsonArray*& headers,
212
212
return id;
213
213
}
214
214
215
- unsigned JsonObjects::add_metadata (const cstring& type, const cstring& name) {
215
+ unsigned JsonObjects::add_metadata (const cstring & type, const cstring & name) {
216
216
auto header = new Util::JsonObject ();
217
217
unsigned id = BMV2::nextId (" headers" );
218
218
LOG3 (" add metadata header id " << id);
@@ -225,8 +225,8 @@ unsigned JsonObjects::add_metadata(const cstring& type, const cstring& name) {
225
225
return id;
226
226
}
227
227
228
- void JsonObjects::add_header_stack (const cstring& type, const cstring& name, const unsigned size,
229
- const std::vector<unsigned >& ids) {
228
+ void JsonObjects::add_header_stack (const cstring & type, const cstring & name, const unsigned size,
229
+ const std::vector<unsigned > & ids) {
230
230
auto stack = new Util::JsonObject ();
231
231
unsigned id = BMV2::nextId (" stack" );
232
232
stack->emplace (" name" , name);
@@ -241,8 +241,8 @@ void JsonObjects::add_header_stack(const cstring& type, const cstring& name, con
241
241
header_stacks->append (stack);
242
242
}
243
243
244
- void JsonObjects::add_header_union_stack (const cstring& type, const cstring& name,
245
- const unsigned size, const std::vector<unsigned >& ids) {
244
+ void JsonObjects::add_header_union_stack (const cstring & type, const cstring & name,
245
+ const unsigned size, const std::vector<unsigned > & ids) {
246
246
auto stack = new Util::JsonObject ();
247
247
unsigned id = BMV2::nextId (" union_stack" );
248
248
stack->emplace (" name" , name);
@@ -258,18 +258,18 @@ void JsonObjects::add_header_union_stack(const cstring& type, const cstring& nam
258
258
}
259
259
260
260
// / Add an error to json.
261
- void JsonObjects::add_error (const cstring& name, const unsigned type) {
261
+ void JsonObjects::add_error (const cstring & name, const unsigned type) {
262
262
auto arr = append_array (errors);
263
263
arr->append (name);
264
264
arr->append (type);
265
265
}
266
266
267
267
// / Add a single enum entry to json.
268
268
// / A enum entry is identified with { enum_name, entry_name, entry_value }
269
- void JsonObjects::add_enum (const cstring& enum_name, const cstring& entry_name,
269
+ void JsonObjects::add_enum (const cstring & enum_name, const cstring & entry_name,
270
270
const unsigned entry_value) {
271
271
// look up enum in json by name
272
- Util::JsonObject* enum_json = find_object_by_name (enums, enum_name);
272
+ Util::JsonObject * enum_json = find_object_by_name (enums, enum_name);
273
273
if (enum_json == nullptr ) { // first entry in a new enum
274
274
enum_json = new Util::JsonObject ();
275
275
enum_json->emplace (" name" , enum_name);
@@ -290,7 +290,7 @@ void JsonObjects::add_enum(const cstring& enum_name, const cstring& entry_name,
290
290
}
291
291
}
292
292
293
- unsigned JsonObjects::add_parser (const cstring& name) {
293
+ unsigned JsonObjects::add_parser (const cstring & name) {
294
294
auto parser = new Util::JsonObject ();
295
295
unsigned id = BMV2::nextId (" parser" );
296
296
parser->emplace (" name" , name);
@@ -306,7 +306,7 @@ unsigned JsonObjects::add_parser(const cstring& name) {
306
306
307
307
// / insert parser state into a parser identified by parser_id
308
308
// / return the id of the parser state
309
- unsigned JsonObjects::add_parser_state (const unsigned parser_id, const cstring& state_name) {
309
+ unsigned JsonObjects::add_parser_state (const unsigned parser_id, const cstring & state_name) {
310
310
if (map_parser.find (parser_id) == map_parser.end ()) BUG (" parser %1% not found." , parser_id);
311
311
auto parser = map_parser[parser_id];
312
312
auto states = parser->get (" parse_states" )->to <Util::JsonArray>();
@@ -326,7 +326,7 @@ unsigned JsonObjects::add_parser_state(const unsigned parser_id, const cstring&
326
326
return state_id;
327
327
}
328
328
329
- void JsonObjects::add_parser_transition (const unsigned state_id, Util::IJson* transition) {
329
+ void JsonObjects::add_parser_transition (const unsigned state_id, Util::IJson * transition) {
330
330
if (map_parser_state.find (state_id) == map_parser_state.end ())
331
331
BUG (" parser state %1% not found." , state_id);
332
332
auto state = map_parser_state[state_id];
@@ -337,7 +337,7 @@ void JsonObjects::add_parser_transition(const unsigned state_id, Util::IJson* tr
337
337
transitions->append (trans);
338
338
}
339
339
340
- void JsonObjects::add_parser_op (const unsigned state_id, Util::IJson* op) {
340
+ void JsonObjects::add_parser_op (const unsigned state_id, Util::IJson * op) {
341
341
if (map_parser_state.find (state_id) == map_parser_state.end ())
342
342
BUG (" parser state %1% not found." , state_id);
343
343
auto state = map_parser_state[state_id];
@@ -346,7 +346,7 @@ void JsonObjects::add_parser_op(const unsigned state_id, Util::IJson* op) {
346
346
statements->append (op);
347
347
}
348
348
349
- void JsonObjects::add_parser_transition_key (const unsigned state_id, Util::IJson* newKey) {
349
+ void JsonObjects::add_parser_transition_key (const unsigned state_id, Util::IJson * newKey) {
350
350
if (map_parser_state.find (state_id) != map_parser_state.end ()) {
351
351
auto state = map_parser_state[state_id];
352
352
auto keys = state->get (" transition_key" )->to <Util::JsonArray>();
@@ -358,8 +358,8 @@ void JsonObjects::add_parser_transition_key(const unsigned state_id, Util::IJson
358
358
}
359
359
}
360
360
361
- void JsonObjects::add_parse_vset (const cstring& name, const unsigned bitwidth,
362
- const big_int& size) {
361
+ void JsonObjects::add_parse_vset (const cstring & name, const unsigned bitwidth,
362
+ const big_int & size) {
363
363
auto parse_vset = new Util::JsonObject ();
364
364
unsigned id = BMV2::nextId (" parse_vsets" );
365
365
parse_vset->emplace (" name" , name);
@@ -369,8 +369,8 @@ void JsonObjects::add_parse_vset(const cstring& name, const unsigned bitwidth,
369
369
parse_vsets->append (parse_vset);
370
370
}
371
371
372
- unsigned JsonObjects::add_action (const cstring& name, Util::JsonArray*& params,
373
- Util::JsonArray*& body) {
372
+ unsigned JsonObjects::add_action (const cstring & name, Util::JsonArray *& params,
373
+ Util::JsonArray *& body) {
374
374
CHECK_NULL (params);
375
375
CHECK_NULL (body);
376
376
auto action = new Util::JsonObject ();
@@ -383,17 +383,17 @@ unsigned JsonObjects::add_action(const cstring& name, Util::JsonArray*& params,
383
383
return id;
384
384
}
385
385
386
- void JsonObjects::add_extern_attribute (const cstring& name, const cstring& type,
387
- const cstring& value, Util::JsonArray* attributes) {
386
+ void JsonObjects::add_extern_attribute (const cstring & name, const cstring & type,
387
+ const cstring & value, Util::JsonArray * attributes) {
388
388
auto attr = new Util::JsonObject ();
389
389
attr->emplace (" name" , name);
390
390
attr->emplace (" type" , type);
391
391
attr->emplace (" value" , value);
392
392
attributes->append (attr);
393
393
}
394
394
395
- void JsonObjects::add_extern (const cstring& name, const cstring& type,
396
- Util::JsonArray* attributes) {
395
+ void JsonObjects::add_extern (const cstring & name, const cstring & type,
396
+ Util::JsonArray * attributes) {
397
397
auto extn = new Util::JsonObject ();
398
398
unsigned id = BMV2::nextId (" extern_instances" );
399
399
extn->emplace (" name" , name);
0 commit comments