@@ -72,23 +72,22 @@ symbol_exprt timeframe_symbol(const mp_integer &timeframe, symbol_exprt src)
7272class wl_instantiatet
7373{
7474public:
75- explicit wl_instantiatet (const mp_integer &_no_timeframes)
76- : no_timeframes(_no_timeframes)
75+ wl_instantiatet (const mp_integer &_no_timeframes, bool _next_symbol_allowed )
76+ : no_timeframes(_no_timeframes), next_symbol_allowed(_next_symbol_allowed)
7777 {
7878 }
7979
8080 // / Instantiate the given expression for timeframe t
81- [[nodiscard]] std::pair<mp_integer, exprt>
82- operator ()(exprt expr, const mp_integer &t) const
81+ [[nodiscard]] exprt operator ()(exprt expr, const mp_integer &t) const
8382 {
8483 return instantiate_rec (std::move (expr), t);
8584 }
8685
8786protected:
8887 const mp_integer &no_timeframes;
88+ bool next_symbol_allowed;
8989
90- [[nodiscard]] std::pair<mp_integer, exprt>
91- instantiate_rec (exprt, const mp_integer &t) const ;
90+ [[nodiscard]] exprt instantiate_rec (exprt, const mp_integer &t) const ;
9291 [[nodiscard]] typet instantiate_rec (typet, const mp_integer &t) const ;
9392};
9493
@@ -104,20 +103,20 @@ Function: wl_instantiatet::instantiate_rec
104103
105104\*******************************************************************/
106105
107- std::pair<mp_integer, exprt>
108- wl_instantiatet::instantiate_rec (exprt expr, const mp_integer &t) const
106+ exprt wl_instantiatet::instantiate_rec (exprt expr, const mp_integer &t) const
109107{
110108 expr.type () = instantiate_rec (expr.type (), t);
111109
112110 if (expr.id () == ID_next_symbol)
113111 {
112+ PRECONDITION (next_symbol_allowed);
114113 expr.id (ID_symbol);
115114 auto u = t + 1 ;
116- return {u, timeframe_symbol (u, to_symbol_expr (std::move (expr)))} ;
115+ return timeframe_symbol (u, to_symbol_expr (std::move (expr)));
117116 }
118117 else if (expr.id () == ID_symbol)
119118 {
120- return {t, timeframe_symbol (t, to_symbol_expr (std::move (expr)))} ;
119+ return timeframe_symbol (t, to_symbol_expr (std::move (expr)));
121120 }
122121 else if (
123122 expr.id () == ID_typecast && expr.type ().id () == ID_bool &&
@@ -144,7 +143,7 @@ wl_instantiatet::instantiate_rec(exprt expr, const mp_integer &t) const
144143 if (ticks > t)
145144 {
146145 // return the 'default value' for the type
147- return {t, verilog_past.default_value ()} ;
146+ return verilog_past.default_value ();
148147 }
149148 else
150149 {
@@ -159,15 +158,12 @@ wl_instantiatet::instantiate_rec(exprt expr, const mp_integer &t) const
159158 }
160159 else
161160 {
162- mp_integer max = t;
163161 for (auto &op : expr.operands ())
164162 {
165- auto tmp = instantiate_rec (op, t);
166- op = tmp.second ;
167- max = std::max (max, tmp.first );
163+ op = instantiate_rec (op, t);
168164 }
169165
170- return {max, expr} ;
166+ return expr;
171167 }
172168}
173169
@@ -205,8 +201,8 @@ exprt instantiate(
205201 const mp_integer &t,
206202 const mp_integer &no_timeframes)
207203{
208- wl_instantiatet wl_instantiate (no_timeframes);
209- return wl_instantiate (expr, t). second ;
204+ wl_instantiatet wl_instantiate (no_timeframes, true );
205+ return wl_instantiate (expr, t);
210206}
211207
212208/* ******************************************************************\
@@ -221,11 +217,11 @@ Function: instantiate_property
221217
222218\*******************************************************************/
223219
224- std::pair<mp_integer, exprt> instantiate_property (
220+ exprt instantiate_property (
225221 const exprt &expr,
226222 const mp_integer ¤t,
227223 const mp_integer &no_timeframes)
228224{
229- wl_instantiatet wl_instantiate (no_timeframes);
225+ wl_instantiatet wl_instantiate (no_timeframes, false );
230226 return wl_instantiate (expr, current);
231227}
0 commit comments