Skip to content

Commit 78c12b5

Browse files
author
Daniel Kroening
committed
codet: introduce codet operand methods
1 parent ec3aebb commit 78c12b5

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed

src/util/std_code.h

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,39 @@ class codet:public exprt
119119
{
120120
check_code(code, vm);
121121
}
122+
123+
protected:
124+
typedef std::vector<codet> code_operandst;
125+
126+
code_operandst &code_operands()
127+
{ return (code_operandst &)get_sub(); }
128+
129+
const code_operandst &code_operands() const
130+
{ return (const code_operandst &)get_sub(); }
131+
132+
codet &code_op0()
133+
{ return code_operands().front(); }
134+
135+
codet &code_op1()
136+
{ return code_operands()[1]; }
137+
138+
codet &code_op2()
139+
{ return code_operands()[2]; }
140+
141+
codet &code_op3()
142+
{ return code_operands()[3]; }
143+
144+
const codet &code_op0() const
145+
{ return code_operands().front(); }
146+
147+
const codet &code_op1() const
148+
{ return code_operands()[1]; }
149+
150+
const codet &code_op2() const
151+
{ return code_operands()[2]; }
152+
153+
const codet &code_op3() const
154+
{ return code_operands()[3]; }
122155
};
123156

124157
namespace detail // NOLINT
@@ -770,12 +803,12 @@ class code_switcht:public codet
770803

771804
const codet &body() const
772805
{
773-
return to_code(op1());
806+
return code_op1();
774807
}
775808

776809
codet &body()
777810
{
778-
return static_cast<codet &>(op1());
811+
return code_op1();
779812
}
780813

781814
protected:
@@ -836,12 +869,12 @@ class code_whilet:public codet
836869

837870
const codet &body() const
838871
{
839-
return to_code(op1());
872+
return code_op1();
840873
}
841874

842875
codet &body()
843876
{
844-
return static_cast<codet &>(op1());
877+
return code_op1();
845878
}
846879

847880
protected:
@@ -902,12 +935,12 @@ class code_dowhilet:public codet
902935

903936
const codet &body() const
904937
{
905-
return to_code(op1());
938+
return code_op1();
906939
}
907940

908941
codet &body()
909942
{
910-
return static_cast<codet &>(op1());
943+
return code_op1();
911944
}
912945

913946
protected:
@@ -997,12 +1030,12 @@ class code_fort:public codet
9971030

9981031
const codet &body() const
9991032
{
1000-
return to_code(op3());
1033+
return code_op3();
10011034
}
10021035

10031036
codet &body()
10041037
{
1005-
return static_cast<codet &>(op3());
1038+
return code_op3();
10061039
}
10071040

10081041
protected:
@@ -1356,12 +1389,12 @@ class code_labelt:public codet
13561389

13571390
codet &code()
13581391
{
1359-
return static_cast<codet &>(op0());
1392+
return code_op0();
13601393
}
13611394

13621395
const codet &code() const
13631396
{
1364-
return static_cast<const codet &>(op0());
1397+
return code_op0();
13651398
}
13661399

13671400
protected:
@@ -1433,12 +1466,12 @@ class code_switch_caset:public codet
14331466

14341467
codet &code()
14351468
{
1436-
return static_cast<codet &>(op1());
1469+
return code_op1();
14371470
}
14381471

14391472
const codet &code() const
14401473
{
1441-
return static_cast<const codet &>(op1());
1474+
return code_op1();
14421475
}
14431476

14441477
protected:
@@ -2230,12 +2263,12 @@ class code_try_catcht:public codet
22302263

22312264
codet &try_code()
22322265
{
2233-
return static_cast<codet &>(op0());
2266+
return code_op0();
22342267
}
22352268

22362269
const codet &try_code() const
22372270
{
2238-
return static_cast<const codet &>(op0());
2271+
return code_op0();
22392272
}
22402273

22412274
code_declt &get_catch_decl(unsigned i)

0 commit comments

Comments
 (0)