47 {ID_notequal, {
u8"\u2260"}},
48 {ID_and, {
u8"\u2227"}},
49 {ID_or, {
u8"\u2228"}},
50 {ID_xor, {
u8"\u2295"}},
51 {ID_implies, {
u8"\u21d2"}},
52 {ID_le, {
u8"\u2264"}},
53 {ID_ge, {
u8"\u2265"}},
74 (sub_expr.
id() == ID_mult || sub_expr.
id() == ID_div) &&
75 (expr.
id() == ID_plus || expr.
id() == ID_minus))
80 (sub_expr.
id() == ID_equal || sub_expr.
id() == ID_notequal ||
81 sub_expr.
id() == ID_lt || sub_expr.
id() == ID_gt ||
82 sub_expr.
id() == ID_le || sub_expr.
id() == ID_ge) &&
83 (expr.
id() == ID_and || expr.
id() == ID_or))
88 (sub_expr.
id() == ID_plus || sub_expr.
id() == ID_minus ||
89 sub_expr.
id() == ID_mult || sub_expr.
id() == ID_div) &&
90 (expr.
id() == ID_equal || expr.
id() == ID_notequal || expr.
id() == ID_lt ||
91 expr.
id() == ID_gt || expr.
id() == ID_le || expr.
id() == ID_ge))
107 if(src.
id() == ID_equal &&
to_equal_expr(src).op0().type().
id() == ID_bool)
109 operator_str =
u8"\u21d4";
115 operator_str = infix_map_it->second.rep;
118 for(
const auto &op : src.
operands())
123 os <<
' ' << operator_str <<
' ';
150 if(src.
id() == ID_not)
152 else if(src.
id() == ID_unary_minus)
155 return os << src.
pretty();
158 return os <<
'(' <<
format(src.
op()) <<
')';
166 auto type = src.
type().
id();
173 return os <<
"false";
175 return os << src.
pretty();
177 else if(type == ID_unsignedbv || type == ID_signedbv || type == ID_c_bool)
178 return os << *numeric_cast<mp_integer>(src);
179 else if(type == ID_integer)
181 else if(type == ID_string)
183 else if(type == ID_floatbv)
185 else if(type == ID_pointer && src.
is_zero())
188 return os << src.
pretty();
196 if(s.first != ID_type)
197 os <<
' ' << s.first <<
"=\"" << s.second.id() <<
'"';
204 for(
const auto &op : expr.
operands())
229 std::function<std::ostream &(std::ostream &,
const exprt &)>;
230 using expr_mapt = std::unordered_map<irep_idt, formattert>;
249 auto multi_ary_expr =
250 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
260 auto binary_expr = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
272 expr_map[ID_notequal] = binary_expr;
274 auto unary_expr = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
279 expr_map[ID_unary_minus] = unary_expr;
282 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
287 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
289 <<
format(expr.type()) <<
')';
293 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
295 return os << expr.id() <<
'(' <<
format(byte_extract_expr.op()) <<
", "
296 <<
format(byte_extract_expr.offset()) <<
", "
297 <<
format(byte_extract_expr.type()) <<
')';
300 expr_map[ID_byte_extract_little_endian] = byte_extract;
301 expr_map[ID_byte_extract_big_endian] = byte_extract;
303 auto byte_update = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
305 return os << expr.id() <<
'(' <<
format(byte_update_expr.op()) <<
", "
306 <<
format(byte_update_expr.offset()) <<
", "
307 <<
format(byte_update_expr.value()) <<
", "
308 <<
format(byte_update_expr.type()) <<
')';
311 expr_map[ID_byte_update_little_endian] = byte_update;
312 expr_map[ID_byte_update_big_endian] = byte_update;
315 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
321 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
326 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
328 return os <<
format(index_expr.array()) <<
'[' <<
format(index_expr.index())
333 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
338 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
345 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
351 expr_map[ID_let] = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
358 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
365 for(
auto &v : lambda_expr.variables())
375 return os <<
" . " <<
format(lambda_expr.where());
378 auto compound = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
383 for(
const auto &op : expr.operands())
399 expr_map[ID_if] = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
401 return os <<
'(' <<
format(if_expr.cond()) <<
" ? "
402 <<
format(if_expr.true_case()) <<
" : "
403 <<
format(if_expr.false_case()) <<
')';
407 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
408 const auto &code =
to_code(expr);
409 const irep_idt &statement = code.get_statement();
411 if(statement == ID_assign)
414 else if(statement == ID_block)
421 else if(statement == ID_dead)
425 else if(
const auto decl = expr_try_dynamic_cast<code_declt>(code))
427 const auto &declaration_symb = decl->symbol();
428 os <<
"decl " <<
format(declaration_symb.type()) <<
" "
429 <<
format(declaration_symb);
431 os <<
" = " <<
format(*initial_value);
434 else if(statement == ID_function_call)
442 func_call.arguments().begin(),
443 func_call.arguments().end(),
445 [](
const exprt &expr) { return format(expr); });
453 fallback = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
473 return formatter(os, expr);
Expression classes for byte-level operators.
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
A base class for binary expressions.
A constant literal expression.
const irep_idt & get_value() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
bool has_operands() const
Return true if there is at least one operand.
bool is_true() const
Return whether the expression is a constant representing true.
bool is_false() const
Return whether the expression is a constant representing false.
bool is_zero() const
Return whether the expression is a constant representing 0.
typet & type()
Return the type of the expression.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
named_subt & get_named_sub()
const irep_idt & id() const
irep_idt get_component_name() const
A base class for multi-ary expressions Associativity is not specified.
const irep_idt & get_identifier() const
Generic base class for unary expressions.
Forward depth-first search iterators These iterators' copy operations are expensive,...
const std::string & id2string(const irep_idt &d)
API to expression classes for 'mathematical' expressions.
const lambda_exprt & to_lambda_expr(const exprt &expr)
Cast an exprt to a lambda_exprt.
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
nonstd::optional< T > optionalt
const codet & to_code(const exprt &expr)
const code_blockt & to_code_block(const codet &code)
const code_deadt & to_code_dead(const codet &code)
const code_function_callt & to_code_function_call(const codet &code)
const code_assignt & to_code_assign(const codet &code)
API to expression classes.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
std::string escape(const std::string &s)
Generic escaping of strings; this is not meant to be a particular programming language.
Stream & join_strings(Stream &&os, const It b, const It e, const Delimiter &delimiter, TransformFunc &&transform_func)
Prints items to an stream, separated by a constant delimiter.