Skip to content

Commit 2bb9dd9

Browse files
author
Daniel Kroening
committed
codet: introduce codet operand methods
1 parent a4aaaf5 commit 2bb9dd9

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:
@@ -1352,12 +1385,12 @@ class code_labelt:public codet
13521385

13531386
codet &code()
13541387
{
1355-
return static_cast<codet &>(op0());
1388+
return code_op0();
13561389
}
13571390

13581391
const codet &code() const
13591392
{
1360-
return static_cast<const codet &>(op0());
1393+
return code_op0();
13611394
}
13621395

13631396
protected:
@@ -1429,12 +1462,12 @@ class code_switch_caset:public codet
14291462

14301463
codet &code()
14311464
{
1432-
return static_cast<codet &>(op1());
1465+
return code_op1();
14331466
}
14341467

14351468
const codet &code() const
14361469
{
1437-
return static_cast<const codet &>(op1());
1470+
return code_op1();
14381471
}
14391472

14401473
protected:
@@ -2407,12 +2440,12 @@ class code_try_catcht:public codet
24072440

24082441
codet &try_code()
24092442
{
2410-
return static_cast<codet &>(op0());
2443+
return code_op0();
24112444
}
24122445

24132446
const codet &try_code() const
24142447
{
2415-
return static_cast<const codet &>(op0());
2448+
return code_op0();
24162449
}
24172450

24182451
code_declt &get_catch_decl(unsigned i)

0 commit comments

Comments
 (0)