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(struct_typet::componentst::const_iterator
72 c_it=components.begin();
73 c_it!=components.end();
76 if(c_it->type().id()==ID_code)
88 if(last_size+40<dest.size())
91 last_size=dest.size();
99 dest+=c_it->get_string(ID_pretty_name);
114 unsigned &precedence)
116 if(src.
type().
id()==ID_bool)
131 const std::string &declarator)
133 std::unique_ptr<qualifierst> clone = qualifiers.
clone();
135 new_qualifiers.
read(src);
138 declarator==
""?declarator:(
" "+declarator);
151 else if(!src.
get(ID_C_c_type).
empty())
155 if(c_type==ID_signed_char)
156 return q+
"signed char"+d;
157 else if(c_type==ID_unsigned_char)
158 return q+
"unsigned char"+d;
159 else if(c_type==ID_char)
161 else if(c_type==ID_signed_short_int)
163 else if(c_type==ID_unsigned_short_int)
164 return q+
"unsigned short"+d;
165 else if(c_type==ID_signed_int)
167 else if(c_type==ID_unsigned_int)
168 return q+
"unsigned"+d;
169 else if(c_type==ID_signed_long_int)
171 else if(c_type==ID_unsigned_long_int)
172 return q+
"unsigned long"+d;
173 else if(c_type==ID_signed_long_long_int)
174 return q+
"long long"+d;
175 else if(c_type==ID_unsigned_long_long_int)
176 return q+
"unsigned long long"+d;
177 else if(c_type==ID_wchar_t)
178 return q+
"wchar_t"+d;
179 else if(c_type==ID_float)
181 else if(c_type==ID_double)
183 else if(c_type==ID_long_double)
184 return q+
"long double"+d;
185 else if(c_type==ID_bool)
190 else if(src.
id()==ID_symbol)
197 if(symbol.
type.
id()==ID_struct ||
198 symbol.
type.
id()==ID_incomplete_struct)
216 else if(symbol.
type.
id()==ID_c_enum)
232 else if(src.
id()==ID_struct ||
233 src.
id()==ID_incomplete_struct)
239 else if(src.
get_bool(ID_C_interface))
248 else if(src.
id()==ID_constructor)
250 return "constructor ";
252 else if(src.
id()==ID_destructor)
254 return "destructor ";
256 else if(src.
id()==
"cpp-template-type")
260 else if(src.
id()==ID_template)
262 std::string dest=
"template<";
268 if(it!=arguments.begin())
273 if(argument.
id()==ID_symbol)
278 else if(argument.
id()==ID_type)
291 else if(src.
id()==ID_pointer && src.
subtype().
id()==ID_nullptr)
293 return "std::nullptr_t";
295 else if(src.
id()==ID_pointer &&
300 member.
swap(tmp.
add(
"to-member"));
313 for(code_typet::parameterst::const_iterator it=args.begin();
330 else if(src.
id()==ID_verilog_signedbv ||
331 src.
id()==ID_verilog_unsignedbv)
333 else if(src.
id()==ID_unassigned)
335 else if(src.
id()==ID_code)
342 std::string dest=
"auto";
353 for(code_typet::parameterst::const_iterator
354 it=parameters.begin();
355 it!=parameters.end();
358 if(it!=parameters.begin())
366 if(!parameters.empty())
374 dest+=
" -> "+
convert(return_type);
378 else if(src.
id()==ID_initializer_list)
400 if(src.
get(ID_statement)==ID_cpp_new_array)
404 std::string tmp_size=
405 convert(static_cast<const exprt &>(src.
find(ID_size)));
423 std::string dest=
indent_str(indent)+
"delete ";
440 unsigned &precedence)
442 if(src.
id()==
"cpp-this")
444 if(src.
id()==ID_extractbit)
446 else if(src.
id()==ID_extractbits)
448 else if(src.
id()==ID_side_effect &&
449 (src.
get(ID_statement)==ID_cpp_new ||
450 src.
get(ID_statement)==ID_cpp_new_array))
452 else if(src.
id()==ID_side_effect &&
453 src.
get(ID_statement)==ID_throw)
461 else if(src.
id()==ID_unassigned)
463 else if(src.
id()==
"pod_constructor")
464 return "pod_constructor";
475 if(statement==ID_cpp_delete ||
476 statement==ID_cpp_delete_array)
479 if(statement==ID_cpp_new ||
480 statement==ID_cpp_new_array)
The type of an expression.
std::string convert_struct(const exprt &src, unsigned &precedence) override
virtual std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator)
const std::string & id2string(const irep_idt &d)
std::string convert_function(const exprt &src, const std::string &symbol, unsigned precedence)
std::string convert_extractbit(const exprt &src, unsigned precedence)
std::vector< irept > subt
std::string expr2string() const
virtual void read(const typet &src)=0
bool has_ellipsis() const
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
std::vector< componentt > componentst
const irep_idt & get_value() const
const symbol_typet & to_symbol_type(const typet &type)
Cast a generic typet to a symbol_typet.
std::vector< parametert > parameterst
const componentst & components() const
std::string convert_code(const codet &src)
irep_idt pretty_name
Language-specific display name.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
A constant literal expression.
bool get_bool(const irep_namet &name) const
virtual std::string convert(const typet &src)
std::string convert_cpp_new(const exprt &src, unsigned precedence)
std::string convert_code(const codet &src, unsigned indent) override
std::string convert_extractbits(const exprt &src, unsigned precedence)
virtual std::string convert_constant(const constant_exprt &src, unsigned &precedence)
const irep_idt & id() const
std::string convert_code_cpp_delete(const exprt &src, unsigned precedence)
std::string convert_rec(const typet &src, const qualifierst &qualifiers, const std::string &declarator) override
virtual std::unique_ptr< qualifierst > clone() const =0
std::string expr2cpp(const exprt &expr, const namespacet &ns)
std::string convert_cpp_this(const exprt &src, unsigned precedence)
API to expression classes.
bool is_reference(const typet &type)
TO_BE_DOCUMENTED.
const irep_idt & get(const irep_namet &name) const
const typet & follow(const typet &) const
void irep2lisp(const irept &src, lispexprt &dest)
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast a generic exprt to a constant_exprt.
expr2cppt(const namespacet &_ns)
std::string convert_with_precedence(const exprt &src, unsigned &precedence) override
std::string convert_norep(const exprt &src, unsigned &precedence)
typet type
Type of symbol.
std::string convert_constant(const constant_exprt &src, unsigned &precedence) override
std::string type2cpp(const typet &type, const namespacet &ns)
virtual std::string as_string() const =0
Base class for all expressions.
bool is_rvalue_reference(const typet &type)
TO_BE_DOCUMENTED.
const parameterst & parameters() const
virtual std::string convert_with_precedence(const exprt &src, unsigned &precedence)
irept & add(const irep_namet &name)
std::string MetaString(const std::string &in)
A statement in a programming language.
const typet & subtype() const
const irept & find(const irep_namet &name) const
const typet & return_type() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
const irep_idt & get_identifier() const
static std::string indent_str(unsigned indent)
#define forall_irep(it, irep)