@@ -20,6 +20,7 @@ Author: Daniel Kroening
20
20
#include < util/simplify_expr.h>
21
21
22
22
#include < langapi/language_util.h>
23
+ #include < langapi/mode.h>
23
24
#include < util/json_irep.h>
24
25
25
26
// / Produce a json representation of a trace.
@@ -90,7 +91,6 @@ void convert(
90
91
json_assignment[" sourceLocation" ]=json_location;
91
92
92
93
std::string value_string, binary_string, type_string, full_lhs_string;
93
- json_objectt full_lhs_value;
94
94
95
95
DATA_INVARIANT (
96
96
step.full_lhs .is_not_nil (),
@@ -132,27 +132,18 @@ void convert(
132
132
const symbolt *symbol;
133
133
irep_idt base_name, display_name;
134
134
135
+
135
136
if (!ns.lookup (identifier, symbol))
136
137
{
137
138
base_name=symbol->base_name ;
138
139
display_name=symbol->display_name ();
139
- if (type_string==" " )
140
- type_string=from_type (ns, identifier, symbol->type );
140
+ type_string = from_type (ns, identifier, symbol->type );
141
141
142
142
json_assignment[" mode" ]=json_stringt (id2string (symbol->mode ));
143
- exprt simplified=simplify_expr (step.full_lhs_value , ns);
144
-
145
- full_lhs_value=json (simplified, ns, symbol->mode );
146
- }
147
- else
148
- {
149
- DATA_INVARIANT (
150
- step.full_lhs_value .is_not_nil (),
151
- " full_lhs_value in assignment must not be nil" );
152
- full_lhs_value=json (step.full_lhs_value , ns, ID_unknown);
153
143
}
154
144
155
- json_assignment[" value" ]=full_lhs_value;
145
+ const exprt value_simplified = simplify_expr (step.full_lhs_value , ns);
146
+ json_assignment[" value" ] = json (ns, identifier, value_simplified);
156
147
json_assignment[" lhs" ]=json_stringt (full_lhs_string);
157
148
if (trace_options.json_full_lhs )
158
149
{
@@ -184,13 +175,8 @@ void convert(
184
175
json_output[" outputID" ]=json_stringt (id2string (step.io_id ));
185
176
186
177
// Recovering the mode from the function
187
- irep_idt mode;
188
- const symbolt *function_name;
189
- if (ns.lookup (source_location.get_function (), function_name))
190
- // Failed to find symbol
191
- mode=ID_unknown;
192
- else
193
- mode=function_name->mode ;
178
+ const irep_idt mode =
179
+ get_mode_from_identifier (ns.get_symbol_table (), source_location.get_function ());
194
180
json_output[" mode" ]=json_stringt (id2string (mode));
195
181
json_arrayt &json_values=json_output[" values" ].make_array ();
196
182
@@ -199,7 +185,7 @@ void convert(
199
185
if (arg.is_nil ())
200
186
json_values.push_back (json_stringt (" " ));
201
187
else
202
- json_values.push_back (json (arg, ns, mode ));
188
+ json_values.push_back (json (ns, source_location. get_function (), arg ));
203
189
}
204
190
205
191
if (!json_location.is_null ())
@@ -218,13 +204,8 @@ void convert(
218
204
json_input[" inputID" ]=json_stringt (id2string (step.io_id ));
219
205
220
206
// Recovering the mode from the function
221
- irep_idt mode;
222
- const symbolt *function_name;
223
- if (ns.lookup (source_location.get_function (), function_name))
224
- // Failed to find symbol
225
- mode=ID_unknown;
226
- else
227
- mode=function_name->mode ;
207
+ const irep_idt mode =
208
+ get_mode_from_identifier (ns.get_symbol_table (), source_location.get_function ());
228
209
json_input[" mode" ]=json_stringt (id2string (mode));
229
210
json_arrayt &json_values=json_input[" values" ].make_array ();
230
211
@@ -233,7 +214,7 @@ void convert(
233
214
if (arg.is_nil ())
234
215
json_values.push_back (json_stringt (" " ));
235
216
else
236
- json_values.push_back (json (arg, ns, mode ));
217
+ json_values.push_back (json (ns, source_location. get_function (), arg ));
237
218
}
238
219
239
220
if (!json_location.is_null ())
0 commit comments