@@ -23,6 +23,7 @@ Author: Daniel Kroening
23
23
#include < util/simplify_expr.h>
24
24
#include < util/json_irep.h>
25
25
#include < langapi/language_util.h>
26
+ #include < langapi/mode.h>
26
27
27
28
// / Convert an ASSERT goto_trace step.
28
29
// / \param [out] json_failure: The JSON object that
@@ -123,30 +124,18 @@ void convert_decl(
123
124
124
125
full_lhs_string = from_expr (ns, identifier, simplified);
125
126
126
- const symbolt *symbol;
127
127
irep_idt base_name, display_name;
128
128
129
- if (!ns.lookup (identifier, symbol))
130
- {
131
- base_name = symbol->base_name ;
132
- display_name = symbol->display_name ();
133
- if (type_string == " " )
134
- type_string = from_type (ns, identifier, symbol->type );
135
-
136
- json_assignment[" mode" ] = json_stringt (id2string (symbol->mode ));
137
- exprt simplified = simplify_expr (step.full_lhs_value , ns);
129
+ const symbolt *symbol;
130
+ bool not_found = ns.lookup (identifier, symbol);
131
+ CHECK_RETURN (!not_found);
132
+ base_name = symbol->base_name ;
133
+ display_name = symbol->display_name ();
138
134
139
- full_lhs_value = json (simplified, ns, symbol->mode );
140
- }
141
- else
142
- {
143
- DATA_INVARIANT (
144
- step.full_lhs_value .is_not_nil (),
145
- " full_lhs_value in assignment must not be nil" );
146
- full_lhs_value = json (step.full_lhs_value , ns, ID_unknown);
147
- }
135
+ json_assignment[" mode" ] = json_stringt (id2string (symbol->mode ));
148
136
149
- json_assignment[" value" ] = full_lhs_value;
137
+ const exprt value_simplified = simplify_expr (step.full_lhs_value , ns);
138
+ json_assignment[" value" ] = json (ns, identifier, value_simplified);
150
139
json_assignment[" lhs" ] = json_stringt (full_lhs_string);
151
140
if (trace_options.json_full_lhs )
152
141
{
@@ -186,20 +175,17 @@ void convert_output(
186
175
json_output[" outputID" ] = json_stringt (id2string (step.io_id ));
187
176
188
177
// Recovering the mode from the function
189
- irep_idt mode;
190
- const symbolt *function_name;
191
- if (ns.lookup (source_location.get_function (), function_name))
192
- // Failed to find symbol
193
- mode = ID_unknown;
194
- else
195
- mode = function_name->mode ;
178
+ const irep_idt mode =
179
+ get_mode_from_identifier (ns, source_location.get_function ());
196
180
json_output[" mode" ] = json_stringt (id2string (mode));
197
181
json_arrayt &json_values = json_output[" values" ].make_array ();
198
182
199
183
for (const auto &arg : step.io_args )
200
184
{
201
- arg.is_nil () ? json_values.push_back (json_stringt (" " ))
202
- : json_values.push_back (json (arg, ns, mode));
185
+ if (arg.is_nil ())
186
+ json_values.push_back (json_stringt (" " ));
187
+ else
188
+ json_values.push_back (json (ns, source_location.get_function (), arg));
203
189
}
204
190
205
191
if (!location.is_null ())
@@ -229,20 +215,17 @@ void convert_input(
229
215
json_input[" inputID" ] = json_stringt (id2string (step.io_id ));
230
216
231
217
// Recovering the mode from the function
232
- irep_idt mode;
233
- const symbolt *function_name;
234
- if (ns.lookup (source_location.get_function (), function_name))
235
- // Failed to find symbol
236
- mode = ID_unknown;
237
- else
238
- mode = function_name->mode ;
218
+ const irep_idt mode =
219
+ get_mode_from_identifier (ns, source_location.get_function ());
239
220
json_input[" mode" ] = json_stringt (id2string (mode));
240
221
json_arrayt &json_values = json_input[" values" ].make_array ();
241
222
242
223
for (const auto &arg : step.io_args )
243
224
{
244
- arg.is_nil () ? json_values.push_back (json_stringt (" " ))
245
- : json_values.push_back (json (arg, ns, mode));
225
+ if (arg.is_nil ())
226
+ json_values.push_back (json_stringt (" " ));
227
+ else
228
+ json_values.push_back (json (ns, source_location.get_function (), arg));
246
229
}
247
230
248
231
if (!location.is_null ())
@@ -277,7 +260,7 @@ void convert_return(
277
260
json_objectt &json_function = json_call_return[" function" ].make_object ();
278
261
json_function[" displayName" ] = json_stringt (id2string (symbol.display_name ()));
279
262
json_function[" identifier" ] = json_stringt (id2string (step.identifier ));
280
- json_function[" sourceLocation" ] = json (symbol.location );
263
+ json_function[" sourceLocation" ] = json (ns, step. identifier , symbol.location );
281
264
282
265
if (!location.is_null ())
283
266
json_call_return[" sourceLocation" ] = location;
0 commit comments