@@ -210,28 +210,18 @@ string_dependenciest::node_at(const array_string_exprt &e) const
210
210
return {};
211
211
}
212
212
213
- string_dependenciest::builtin_function_nodet string_dependenciest::make_node (
213
+ string_dependenciest::builtin_function_nodet & string_dependenciest::make_node (
214
214
std::unique_ptr<string_builtin_functiont> &builtin_function)
215
215
{
216
- const builtin_function_nodet builtin_function_node (
217
- builtin_function_nodes.size ());
218
- builtin_function_nodes.emplace_back ();
219
- builtin_function_nodes.back ().swap (builtin_function);
220
- return builtin_function_node;
216
+ builtin_function_nodes.emplace_back (
217
+ std::move (builtin_function), builtin_function_nodes.size ());
218
+ return builtin_function_nodes.back ();
221
219
}
222
220
223
221
const string_builtin_functiont &string_dependenciest::get_builtin_function (
224
222
const builtin_function_nodet &node) const
225
223
{
226
- PRECONDITION (node.index < builtin_function_nodes.size ());
227
- return *(builtin_function_nodes[node.index ]);
228
- }
229
-
230
- const std::vector<string_dependenciest::builtin_function_nodet> &
231
- string_dependenciest::dependencies (
232
- const string_dependenciest::string_nodet &node) const
233
- {
234
- return node.dependencies ;
224
+ return *node.data ;
235
225
}
236
226
237
227
void string_dependenciest::add_dependency (
@@ -248,7 +238,7 @@ void string_dependenciest::add_dependency(
248
238
return ;
249
239
}
250
240
string_nodet &string_node = get_node (e);
251
- string_node.dependencies .push_back (builtin_function_node);
241
+ string_node.dependencies .push_back (builtin_function_node. index );
252
242
}
253
243
254
244
static void add_dependency_to_string_subexprs (
@@ -299,7 +289,7 @@ optionalt<exprt> string_dependenciest::eval(
299
289
const auto &f = node.result_from ;
300
290
if (f && node.dependencies .size () == 1 )
301
291
{
302
- const auto value_opt = get_builtin_function (*f). eval (get_value);
292
+ const auto value_opt = builtin_function_nodes[*f]. data -> eval (get_value);
303
293
eval_string_cache[it->second ] = value_opt;
304
294
return value_opt;
305
295
}
@@ -336,7 +326,7 @@ bool add_node(
336
326
{
337
327
dependencies.add_dependency (*string_result, builtin_function_node);
338
328
auto &node = dependencies.get_node (*string_result);
339
- node.result_from = builtin_function_node;
329
+ node.result_from = builtin_function_node. index ;
340
330
}
341
331
else
342
332
add_dependency_to_string_subexprs (
@@ -352,7 +342,7 @@ void string_dependenciest::for_each_successor(
352
342
if (node.kind == nodet::BUILTIN)
353
343
{
354
344
const auto &builtin = builtin_function_nodes[node.index ];
355
- for (const auto &s : builtin->string_arguments ())
345
+ for (const auto &s : builtin. data ->string_arguments ())
356
346
{
357
347
std::vector<std::reference_wrapper<const exprt>> stack ({s});
358
348
while (!stack.empty ())
@@ -377,7 +367,9 @@ void string_dependenciest::for_each_successor(
377
367
std::for_each (
378
368
s_node.dependencies .begin (),
379
369
s_node.dependencies .end (),
380
- [&](const builtin_function_nodet &p) { f (nodet (p)); });
370
+ [&](const std::size_t &index ) { // NOLINT
371
+ f (nodet (builtin_function_nodes[index ]));
372
+ });
381
373
}
382
374
else
383
375
UNREACHABLE;
@@ -389,7 +381,7 @@ void string_dependenciest::for_each_node(
389
381
for (const auto string_node : string_nodes)
390
382
f (nodet (string_node));
391
383
for (std::size_t i = 0 ; i < builtin_function_nodes.size (); ++i)
392
- f (nodet (builtin_function_nodet (i) ));
384
+ f (nodet (builtin_function_nodes[i] ));
393
385
}
394
386
395
387
void string_dependenciest::output_dot (std::ostream &stream) const
@@ -405,7 +397,7 @@ void string_dependenciest::output_dot(std::ostream &stream) const
405
397
const auto node_to_string = [&](const nodet &n) { // NOLINT
406
398
std::stringstream ostream;
407
399
if (n.kind == nodet::BUILTIN)
408
- ostream << builtin_function_nodes[n.index ]->name () << n.index ;
400
+ ostream << builtin_function_nodes[n.index ]. data ->name () << n.index ;
409
401
else
410
402
ostream << ' "' << format (string_nodes[n.index ].expr ) << ' "' ;
411
403
return ostream.str ();
@@ -420,7 +412,7 @@ void string_dependenciest::add_constraints(
420
412
{
421
413
for (const auto &builtin : builtin_function_nodes)
422
414
{
423
- const exprt return_value = builtin->add_constraints (generator);
424
- generator.add_lemma (equal_exprt (return_value, builtin->return_code ));
415
+ const exprt return_value = builtin. data ->add_constraints (generator);
416
+ generator.add_lemma (equal_exprt (return_value, builtin. data ->return_code ));
425
417
}
426
418
}
0 commit comments