29 exprt object_tc=object;
40 if(tmp_type.id()==ID_array)
49 if(!operands.empty() && !operands.front().get_bool(
"#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()==
"infinity")
76 exprt tmp_size=size_expr;
84 <<
"' is not a constant" <<
eom;
105 codet new_code(ID_block);
115 exprt index(ID_index);
120 if(!operands.empty())
122 exprt operand(ID_index);
126 tmp_operands.push_back(operand);
148 for(exprt::operandst::iterator
149 it=operands_tc.begin();
150 it!=operands_tc.end();
157 if(operands_tc.empty())
162 else if(operands_tc.size()==1)
165 object_tc.
type().
set(ID_C_constant,
false);
166 object_tc.
set(ID_C_lvalue,
true);
176 error() <<
"initialization of POD requires one argument, " 177 "but got " << operands.size() <<
eom;
183 else if(tmp_type.id()==ID_union)
187 else if(tmp_type.id()==ID_struct)
191 for(exprt::operandst::iterator
192 it=operands_tc.begin();
193 it!=operands_tc.end();
204 codet block(ID_block);
205 for(std::size_t i=0; i < struct_type.
components().size(); i++)
208 if(component.
get(ID_base_name)!=
"@most_derived")
212 member.
set(ID_component_name, component.
get(ID_name));
215 member.
set(ID_C_lvalue, object_tc.
get_bool(ID_C_lvalue));
219 if(!component.
get_bool(
"from_base"))
241 for(struct_typet::componentst::const_iterator
242 it=components.begin();
243 it!=components.end();
246 const typet &type=it->type();
248 if(!it->get_bool(ID_from_base) &&
249 type.
id()==ID_code &&
250 type.
find(ID_return_type).
id()==ID_constructor)
252 constructor_name=it->get(ID_base_name);
258 assert(constructor_name!=
"");
260 irept cpp_name(ID_cpp_name);
262 cpp_name.
get_sub().back().set(ID_identifier, constructor_name);
263 cpp_name.
get_sub().back().set(ID_C_source_location, source_location);
267 function_call.
function().
swap(static_cast<exprt&>(cpp_name));
268 function_call.
arguments().reserve(operands_tc.size());
270 for(exprt::operandst::iterator
271 it=operands_tc.begin();
272 it!=operands_tc.end();
277 assert(function_call.
get(ID_statement)==ID_temporary_object);
280 static_cast<exprt &
>(function_call.
add(ID_initializer));
282 assert(initializer.id()==ID_code &&
283 initializer.get(ID_statement)==ID_expression);
288 exprt &tmp_this=func_ini.arguments().front();
289 assert(tmp_this.id()==ID_address_of
290 && tmp_this.op0().id()==
"new_object");
317 exprt tmp_object_expr=
exprt(ID_side_effect, type);
318 tmp_object_expr.
set(ID_statement, ID_temporary_object);
321 exprt new_object(ID_new_object);
323 new_object.
set(ID_C_lvalue,
true);
324 new_object.
type()=tmp_object_expr.
type();
333 if(new_code.
get(ID_statement)==ID_assign)
336 tmp_object_expr.
add(ID_initializer)=new_code;
339 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)
const irep_idt & id() const
const array_typet & to_array_type(const typet &type)
Cast a generic typet to an array_typet.
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.
bitvector_typet index_type()
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
const struct_typet & to_struct_type(const typet &type)
Cast a generic typet to a struct_typet.
cpp_scopet & set_scope(const irep_idt &identifier)
A function call side effect.
void follow_symbol(irept &irep) const
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)