@@ -59,6 +59,39 @@ class codet:public exprt
59
59
codet &last_statement ();
60
60
const codet &last_statement () const ;
61
61
class code_blockt &make_block ();
62
+
63
+ protected:
64
+ typedef std::vector<codet> code_operandst;
65
+
66
+ code_operandst &code_operands ()
67
+ { return (code_operandst &)get_sub (); }
68
+
69
+ const code_operandst &code_operands () const
70
+ { return (const code_operandst &)get_sub (); }
71
+
72
+ codet &code_op0 ()
73
+ { return code_operands ().front (); }
74
+
75
+ codet &code_op1 ()
76
+ { return code_operands ()[1 ]; }
77
+
78
+ codet &code_op2 ()
79
+ { return code_operands ()[2 ]; }
80
+
81
+ codet &code_op3 ()
82
+ { return code_operands ()[3 ]; }
83
+
84
+ const codet &code_op0 () const
85
+ { return code_operands ().front (); }
86
+
87
+ const codet &code_op1 () const
88
+ { return code_operands ()[1 ]; }
89
+
90
+ const codet &code_op2 () const
91
+ { return code_operands ()[2 ]; }
92
+
93
+ const codet &code_op3 () const
94
+ { return code_operands ()[3 ]; }
62
95
};
63
96
64
97
namespace detail // NOLINT
@@ -595,12 +628,12 @@ class code_switcht:public codet
595
628
596
629
const codet &body () const
597
630
{
598
- return to_code ( op1 () );
631
+ return code_op1 ( );
599
632
}
600
633
601
634
codet &body ()
602
635
{
603
- return static_cast <codet &>( op1 () );
636
+ return code_op1 ( );
604
637
}
605
638
};
606
639
@@ -657,12 +690,12 @@ class code_whilet:public codet
657
690
658
691
const codet &body () const
659
692
{
660
- return to_code ( op1 () );
693
+ return code_op1 ( );
661
694
}
662
695
663
696
codet &body ()
664
697
{
665
- return static_cast <codet &>( op1 () );
698
+ return code_op1 ( );
666
699
}
667
700
};
668
701
@@ -719,12 +752,12 @@ class code_dowhilet:public codet
719
752
720
753
const codet &body () const
721
754
{
722
- return to_code ( op1 () );
755
+ return code_op1 ( );
723
756
}
724
757
725
758
codet &body ()
726
759
{
727
- return static_cast <codet &>( op1 () );
760
+ return code_op1 ( );
728
761
}
729
762
};
730
763
@@ -796,12 +829,12 @@ class code_fort:public codet
796
829
797
830
const codet &body () const
798
831
{
799
- return to_code ( op3 () );
832
+ return code_op3 ( );
800
833
}
801
834
802
835
codet &body ()
803
836
{
804
- return static_cast <codet &>( op3 () );
837
+ return code_op3 ( );
805
838
}
806
839
};
807
840
@@ -1076,12 +1109,12 @@ class code_labelt:public codet
1076
1109
1077
1110
codet &code ()
1078
1111
{
1079
- return static_cast <codet &>( op0 () );
1112
+ return code_op0 ( );
1080
1113
}
1081
1114
1082
1115
const codet &code () const
1083
1116
{
1084
- return static_cast < const codet &>( op0 () );
1117
+ return code_op0 ( );
1085
1118
}
1086
1119
};
1087
1120
@@ -1123,7 +1156,9 @@ class code_switch_caset:public codet
1123
1156
code_switch_caset (
1124
1157
const exprt &_case_op, const codet &_code):codet(ID_switch_case)
1125
1158
{
1126
- add_to_operands (_case_op, _code);
1159
+ operands ().resize (2 );
1160
+ op0 ()=_case_op;
1161
+ code_op1 ()=_code;
1127
1162
}
1128
1163
1129
1164
bool is_default () const
@@ -1148,12 +1183,12 @@ class code_switch_caset:public codet
1148
1183
1149
1184
codet &code ()
1150
1185
{
1151
- return static_cast <codet &>( op1 () );
1186
+ return code_op1 ( );
1152
1187
}
1153
1188
1154
1189
const codet &code () const
1155
1190
{
1156
- return static_cast < const codet &>( op1 () );
1191
+ return code_op1 ( );
1157
1192
}
1158
1193
};
1159
1194
@@ -1788,12 +1823,12 @@ class code_try_catcht:public codet
1788
1823
1789
1824
codet &try_code ()
1790
1825
{
1791
- return static_cast <codet &>( op0 () );
1826
+ return code_op0 ( );
1792
1827
}
1793
1828
1794
1829
const codet &try_code () const
1795
1830
{
1796
- return static_cast < const codet &>( op0 () );
1831
+ return code_op0 ( );
1797
1832
}
1798
1833
1799
1834
code_declt &get_catch_decl (unsigned i)
0 commit comments