Skip to content

Commit 11402da

Browse files
author
Owen Jones
committed
Assign variables for all parameters
The pointer code is well suited to handle all types, not just pointers, with just a minor tweak for booleans.
1 parent b048787 commit 11402da

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

src/java_bytecode/java_object_factory.cpp

+33-38
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,20 @@ void java_object_factoryt::gen_nondet_init(
464464
}
465465
else
466466
{
467-
side_effect_expr_nondett se=side_effect_expr_nondett(type);
467+
code_assignt assign;
468+
assign.lhs()=expr;
469+
assign.add_source_location()=loc;
468470

469-
code_assignt code(expr, se);
470-
code.add_source_location()=loc;
471-
init_code.copy_to_operands(code);
471+
if(type.id()==ID_c_bool)
472+
{
473+
assign.rhs()=get_nondet_bool(type);
474+
}
475+
else
476+
{
477+
assign.rhs()=side_effect_expr_nondett(type);
478+
}
479+
480+
init_code.copy_to_operands(assign);
472481
}
473482
}
474483

@@ -702,43 +711,29 @@ exprt object_factory(
702711
const source_locationt &loc,
703712
message_handlert &message_handler)
704713
{
705-
if(type.id()==ID_pointer)
706-
{
707-
symbolt &aux_symbol=new_tmp_symbol(
708-
symbol_table,
709-
loc,
710-
type);
711-
aux_symbol.is_static_lifetime=true;
714+
symbolt &aux_symbol=new_tmp_symbol(symbol_table, loc, type);
715+
aux_symbol.is_static_lifetime=true;
712716

713-
exprt object=aux_symbol.symbol_expr();
717+
exprt object=aux_symbol.symbol_expr();
714718

715-
java_object_factoryt state(
716-
init_code,
717-
!allow_null,
718-
max_nondet_array_length,
719-
symbol_table,
720-
message_handler,
721-
loc);
722-
state.gen_nondet_init(
723-
object,
724-
false,
725-
"",
726-
false,
727-
false,
728-
false,
729-
typet(),
730-
NO_UPDATE_IN_PLACE);
719+
java_object_factoryt state(
720+
init_code,
721+
!allow_null,
722+
max_nondet_array_length,
723+
symbol_table,
724+
message_handler,
725+
loc);
726+
state.gen_nondet_init(
727+
object,
728+
false,
729+
"",
730+
false,
731+
false,
732+
false,
733+
typet(),
734+
NO_UPDATE_IN_PLACE);
731735

732-
return object;
733-
}
734-
else if(type.id()==ID_c_bool)
735-
{
736-
// We force this to 0 and 1 and won't consider
737-
// other values.
738-
return get_nondet_bool(type);
739-
}
740-
else
741-
return side_effect_expr_nondett(type);
736+
return object;
742737
}
743738

744739
/*******************************************************************\

0 commit comments

Comments
 (0)