@@ -569,35 +569,15 @@ void goto_convertt::do_java_new(
569
569
const side_effect_exprt &rhs,
570
570
goto_programt &dest)
571
571
{
572
- if (lhs.is_nil ())
573
- {
574
- error ().source_location =lhs.find_source_location ();
575
- error () << " do_java_new without lhs is yet to be implemented" << eom;
576
- throw 0 ;
577
- }
578
-
572
+ PRECONDITION (!lhs.is_nil ());
573
+ PRECONDITION (rhs.operands ().empty ());
574
+ PRECONDITION (rhs.type ().id () == ID_pointer);
579
575
source_locationt location=rhs.source_location ();
580
-
581
- assert (rhs.operands ().empty ());
582
-
583
- if (rhs.type ().id ()!=ID_pointer)
584
- {
585
- error ().source_location =rhs.find_source_location ();
586
- error () << " do_java_new returns pointer" << eom;
587
- throw 0 ;
588
- }
589
-
590
576
typet object_type=rhs.type ().subtype ();
591
577
592
578
// build size expression
593
579
exprt object_size=size_of_expr (object_type, ns);
594
-
595
- if (object_size.is_nil ())
596
- {
597
- error ().source_location =rhs.find_source_location ();
598
- error () << " do_java_new got nil object_size" << eom;
599
- throw 0 ;
600
- }
580
+ CHECK_RETURN (object_size.is_not_nil ());
601
581
602
582
// we produce a malloc side-effect, which stays
603
583
side_effect_exprt malloc_expr (ID_malloc);
@@ -624,36 +604,18 @@ void goto_convertt::do_java_new_array(
624
604
const side_effect_exprt &rhs,
625
605
goto_programt &dest)
626
606
{
627
- if (lhs.is_nil ())
628
- {
629
- error ().source_location =lhs.find_source_location ();
630
- error () << " do_java_new_array without lhs is yet to be implemented"
631
- << eom;
632
- throw 0 ;
633
- }
607
+ PRECONDITION (!lhs.is_nil ()); // do_java_new_array without lhs not implemented
608
+ PRECONDITION (rhs.operands ().size () >= 1 ); // one per dimension
609
+ PRECONDITION (rhs.type ().id () == ID_pointer);
634
610
635
611
source_locationt location=rhs.source_location ();
636
-
637
- assert (rhs.operands ().size ()>=1 ); // one per dimension
638
-
639
- if (rhs.type ().id ()!=ID_pointer)
640
- {
641
- error ().source_location =rhs.find_source_location ();
642
- error () << " do_java_new_array returns pointer" << eom;
643
- throw 0 ;
644
- }
645
-
646
612
typet object_type=rhs.type ().subtype ();
613
+ PRECONDITION (ns.follow (object_type).id () == ID_struct);
647
614
648
615
// build size expression
649
616
exprt object_size=size_of_expr (object_type, ns);
650
617
651
- if (object_size.is_nil ())
652
- {
653
- error ().source_location =rhs.find_source_location ();
654
- error () << " do_java_new_array got nil object_size" << eom;
655
- throw 0 ;
656
- }
618
+ CHECK_RETURN (!object_size.is_nil ());
657
619
658
620
// we produce a malloc side-effect, which stays
659
621
side_effect_exprt malloc_expr (ID_malloc);
@@ -664,9 +626,8 @@ void goto_convertt::do_java_new_array(
664
626
t_n->code =code_assignt (lhs, malloc_expr);
665
627
t_n->source_location =location;
666
628
667
- assert (ns.follow (object_type).id ()==ID_struct);
668
629
const struct_typet &struct_type=to_struct_type (ns.follow (object_type));
669
- assert (struct_type.components ().size ()== 3 );
630
+ PRECONDITION (struct_type.components ().size () == 3 );
670
631
671
632
// Init base class:
672
633
dereference_exprt deref (lhs, object_type);
@@ -696,7 +657,6 @@ void goto_convertt::do_java_new_array(
696
657
// Allocate a (struct realtype**) instead of a (void**) if possible.
697
658
const irept &given_element_type=object_type.find (ID_C_element_type);
698
659
typet allocate_data_type;
699
- exprt cast_data_member;
700
660
if (given_element_type.is_not_nil ())
701
661
{
702
662
allocate_data_type=
0 commit comments