133 const irep_idt &function_identifier,
182 const auto underlying_type_and_dimension =
185 bool target_type_is_reference_array =
186 underlying_type_and_dimension.second >= 1 &&
189 if(target_type_is_reference_array)
195 object_array_dimension,
197 underlying_type_and_dimension.second, object_array_dimension.
type()),
204 object_array_element_type,
230 const irept &given_element_type = object_type.
find(ID_element_type);
231 typet allocate_data_type;
238 allocate_data_type = data.
type();
241 ID_java_new_array_data, allocate_data_type, location);
248 const irept size_bound = rhs.
find(ID_length_upper_bound);
252 data_java_new_expr.
set(ID_size, size_bound);
258 data_java_new_expr.
type(),
259 "tmp_new_data_array",
270 code_assignt(new_array_data_symbol, data_java_new_expr), location));
272 exprt cast_java_new = new_array_data_symbol;
273 if(cast_java_new.
type() != data.
type())
281 if(!rhs.
get_bool(ID_skip_initialize))
283 const auto zero_element =
286 codet array_set{ID_array_set, {new_array_data_symbol, *zero_element}};
316 sub_java_new.
type() = sub_type;
325 sub_type,
"subarray_init", location, function_identifier,
symbol_table)
329 for_body.
add(std::move(init_decl));
332 for_body.
add(std::move(init_subarray));
335 for_body.
add(std::move(assign_subarray));
352 return std::prev(next);
363 const irep_idt &function_identifier,
368 if(!target->is_assign())
371 if(
as_const(*target).assign_rhs().id() == ID_side_effect)
375 exprt lhs = target->assign_lhs();
376 exprt rhs = target->assign_rhs();
379 const auto &statement = side_effect_expr.get_statement();
381 if(statement == ID_java_new)
384 function_identifier, lhs, side_effect_expr, goto_program, target);
386 else if(statement == ID_java_new_array)
409 const irep_idt &function_identifier,
413 bool changed =
false;
414 for(goto_programt::instructionst::iterator target =
420 function_identifier, goto_program, target, message_handler);
421 changed = changed || new_target == target;
439 const irep_idt &function_identifier,
447 function_identifier, goto_program, target, message_handler);
458 const irep_idt &function_identifier,
464 rem.lower_java_new(function_identifier,
function.body, message_handler);
479 bool changed =
false;
482 rem.lower_java_new(f.first, f.second.body, message_handler) || changed;
const T & as_const(T &value)
Return a reference to the same object but ensures the type is const.
pointer_typet pointer_type(const typet &subtype)
void set_class_identifier(struct_exprt &expr, const namespacet &ns, const struct_tag_typet &class_type)
If expr has its components filled in then sets the @class_identifier member of the struct.
Extract class identifier.
A goto_instruction_codet representing an assignment in the program.
A codet representing sequential composition of program statements.
void add(const codet &code)
A goto_instruction_codet representing the declaration of a local variable.
codet representation of a for statement.
static code_fort from_index_bounds(exprt start_index, exprt end_index, symbol_exprt loop_index, codet body, source_locationt location)
Produce a code_fort representing:
Data structure for representing an arbitrary statement in a program.
A constant literal expression.
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
void copy_to_operands(const exprt &expr)
Copy the given argument to the end of exprt's operands.
source_locationt & add_source_location()
const source_locationt & source_location() const
typet & type()
Return the type of the expression.
The Boolean constant false.
A collection of goto functions.
function_mapt function_map
::goto_functiont goto_functiont
void compute_location_numbers()
symbol_tablet symbol_table
Symbol table.
goto_functionst goto_functions
GOTO functions.
A generic container class for the GOTO intermediate representation of one function.
instructionst instructions
The list of instructions in the goto program.
void update()
Update all indices.
void destructive_insert(const_targett target, goto_programt &p)
Inserts the given program p before target.
instructionst::iterator targett
static instructiont make_assignment(const code_assignt &_code, const source_locationt &l=source_locationt::nil())
Create an assignment instruction.
targett insert_after(const_targett target)
Insertion after the instruction pointed-to by the given instruction iterator target.
static instructiont make_other(const goto_instruction_codet &_code, const source_locationt &l=source_locationt::nil())
static instructiont make_decl(const symbol_exprt &symbol, const source_locationt &l=source_locationt::nil())
targett insert_before(const_targett target)
Insertion before the instruction pointed-to by the given instruction iterator target.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
bool get_bool(const irep_idt &name) const
const irept & find(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
Extract member of struct or union.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The plus expression Associativity is not specified.
const typet & base_type() const
The type of the data what we point to.
remove_java_newt(symbol_table_baset &symbol_table)
symbol_table_baset & symbol_table
bool lower_java_new(const irep_idt &function_identifier, goto_programt &, message_handlert &)
Replace every java_new or java_new_array by a malloc side-effect and zero initialization.
goto_programt::targett lower_java_new_array(const irep_idt &function_identifier, const exprt &lhs, const side_effect_exprt &rhs, goto_programt &, goto_programt::targett, message_handlert &)
Replaces the instruction lhs = new java_array_type by the following code: lhs = ALLOCATE(java_type) l...
An expression containing a side effect.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
const componentst & components() const
Expression to hold a symbol (variable)
The symbol table base class interface.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
const irep_idt & get_identifier() const
Semantic type conversion.
The type of an expression, extends irept.
std::optional< exprt > zero_initializer(const typet &type, const source_locationt &source_location, const namespacet &ns)
Create the equivalent of zero for type type.
Expression Initialization.
void goto_convert(const codet &code, symbol_table_baset &symbol_table, goto_programt &dest, message_handlert &message_handler, const irep_idt &mode)
bool is_valid_java_array(const struct_typet &type)
Programmatic documentation of the structure of a Java array (of either primitives or references) type...
std::pair< typet, std::size_t > java_array_dimension_and_element_type(const struct_tag_typet &type)
Returns the underlying element type and array dimensionality of Java struct type.
exprt get_array_element_type_field(const exprt &pointer)
exprt get_array_dimension_field(const exprt &pointer)
bool can_cast_type< java_reference_typet >(const typet &type)
symbolt & fresh_java_symbol(const typet &type, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &function_name, symbol_table_baset &symbol_table)
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
exprt object_size(const exprt &pointer)
void remove_java_new(const irep_idt &function_identifier, goto_programt::targett target, goto_programt &goto_program, symbol_table_baset &symbol_table, message_handlert &message_handler)
Replace every java_new or java_new_array by a malloc side-effect and zero initialization.
Remove Java New Operators.
exprt deref_expr(const exprt &expr)
Wraps a given expression into a dereference_exprt unless it is an address_of_exprt in which case it j...
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
side_effect_exprt & to_side_effect_expr(exprt &expr)
const multi_ary_exprt & to_multi_ary_expr(const exprt &expr)
Cast an exprt to a multi_ary_exprt.
const struct_exprt & to_struct_expr(const exprt &expr)
Cast an exprt to a struct_exprt.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.