Go to the documentation of this file.
31 const exprt &src,
unsigned &precedence)
override;
46 const std::string &declarator)
override;
55 if(full_type.
id()!=ID_struct)
60 std::string dest=
"{ ";
65 assert(components.size()==src.
operands().size());
67 exprt::operandst::const_iterator o_it=src.
operands().begin();
72 for(
const auto &c : components)
74 if(c.type().id() == ID_code)
86 if(last_size+40<dest.size())
89 last_size=dest.size();
97 dest += c.get_string(ID_pretty_name);
112 unsigned &precedence)
114 if(src.
type().
id() == ID_c_bool)
129 const std::string &declarator)
131 std::unique_ptr<qualifierst> clone = qualifiers.
clone();
133 new_qualifiers.
read(src);
135 const std::string d = declarator.empty() ? declarator : (
" " + declarator);
148 else if(!src.
get(ID_C_c_type).
empty())
152 if(c_type == ID_bool)
157 else if(src.
id() == ID_struct)
163 else if(src.
get_bool(ID_C_interface))
172 else if(src.
id() == ID_struct_tag)
176 std::string dest = q;
180 else if(src.
get_bool(ID_C_interface))
181 dest +=
"__interface";
185 const irept &tag = struct_type.
find(ID_tag);
188 if(tag.
id() == ID_cpp_name)
198 else if(src.
id() == ID_union_tag)
202 std::string dest = q +
"union";
204 const irept &tag = union_type.
find(ID_tag);
207 if(tag.
id() == ID_cpp_name)
217 else if(src.
id()==ID_constructor)
219 return "constructor ";
221 else if(src.
id()==ID_destructor)
223 return "destructor ";
225 else if(src.
id()==
"cpp-template-type")
229 else if(src.
id()==ID_template)
231 std::string dest=
"template<";
235 for(
auto it = arguments.begin(); it != arguments.end(); ++it)
237 if(it!=arguments.begin())
242 if(argument.
id()==ID_symbol)
247 else if(argument.
id()==ID_type)
260 else if(src.
id()==ID_pointer && src.
subtype().
id()==ID_nullptr)
262 return "std::nullptr_t";
268 member.
swap(tmp.
add(ID_to_member));
281 for(code_typet::parameterst::const_iterator it=args.begin();
298 else if(src.
id()==ID_verilog_signedbv ||
299 src.
id()==ID_verilog_unsignedbv)
302 else if(src.
id()==ID_unassigned)
304 else if(src.
id()==ID_code)
311 std::string dest=
"auto";
322 for(code_typet::parameterst::const_iterator
323 it=parameters.begin();
324 it!=parameters.end();
327 if(it!=parameters.begin())
335 if(!parameters.empty())
343 dest+=
" -> "+
convert(return_type);
347 else if(src.
id()==ID_initializer_list)
352 else if(src.
id() == ID_c_bool)
354 return q +
"bool" + d;
369 if(src.
get(ID_statement)==ID_cpp_new_array)
373 std::string tmp_size=
397 std::string dest=
indent_str(indent)+
"delete ";
414 unsigned &precedence)
416 if(src.
id()==
"cpp-this")
421 if(src.
id()==ID_extractbit)
426 else if(src.
id()==ID_extractbits)
431 else if(src.
id()==ID_side_effect &&
432 (src.
get(ID_statement)==ID_cpp_new ||
433 src.
get(ID_statement)==ID_cpp_new_array))
438 else if(src.
id()==ID_side_effect &&
439 src.
get(ID_statement)==ID_throw)
450 else if(src.
id()==ID_unassigned)
452 else if(src.
id() == ID_pod_constructor)
453 return "pod_constructor";
464 if(statement==ID_cpp_delete ||
465 statement==ID_cpp_delete_array)
468 if(statement==ID_cpp_new ||
469 statement==ID_cpp_new_array)
478 return convert(extractbit_expr.op0()) +
"[" +
convert(extractbit_expr.op1()) +
485 return convert(extractbits_expr.src()) +
".range(" +
486 convert(extractbits_expr.upper()) +
"," +
487 convert(extractbits_expr.lower()) +
")";
expr2cppt(const namespacet &_ns)
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
std::string MetaString(const std::string &in)
const componentst & components() const
void irep2lisp(const irept &src, lispexprt &dest)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool has_ellipsis() const
const extractbit_exprt & to_extractbit_expr(const exprt &expr)
Cast an exprt to an extractbit_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const typet & subtype() const
std::string convert_extractbit(const exprt &src)
std::string convert_code_cpp_new(const exprt &src, unsigned indent)
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
The type of an expression, extends irept.
std::vector< parametert > parameterst
irept & add(const irep_namet &name)
const irept & find(const irep_namet &name) const
Base class for all expressions.
std::vector< componentt > componentst
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::string convert_code(const codet &src)
bool is_true() const
Return whether the expression is a constant representing true.
std::string expr2cpp(const exprt &expr, const namespacet &ns)
virtual void read(const typet &src)=0
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
bool is_rvalue_reference(const typet &type)
Returns if the type is an R value reference.
bool is_false() const
Return whether the expression is a constant representing false.
virtual std::string convert_with_precedence(const exprt &src, unsigned &precedence)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
typet & type()
Return the type of the expression.
bool get_bool(const irep_namet &name) const
std::string convert_code_cpp_delete(const exprt &src, unsigned indent)
virtual std::string convert(const typet &src)
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
std::string expr2string() const
std::string convert_struct(const exprt &src, unsigned &precedence) override
const std::string & id2string(const irep_idt &d)
std::string type2cpp(const typet &type, const namespacet &ns)
virtual std::unique_ptr< qualifierst > clone() const =0
std::string convert_with_precedence(const exprt &src, unsigned &precedence) override
std::string convert_constant(const constant_exprt &src, unsigned &precedence) override
API to expression classes for Pointers.
const irep_idt & id() const
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const parameterst & parameters() const
std::string convert_cpp_new(const exprt &src)
virtual std::string convert_constant(const constant_exprt &src, unsigned &precedence)
static std::string indent_str(unsigned indent)
std::string convert_norep(const exprt &src, unsigned &precedence)
bool is_reference(const typet &type)
Returns true if the type is a reference.
Structure type, corresponds to C style structs.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
const irep_idt & get(const irep_namet &name) const
optionalt< std::string > convert_function(const exprt &src)
Returns a string if src is a function with a known conversion, else returns nullopt.
bool is_constant() const
Return whether the expression is a constant.
const extractbits_exprt & to_extractbits_expr(const exprt &expr)
Cast an exprt to an extractbits_exprt.
const typet & return_type() const
There are a large number of kinds of tree structured or tree-like data in CPROVER.
virtual std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator)
virtual std::string as_string() const =0
std::string convert_extractbits(const exprt &src)
A constant literal expression.
API to expression classes.
std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator) override
std::string to_string() const
cpp_namet & to_cpp_name(irept &cpp_name)
std::string convert_code(const codet &src, unsigned indent) override
std::string convert_cpp_this()
Data structure for representing an arbitrary statement in a program.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.