30 exprt object_tc=object;
40 if(tmp_type.id()==ID_array)
49 if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
52 error() <<
"bad array initializer" <<
eom;
56 assert(operands.empty() || operands.size()==1);
65 const exprt &size_expr=
68 if(size_expr.
id() == ID_infinity)
76 exprt tmp_size=size_expr;
84 <<
"' is not a constant" <<
eom;
118 if(!operands.empty())
122 tmp_operands.push_back(operand);
144 for(exprt::operandst::iterator
145 it=operands_tc.begin();
146 it!=operands_tc.end();
153 if(operands_tc.empty())
158 else if(operands_tc.size()==1)
161 object_tc.
type().
set(ID_C_constant,
false);
162 object_tc.
set(ID_C_lvalue,
true);
171 error() <<
"initialization of POD requires one argument, " 172 "but got " << operands.size() <<
eom;
178 else if(tmp_type.id()==ID_union)
182 else if(tmp_type.id()==ID_struct)
186 for(exprt::operandst::iterator
187 it=operands_tc.begin();
188 it!=operands_tc.end();
200 for(std::size_t i=0; i < struct_type.
components().size(); i++)
203 if(component.
get(ID_base_name)!=
"@most_derived")
208 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
212 if(!component.
get_bool(
"from_base"))
232 for(struct_typet::componentst::const_iterator
233 it=components.begin();
234 it!=components.end();
237 const typet &type=it->type();
239 if(!it->get_bool(ID_from_base) &&
240 type.
id()==ID_code &&
241 type.
find(ID_return_type).
id()==ID_constructor)
243 constructor_name=it->get(ID_base_name);
249 assert(constructor_name!=
"");
251 irept cpp_name(ID_cpp_name);
253 cpp_name.
get_sub().back().set(ID_identifier, constructor_name);
254 cpp_name.
get_sub().back().set(ID_C_source_location, source_location);
258 function_call.
function().
swap(static_cast<exprt&>(cpp_name));
259 function_call.
arguments().reserve(operands_tc.size());
261 for(exprt::operandst::iterator
262 it=operands_tc.begin();
263 it!=operands_tc.end();
268 assert(function_call.
get(ID_statement)==ID_temporary_object);
271 static_cast<exprt &
>(function_call.
add(ID_initializer));
273 assert(initializer.id()==ID_code &&
274 initializer.get(ID_statement)==ID_expression);
279 exprt &tmp_this=func_ini.arguments().front();
280 assert(tmp_this.id()==ID_address_of
281 && tmp_this.op0().id()==
"new_object");
308 exprt tmp_object_expr=
exprt(ID_side_effect, type);
309 tmp_object_expr.
set(ID_statement, ID_temporary_object);
312 exprt new_object(ID_new_object);
314 new_object.
set(ID_C_lvalue,
true);
315 new_object.
type()=tmp_object_expr.
type();
324 if(new_code.
get(ID_statement)==ID_assign)
327 tmp_object_expr.
add(ID_initializer)=new_code;
330 temporary.
swap(tmp_object_expr);
side_effect_expr_function_callt & to_side_effect_expr_function_call(exprt &expr)
The type of an expression.
void typecheck_side_effect_function_call(side_effect_expr_function_callt &expr)
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
void add_implicit_dereference(exprt &expr)
void copy_to_operands(const exprt &expr)
std::vector< componentt > componentst
void move_to_operands(exprt &expr)
void already_typechecked(irept &irep)
const componentst & components() const
static mstreamt & eom(mstreamt &m)
bool get_bool(const irep_namet &name) const
virtual void typecheck_expr(exprt &expr)
Extract member of struct or union.
const irep_idt & id() const
void elaborate_class_template(const typet &type)
elaborate class template instances
The boolean constant true.
source_locationt source_location
bool cpp_is_pod(const typet &type) const
bool is_reference(const typet &type)
TO_BE_DOCUMENTED.
const irep_idt & get(const irep_namet &name) const
const exprt & size() const
Base class for tree-like data structures with sharing.
C++ Language Type Checking.
const typet & follow(const typet &) const
bitvector_typet index_type()
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
void typecheck_side_effect_assignment(side_effect_exprt &expr)
Operator to return the address of an object.
The boolean constant false.
std::vector< exprt > operandst
cpp_scopet & set_scope(const irep_idt &identifier)
A function call side effect.
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
Base class for all expressions.
const source_locationt & source_location() const
const exprt & expression() const
virtual void make_constant_index(exprt &expr)
irept & add(const irep_namet &name)
virtual std::string to_string(const typet &type)
exprt::operandst & arguments()
source_locationt & add_source_location()
const codet & to_code(const exprt &expr)
A statement in a programming language.
An expression containing a side effect.
const irept & find(const irep_namet &name) const
codet cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
void set(const irep_namet &name, const irep_idt &value)