Go to the documentation of this file.
31 const exprt &src,
unsigned &precedence)
override;
45 const std::string &declarator)
override;
54 if(full_type.
id()!=ID_struct)
59 std::string dest=
"{ ";
64 assert(components.size()==src.
operands().size());
66 exprt::operandst::const_iterator o_it=src.
operands().begin();
71 for(
const auto &c : components)
73 if(c.type().id() == ID_code)
85 if(last_size+40<dest.size())
88 last_size=dest.size();
96 dest += c.get_string(ID_pretty_name);
111 unsigned &precedence)
113 if(src.
type().
id() == ID_c_bool)
128 const std::string &declarator)
130 std::unique_ptr<qualifierst> clone = qualifiers.
clone();
132 new_qualifiers.
read(src);
135 declarator==
""?declarator:(
" "+declarator);
148 else if(!src.
get(ID_C_c_type).
empty())
152 if(c_type == ID_bool)
157 else if(src.
id() == ID_symbol_type)
164 if(symbol.
type.
id()==ID_struct ||
165 symbol.
type.
id()==ID_incomplete_struct)
183 else if(symbol.
type.
id()==ID_c_enum)
199 else if(src.
id()==ID_struct ||
200 src.
id()==ID_incomplete_struct)
206 else if(src.
get_bool(ID_C_interface))
215 else if(src.
id()==ID_constructor)
217 return "constructor ";
219 else if(src.
id()==ID_destructor)
221 return "destructor ";
223 else if(src.
id()==
"cpp-template-type")
227 else if(src.
id()==ID_template)
229 std::string dest=
"template<";
235 if(it!=arguments.begin())
240 if(argument.
id()==ID_symbol)
245 else if(argument.
id()==ID_type)
258 else if(src.
id()==ID_pointer && src.
subtype().
id()==ID_nullptr)
260 return "std::nullptr_t";
262 else if(src.
id()==ID_pointer &&
267 member.
swap(tmp.
add(
"to-member"));
280 for(code_typet::parameterst::const_iterator it=args.begin();
297 else if(src.
id()==ID_verilog_signedbv ||
298 src.
id()==ID_verilog_unsignedbv)
300 else if(src.
id()==ID_unassigned)
302 else if(src.
id()==ID_code)
309 std::string dest=
"auto";
320 for(code_typet::parameterst::const_iterator
321 it=parameters.begin();
322 it!=parameters.end();
325 if(it!=parameters.begin())
333 if(!parameters.empty())
341 dest+=
" -> "+
convert(return_type);
345 else if(src.
id()==ID_initializer_list)
350 else if(src.
id() == ID_c_bool)
352 return q +
"bool" + d;
371 if(src.
get(ID_statement)==ID_cpp_new_array)
375 std::string tmp_size=
376 convert(static_cast<const exprt &>(src.
find(ID_size)));
394 std::string dest=
indent_str(indent)+
"delete ";
411 unsigned &precedence)
413 if(src.
id()==
"cpp-this")
415 if(src.
id()==ID_extractbit)
417 else if(src.
id()==ID_extractbits)
419 else if(src.
id()==ID_side_effect &&
420 (src.
get(ID_statement)==ID_cpp_new ||
421 src.
get(ID_statement)==ID_cpp_new_array))
423 else if(src.
id()==ID_side_effect &&
424 src.
get(ID_statement)==ID_throw)
432 else if(src.
id()==ID_unassigned)
434 else if(src.
id() == ID_pod_constructor)
435 return "pod_constructor";
446 if(statement==ID_cpp_delete ||
447 statement==ID_cpp_delete_array)
450 if(statement==ID_cpp_new ||
451 statement==ID_cpp_new_array)
expr2cppt(const namespacet &_ns)
std::string MetaString(const std::string &in)
std::string convert_extractbits(const exprt &src, unsigned precedence)
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 typet & subtype() const
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
std::string convert_code_cpp_delete(const exprt &src, unsigned precedence)
std::string convert_cpp_this(const exprt &src, unsigned precedence)
typet type
Type of symbol.
irept & add(const irep_namet &name)
virtual std::string convert_constant(const constant_exprt &src, unsigned &precedence)
const irept & find(const irep_namet &name) const
Base class for all expressions.
std::vector< componentt > componentst
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 irep_idt & get_identifier() const
std::string convert_extractbit(const exprt &src, unsigned precedence)
bool is_false() const
Return whether the expression is a constant representing false.
irep_idt pretty_name
Language-specific display name.
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 lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
bool get_bool(const irep_namet &name) const
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)
static std::string indent_str(unsigned indent)
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
const irep_idt & id() const
std::string convert_function(const exprt &src, const std::string &symbol, unsigned precedence)
const parameterst & parameters() const
const symbol_typet & to_symbol_type(const typet &type)
Cast a typet to a symbol_typet.
std::string convert_norep(const exprt &src, unsigned &precedence)
#define forall_irep(it, irep)
Structure type, corresponds to C style structs.
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const irep_idt & get(const irep_namet &name) const
bool is_constant() const
Return whether the expression is a constant.
bool is_rvalue_reference(const typet &type)
Returns if the type is an R value reference.
const typet & return_type() const
std::string convert_cpp_new(const exprt &src, unsigned precedence)
virtual std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator)
virtual std::string as_string() const =0
A constant literal expression.
virtual std::string convert_with_precedence(const exprt &src, unsigned &precedence)
std::vector< irept > subt
std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator) override
const irep_idt & get_value() const
std::string convert_code(const codet &src, unsigned indent) override
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.