32 const exprt &src,
unsigned &precedence)
override;
47 const std::string &declarator)
override;
54 if(src.
type().
id() != ID_struct && src.
type().
id() != ID_struct_tag)
58 src.
type().
id() == ID_struct_tag
62 std::string dest=
"{ ";
68 components.size() == src.
operands().size(),
"component count mismatch");
70 exprt::operandst::const_iterator o_it=src.
operands().begin();
75 for(
const auto &c : components)
77 if(c.type().id() == ID_code)
89 if(last_size+40<dest.size())
92 last_size=dest.size();
100 if(!c.get_pretty_name().empty())
118 unsigned &precedence)
120 if(src.
type().
id() == ID_c_bool)
135 const std::string &declarator)
137 std::unique_ptr<qualifierst> clone = qualifiers.
clone();
139 new_qualifiers.
read(src);
141 const std::string d = declarator.empty() ? declarator : (
" " + declarator);
154 else if(!src.
get(ID_C_c_type).
empty())
158 if(c_type == ID_bool)
163 else if(src.
id() == ID_struct)
169 else if(src.
get_bool(ID_C_interface))
178 else if(src.
id() == ID_struct_tag)
182 std::string dest = q;
186 else if(src.
get_bool(ID_C_interface))
187 dest +=
"__interface";
191 const irept &tag = struct_type.
find(ID_tag);
194 if(tag.
id() == ID_cpp_name)
204 else if(src.
id() == ID_union_tag)
208 std::string dest = q +
"union";
210 const irept &tag = union_type.
find(ID_tag);
213 if(tag.
id() == ID_cpp_name)
223 else if(src.
id()==ID_constructor)
225 return "constructor ";
227 else if(src.
id()==ID_destructor)
229 return "destructor ";
231 else if(src.
id()==
"cpp-template-type")
235 else if(src.
id()==ID_template)
237 std::string dest=
"template<";
241 for(
auto it = arguments.begin(); it != arguments.end(); ++it)
243 if(it!=arguments.begin())
248 if(argument.
id()==ID_symbol)
253 else if(argument.
id()==ID_type)
267 src.
id() == ID_pointer &&
270 return "std::nullptr_t";
276 member.
swap(tmp.
add(ID_to_member));
282 if(base_type.id() == ID_code)
291 for(code_typet::parameterst::const_iterator it=args.begin();
308 else if(src.
id()==ID_verilog_signedbv ||
309 src.
id()==ID_verilog_unsignedbv)
312 else if(src.
id()==ID_unassigned)
314 else if(src.
id()==ID_code)
321 std::string dest=
"auto";
332 for(code_typet::parameterst::const_iterator
333 it=parameters.begin();
334 it!=parameters.end();
337 if(it!=parameters.begin())
345 if(!parameters.empty())
353 dest+=
" -> "+
convert(return_type);
357 else if(src.
id()==ID_initializer_list)
362 else if(src.
id() == ID_c_bool)
364 return q +
"bool" + d;
379 if(src.
get(ID_statement)==ID_cpp_new_array)
383 std::string tmp_size=
407 std::string dest=
indent_str(indent)+
"delete ";
424 unsigned &precedence)
426 if(src.
id()==
"cpp-this")
431 if(src.
id()==ID_extractbit)
436 else if(src.
id()==ID_extractbits)
441 else if(src.
id()==ID_side_effect &&
442 (src.
get(ID_statement)==ID_cpp_new ||
443 src.
get(ID_statement)==ID_cpp_new_array))
448 else if(src.
id()==ID_side_effect &&
449 src.
get(ID_statement)==ID_throw)
460 else if(src.
id()==ID_unassigned)
462 else if(src.
id() == ID_pod_constructor)
463 return "pod_constructor";
474 if(statement==ID_cpp_delete ||
475 statement==ID_cpp_delete_array)
478 if(statement==ID_cpp_new ||
479 statement==ID_cpp_new_array)
488 return convert(extractbit_expr.op0()) +
"[" +
convert(extractbit_expr.op1()) +
495 return convert(extractbits_expr.src()) +
".range(" +
496 convert(extractbits_expr.upper()) +
"," +
497 convert(extractbits_expr.lower()) +
")";
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
std::string MetaString(const std::string &in)
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
std::vector< parametert > parameterst
const typet & return_type() const
bool has_ellipsis() const
const parameterst & parameters() const
Data structure for representing an arbitrary statement in a program.
A constant literal expression.
std::string to_string() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
std::string convert_with_precedence(const exprt &src, unsigned &precedence) override
std::string convert_struct(const exprt &src, unsigned &precedence) override
std::string convert_code_cpp_new(const exprt &src, unsigned indent)
std::string convert_constant(const constant_exprt &src, unsigned &precedence) override
expr2cppt(const namespacet &_ns)
std::string convert_code(const codet &src, unsigned indent) override
std::string convert_extractbits(const exprt &src)
std::string convert_extractbit(const exprt &src)
std::string convert_cpp_new(const exprt &src)
std::string convert_cpp_this()
std::string convert_code_cpp_delete(const exprt &src, unsigned indent)
std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator) override
std::optional< std::string > convert_function(const exprt &src)
Returns a string if src is a function with a known conversion, else returns nullopt.
static std::string indent_str(unsigned indent)
std::string convert_code(const codet &src)
std::string convert_norep(const exprt &src, unsigned &precedence)
virtual std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator)
virtual std::string convert_constant(const constant_exprt &src, unsigned &precedence)
virtual std::string convert_with_precedence(const exprt &src, unsigned &precedence)
virtual std::string convert(const typet &src)
Base class for all 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.
typet & type()
Return the type of the expression.
bool is_constant() const
Return whether the expression is a constant.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
bool get_bool(const irep_idt &name) const
const irept & find(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
const irep_idt & id() const
irept & add(const irep_idt &name)
std::string expr2string() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
const typet & base_type() const
The type of the data what we point to.
virtual std::unique_ptr< qualifierst > clone() const =0
virtual std::string as_string() const =0
virtual void read(const typet &src)=0
Structure type, corresponds to C style structs.
const componentst & components() const
std::vector< componentt > componentst
The type of an expression, extends irept.
cpp_namet & to_cpp_name(irept &cpp_name)
template_typet & to_template_type(typet &type)
std::string type2cpp(const typet &type, const namespacet &ns)
std::string expr2cpp(const exprt &expr, const namespacet &ns)
const std::string & id2string(const irep_idt &d)
void irep2lisp(const irept &src, lispexprt &dest)
API to expression classes for Pointers.
bool is_reference(const typet &type)
Returns true if the type is a reference.
bool is_rvalue_reference(const typet &type)
Returns if the type is an R value reference.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const reference_typet & to_reference_type(const typet &type)
Cast a typet to a reference_typet.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
API to expression classes.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.