33 const std::string &annotation,
42 std::cout <<
"(sliced) ";
44 std::cout <<
'(' << count <<
") ";
45 if(annotation.empty())
46 std::cout << string_value;
48 std::cout << annotation <<
'(' << string_value <<
')';
53 const std::string guard_string =
from_expr(ns, function_id, step.
guard);
55 std::cout <<
"guard: " << guard_string <<
'\n';
63 std::size_t count = 1;
65 std::cout <<
'\n' <<
"Program constraints:" <<
'\n';
67 for(
const auto &step : equation.
SSA_steps)
69 std::cout <<
"// " << step.source.pc->location_number <<
" ";
70 std::cout << step.source.pc->source_location().as_string() <<
"\n";
72 if(step.is_assignment())
74 else if(step.is_assert())
76 else if(step.is_assume())
78 else if(step.is_constraint())
83 else if(step.is_shared_read())
84 show_step(ns, step,
"SHARED_READ", count);
85 else if(step.is_shared_write())
86 show_step(ns, step,
"SHARED_WRITE", count);
90 template <
typename expr_typet>
94 std::is_base_of<exprt, expr_typet>::value,
95 "`expr_typet` is expected to be a type of `exprt`.");
97 std::size_t count = 0;
99 if(can_cast_expr<expr_typet>(e))
118 const exprt &ssa_expr)
121 const std::string ssa_expr_as_string =
from_expr(ns, function_id, ssa_expr);
124 out << ssa_step.
source.
pc->source_location().as_string() <<
"\n"
126 out << ssa_expr_as_string <<
"\n";
132 const exprt &ssa_expr)
134 const std::string key_srcloc =
"sourceLocation";
135 const std::string key_ssa_expr =
"ssaExpr";
136 const std::string key_ssa_expr_as_string =
"ssaExprString";
139 const std::string ssa_expr_as_string =
from_expr(ns, function_id, ssa_expr);
142 {key_srcloc,
json(ssa_step.
source.
pc->source_location())},
143 {key_ssa_expr_as_string,
json_stringt(ssa_expr_as_string)},
146 return json_ssa_step;
149 template <
typename expr_typet>
155 std::size_t equation_byte_op_count = 0;
156 for(
const auto &step : equation.
SSA_steps)
161 const exprt &ssa_expr = step.get_ssa_expr();
162 const std::size_t ssa_expr_byte_op_count =
163 count_expr_typed<expr_typet>(ssa_expr);
165 if(ssa_expr_byte_op_count == 0)
168 equation_byte_op_count += ssa_expr_byte_op_count;
172 if(std::is_same<expr_typet, byte_extract_exprt>::value)
173 out <<
'\n' <<
"Number of byte extracts: ";
174 else if(std::is_same<expr_typet, byte_update_exprt>::value)
175 out <<
'\n' <<
"Number of byte updates: ";
179 out << equation_byte_op_count <<
'\n';
183 template <
typename expr_typet>
186 if(std::is_same<expr_typet, byte_extract_exprt>::value)
187 return "byteExtractList";
188 else if(std::is_same<expr_typet, byte_update_exprt>::value)
189 return "byteUpdateList";
194 template <
typename expr_typet>
197 if(std::is_same<expr_typet, byte_extract_exprt>::value)
198 return "numOfExtracts";
199 else if(std::is_same<expr_typet, byte_update_exprt>::value)
200 return "numOfUpdates";
205 template <
typename expr_typet>
217 const std::string key_byte_op_list = json_get_key_byte_op_list<expr_typet>();
218 const std::string key_byte_op_num = json_get_key_byte_op_num<expr_typet>();
223 std::size_t equation_byte_op_count = 0;
224 for(
const auto &step : equation.
SSA_steps)
229 const exprt &ssa_expr = step.get_ssa_expr();
230 const std::size_t ssa_expr_byte_op_count =
231 count_expr_typed<expr_typet>(ssa_expr);
233 if(ssa_expr_byte_op_count == 0)
236 equation_byte_op_count += ssa_expr_byte_op_count;
240 byte_op_stats[key_byte_op_num] =
243 return byte_op_stats;
250 template <
typename expr_typet>
253 if(std::is_same<expr_typet, byte_extract_exprt>::value)
254 return "byteExtractStats";
255 else if(std::is_same<expr_typet, byte_update_exprt>::value)
256 return "byteUpdateStats";
263 const std::string &filename = options.
get_option(
"outfile");
264 return (!filename.empty() && filename !=
"-");
281 show_byte_op_plain<byte_extract_exprt>(mout.
status(), ns, equation);
284 show_byte_op_plain<byte_update_exprt>(mout.
status(), ns, equation);
289 show_byte_op_plain<byte_extract_exprt>(msg.
status(), ns, equation);
292 show_byte_op_plain<byte_update_exprt>(msg.
status(), ns, equation);
302 {json_get_key_byte_op_stats<byte_extract_exprt>(),
303 get_byte_op_json<byte_extract_exprt>(ns, equation)},
304 {json_get_key_byte_op_stats<byte_update_exprt>(),
305 get_byte_op_json<byte_update_exprt>(ns, equation)}};
308 json_result[
"byteOpsStats"] = byte_ops_stats;
310 out <<
",\n" << json_result;
317 <<
"XML UI not supported for displaying byte extracts and updates."
329 const std::string &filename = options.
get_option(
"outfile");
336 of.open(filename, std::fstream::out);
339 "failed to open output file: " + filename,
"--outfile");
342 std::ostream &out = outfile_given ? of : std::cout;
344 switch(ui_message_handler.
get_ui())