Go to the documentation of this file.
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)
154 else if(src.
id() == ID_count_leading_zeros)
157 return os << src.
pretty();
160 return os <<
'(' <<
format(src.
op()) <<
')';
168 auto type = src.
type().
id();
175 return os <<
"false";
177 return os << src.
pretty();
179 else if(type == ID_unsignedbv || type == ID_signedbv || type == ID_c_bool)
180 return os << *numeric_cast<mp_integer>(src);
181 else if(type == ID_integer)
183 else if(type == ID_string)
185 else if(type == ID_floatbv)
187 else if(type == ID_pointer && src.
is_zero())
190 return os << src.
pretty();
198 if(s.first != ID_type)
199 os <<
' ' << s.first <<
"=\"" << s.second.id() <<
'"';
206 for(
const auto &op : expr.
operands())
231 std::function<std::ostream &(std::ostream &,
const exprt &)>;
232 using expr_mapt = std::unordered_map<irep_idt, formattert>;
251 auto multi_ary_expr =
252 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
262 auto binary_expr = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
274 expr_map[ID_notequal] = binary_expr;
276 auto unary_expr = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
281 expr_map[ID_unary_minus] = unary_expr;
284 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
289 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
291 <<
format(expr.type()) <<
')';
295 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
297 return os << expr.id() <<
'(' <<
format(byte_extract_expr.op()) <<
", "
298 <<
format(byte_extract_expr.offset()) <<
", "
299 <<
format(byte_extract_expr.type()) <<
')';
302 expr_map[ID_byte_extract_little_endian] = byte_extract;
303 expr_map[ID_byte_extract_big_endian] = byte_extract;
305 auto byte_update = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
307 return os << expr.id() <<
'(' <<
format(byte_update_expr.op()) <<
", "
308 <<
format(byte_update_expr.offset()) <<
", "
309 <<
format(byte_update_expr.value()) <<
", "
310 <<
format(byte_update_expr.type()) <<
')';
313 expr_map[ID_byte_update_little_endian] = byte_update;
314 expr_map[ID_byte_update_big_endian] = byte_update;
317 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
323 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
328 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
330 return os <<
format(index_expr.array()) <<
'[' <<
format(index_expr.index())
335 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
340 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
347 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
353 expr_map[ID_let] = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
360 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
367 for(
auto &v : lambda_expr.variables())
377 return os <<
" . " <<
format(lambda_expr.where());
380 auto compound = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
385 for(
const auto &op : expr.operands())
401 expr_map[ID_if] = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
403 return os <<
'(' <<
format(if_expr.cond()) <<
" ? "
404 <<
format(if_expr.true_case()) <<
" : "
405 <<
format(if_expr.false_case()) <<
')';
409 [](std::ostream &os,
const exprt &expr) -> std::ostream & {
410 const auto &code =
to_code(expr);
411 const irep_idt &statement = code.get_statement();
413 if(statement == ID_assign)
416 else if(statement == ID_block)
423 else if(statement == ID_dead)
427 else if(
const auto decl = expr_try_dynamic_cast<code_declt>(code))
429 const auto &declaration_symb = decl->symbol();
430 os <<
"decl " <<
format(declaration_symb.type()) <<
" "
431 <<
format(declaration_symb);
433 os <<
" = " <<
format(*initial_value);
436 else if(statement == ID_function_call)
444 func_call.arguments().begin(),
445 func_call.arguments().end(),
447 [](
const exprt &expr) { return format(expr); });
455 fallback = [](std::ostream &os,
const exprt &expr) -> std::ostream & {
475 return formatter(os, expr);
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
A base class for multi-ary expressions Associativity is not specified.
const lambda_exprt & to_lambda_expr(const exprt &expr)
Cast an exprt to a lambda_exprt.
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const byte_extract_exprt & to_byte_extract_expr(const exprt &expr)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
const if_exprt & to_if_expr(const exprt &expr)
Cast an exprt to an if_exprt.
Base class for all expressions.
Generic base class for unary expressions.
A base class for binary expressions.
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.
const codet & to_code(const exprt &expr)
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
typet & type()
Return the type of the expression.
Expression classes for byte-level operators.
bool has_operands() const
Return true if there is at least one operand.
const std::string & id2string(const irep_idt &d)
named_subt & get_named_sub()
const byte_update_exprt & to_byte_update_expr(const exprt &expr)
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.
const code_deadt & to_code_dead(const codet &code)
const irep_idt & get_identifier() const
const let_exprt & to_let_expr(const exprt &expr)
Cast an exprt to a let_exprt.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
const code_function_callt & to_code_function_call(const codet &code)
nonstd::optional< T > optionalt
bool is_zero() const
Return whether the expression is a constant representing 0.
Forward depth-first search iterators These iterators' copy operations are expensive,...
const quantifier_exprt & to_quantifier_expr(const exprt &expr)
Cast an exprt to a quantifier_exprt.
const code_assignt & to_code_assign(const codet &code)
const typecast_exprt & to_typecast_expr(const exprt &expr)
Cast an exprt to a typecast_exprt.
const equal_exprt & to_equal_expr(const exprt &expr)
Cast an exprt to an equal_exprt.
const code_blockt & to_code_block(const codet &code)
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
irep_idt get_component_name() const
A constant literal expression.
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
API to expression classes.
const irep_idt & get_value() const
std::string escape(const std::string &s)
Generic escaping of strings; this is not meant to be a particular programming language.
API to expression classes for 'mathematical' expressions.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.