@@ -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
@@ -128,34 +129,25 @@ void convert_decl(
128
129
129
130
if (!ns.lookup (identifier, symbol))
130
131
{
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 );
132
+ base_name=symbol->base_name ;
133
+ display_name=symbol->display_name ();
134
+ type_string = from_type (ns, identifier, symbol->type );
135
135
136
- json_assignment[" mode" ] = json_stringt (id2string (symbol->mode ));
137
- exprt simplified = simplify_expr (step.full_lhs_value , ns);
138
-
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);
136
+ json_assignment[" mode" ]=json_stringt (id2string (symbol->mode ));
147
137
}
148
138
149
- json_assignment[" value" ] = full_lhs_value;
150
- json_assignment[" lhs" ] = json_stringt (full_lhs_string);
139
+ const exprt value_simplified = simplify_expr (step.full_lhs_value , ns);
140
+ json_assignment[" value" ] = json (ns, identifier, value_simplified);
141
+ json_assignment[" lhs" ]=json_stringt (full_lhs_string);
151
142
if (trace_options.json_full_lhs )
152
143
{
153
144
// Not language specific, still mangled, fully-qualified name of lhs
154
- json_assignment[" rawLhs" ] = json_irept (true ).convert_from_irep (simplified);
145
+ json_assignment[" rawLhs" ] =
146
+ json_irept (true ).convert_from_irep (simplified);
155
147
}
156
- json_assignment[" hidden" ] = jsont::json_boolean (step.hidden );
157
- json_assignment[" internal" ] = jsont::json_boolean (step.internal );
158
- json_assignment[" thread" ] = json_numbert (std::to_string (step.thread_nr ));
148
+ json_assignment[" hidden" ]= jsont::json_boolean (step.hidden );
149
+ json_assignment[" internal" ]= jsont::json_boolean (step.internal );
150
+ json_assignment[" thread" ]= json_numbert (std::to_string (step.thread_nr ));
159
151
160
152
json_assignment[" assignmentType" ] = json_stringt (
161
153
step.assignment_type == goto_trace_stept::assignment_typet::ACTUAL_PARAMETER
@@ -186,20 +178,17 @@ void convert_output(
186
178
json_output[" outputID" ] = json_stringt (id2string (step.io_id ));
187
179
188
180
// 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 ;
196
- json_output[" mode" ] = json_stringt (id2string (mode));
197
- json_arrayt &json_values = json_output[" values" ].make_array ();
181
+ const irep_idt mode =
182
+ get_mode_from_identifier (ns.get_symbol_table (), source_location.get_function ());
183
+ json_output[" mode" ]=json_stringt (id2string (mode));
184
+ json_arrayt &json_values=json_output[" values" ].make_array ();
198
185
199
186
for (const auto &arg : step.io_args )
200
187
{
201
- arg.is_nil () ? json_values.push_back (json_stringt (" " ))
202
- : json_values.push_back (json (arg, ns, mode));
188
+ if (arg.is_nil ())
189
+ json_values.push_back (json_stringt (" " ));
190
+ else
191
+ json_values.push_back (json (ns, source_location.get_function (), arg));
203
192
}
204
193
205
194
if (!location.is_null ())
@@ -229,20 +218,17 @@ void convert_input(
229
218
json_input[" inputID" ] = json_stringt (id2string (step.io_id ));
230
219
231
220
// 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 ;
239
- json_input[" mode" ] = json_stringt (id2string (mode));
240
- json_arrayt &json_values = json_input[" values" ].make_array ();
221
+ const irep_idt mode =
222
+ get_mode_from_identifier (ns.get_symbol_table (), source_location.get_function ());
223
+ json_input[" mode" ]=json_stringt (id2string (mode));
224
+ json_arrayt &json_values=json_input[" values" ].make_array ();
241
225
242
226
for (const auto &arg : step.io_args )
243
227
{
244
- arg.is_nil () ? json_values.push_back (json_stringt (" " ))
245
- : json_values.push_back (json (arg, ns, mode));
228
+ if (arg.is_nil ())
229
+ json_values.push_back (json_stringt (" " ));
230
+ else
231
+ json_values.push_back (json (ns, source_location.get_function (), arg));
246
232
}
247
233
248
234
if (!location.is_null ())
0 commit comments