@@ -252,34 +252,27 @@ Function: random_tracest::inputs
252
252
random_tracest::inputst random_tracest::inputs () const
253
253
{
254
254
inputst inputs;
255
- const symbol_tablet &symbol_table = ns.get_symbol_table ();
256
255
257
- auto module_identifier = transition_system.main_symbol ->name ;
258
- auto lower = symbol_table.symbol_module_map .lower_bound (module_identifier);
259
- auto upper = symbol_table.symbol_module_map .upper_bound (module_identifier);
256
+ const auto &module_symbol = *transition_system.main_symbol ;
260
257
261
- // We need a deterministic ordering of the inputs that's
262
- // portable accross implementations. We use irep_idt::compare.
263
- std::vector<irep_idt> input_identifiers ;
258
+ if (module_symbol. type . id () != ID_module)
259
+ throw ebmc_errort () << " expected a module but got "
260
+ << module_symbol. type . id () ;
264
261
265
- for (auto it = lower; it != upper; it++)
266
- {
267
- const symbolt &symbol = ns.lookup (it->second );
262
+ const auto &ports = module_symbol.type .find (ID_ports);
268
263
269
- if (symbol.is_input )
270
- input_identifiers.push_back (symbol.name );
264
+ // filter out the inputs
265
+ for (auto &port : static_cast <const exprt &>(ports).operands ())
266
+ {
267
+ DATA_INVARIANT (port.id () == ID_symbol, " port must be a symbol" );
268
+ if (port.get_bool (ID_input) && !port.get_bool (ID_output))
269
+ {
270
+ symbol_exprt input_symbol (port.get (ID_identifier), port.type ());
271
+ input_symbol.add_source_location () = port.source_location ();
272
+ inputs.push_back (std::move (input_symbol));
273
+ }
271
274
}
272
275
273
- // sort by identifier
274
- std::sort (
275
- input_identifiers.begin (),
276
- input_identifiers.end (),
277
- [](const irep_idt &a, const irep_idt &b) { return a.compare (b) < 0 ; });
278
-
279
- // turn into symbol_exprt
280
- for (auto identifier : input_identifiers)
281
- inputs.push_back (ns.lookup (identifier).symbol_expr ());
282
-
283
276
return inputs;
284
277
}
285
278
@@ -336,7 +329,9 @@ std::vector<exprt> random_tracest::random_input_constraints(
336
329
auto input_in_timeframe = instantiate (input, i, number_of_timeframes, ns);
337
330
auto constraint =
338
331
equal_exprt (input_in_timeframe, random_value (input.type ()));
339
- result.push_back (solver.handle (constraint));
332
+ auto handle = solver.handle (constraint);
333
+ CHECK_RETURN (handle.id () == ID_literal);
334
+ result.push_back (handle);
340
335
}
341
336
}
342
337
@@ -382,6 +377,9 @@ void random_tracest::operator()(
382
377
383
378
auto inputs = this ->inputs ();
384
379
380
+ if (inputs.empty ())
381
+ throw ebmc_errort () << " module does not have inputs" ;
382
+
385
383
message.statistics () << " Found " << inputs.size () << " input(s)"
386
384
<< messaget::eom;
387
385
0 commit comments