@@ -7,9 +7,17 @@ private import TranslatedElement
7
7
private import TranslatedExpr
8
8
9
9
abstract class ConditionContext extends TranslatedElement {
10
- abstract Instruction getChildTrueSuccessor ( TranslatedCondition child ) ;
11
-
12
- abstract Instruction getChildFalseSuccessor ( TranslatedCondition child ) ;
10
+ /**
11
+ * Gets the instruction to be executed when `child` evaluates to `true`. The
12
+ * successor edge kind is specified by `kind`.
13
+ */
14
+ abstract Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) ;
15
+
16
+ /**
17
+ * Gets the instruction to be executed when `child` evaluates to `false`. The
18
+ * successor edge kind is specified by `kind`.
19
+ */
20
+ abstract Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) ;
13
21
}
14
22
15
23
TranslatedCondition getTranslatedCondition ( Expr expr ) { result .getExpr ( ) = expr }
@@ -62,14 +70,14 @@ abstract class TranslatedFlexibleCondition extends TranslatedCondition, Conditio
62
70
class TranslatedParenthesisCondition extends TranslatedFlexibleCondition {
63
71
override ParenthesisExpr expr ;
64
72
65
- final override Instruction getChildTrueSuccessor ( TranslatedCondition child ) {
73
+ final override Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) {
66
74
child = this .getOperand ( ) and
67
- result = this .getConditionContext ( ) .getChildTrueSuccessor ( this )
75
+ result = this .getConditionContext ( ) .getChildTrueSuccessor ( this , kind )
68
76
}
69
77
70
- final override Instruction getChildFalseSuccessor ( TranslatedCondition child ) {
78
+ final override Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) {
71
79
child = this .getOperand ( ) and
72
- result = this .getConditionContext ( ) .getChildFalseSuccessor ( this )
80
+ result = this .getConditionContext ( ) .getChildFalseSuccessor ( this , kind )
73
81
}
74
82
75
83
final override TranslatedCondition getOperand ( ) {
@@ -114,34 +122,34 @@ abstract class TranslatedBinaryLogicalOperation extends TranslatedNativeConditio
114
122
class TranslatedLogicalAndExpr extends TranslatedBinaryLogicalOperation {
115
123
TranslatedLogicalAndExpr ( ) { expr instanceof LogicalAndExpr }
116
124
117
- override Instruction getChildTrueSuccessor ( TranslatedCondition child ) {
125
+ override Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) {
118
126
child = this .getLeftOperand ( ) and
119
- result = this .getRightOperand ( ) .getFirstInstruction ( any ( GotoEdge edge ) )
127
+ result = this .getRightOperand ( ) .getFirstInstruction ( kind )
120
128
or
121
129
child = this .getRightOperand ( ) and
122
- result = this .getConditionContext ( ) .getChildTrueSuccessor ( this )
130
+ result = this .getConditionContext ( ) .getChildTrueSuccessor ( this , kind )
123
131
}
124
132
125
- override Instruction getChildFalseSuccessor ( TranslatedCondition child ) {
133
+ override Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) {
126
134
( child = this .getLeftOperand ( ) or child = this .getRightOperand ( ) ) and
127
- result = this .getConditionContext ( ) .getChildFalseSuccessor ( this )
135
+ result = this .getConditionContext ( ) .getChildFalseSuccessor ( this , kind )
128
136
}
129
137
}
130
138
131
139
class TranslatedLogicalOrExpr extends TranslatedBinaryLogicalOperation {
132
140
override LogicalOrExpr expr ;
133
141
134
- override Instruction getChildTrueSuccessor ( TranslatedCondition child ) {
142
+ override Instruction getChildTrueSuccessor ( TranslatedCondition child , EdgeKind kind ) {
135
143
( child = this .getLeftOperand ( ) or child = this .getRightOperand ( ) ) and
136
- result = this .getConditionContext ( ) .getChildTrueSuccessor ( this )
144
+ result = this .getConditionContext ( ) .getChildTrueSuccessor ( this , kind )
137
145
}
138
146
139
- override Instruction getChildFalseSuccessor ( TranslatedCondition child ) {
147
+ override Instruction getChildFalseSuccessor ( TranslatedCondition child , EdgeKind kind ) {
140
148
child = this .getLeftOperand ( ) and
141
- result = this .getRightOperand ( ) .getFirstInstruction ( any ( GotoEdge edge ) )
149
+ result = this .getRightOperand ( ) .getFirstInstruction ( kind )
142
150
or
143
151
child = this .getRightOperand ( ) and
144
- result = this .getConditionContext ( ) .getChildFalseSuccessor ( this )
152
+ result = this .getConditionContext ( ) .getChildFalseSuccessor ( this , kind )
145
153
}
146
154
}
147
155
@@ -170,10 +178,10 @@ class TranslatedValueCondition extends TranslatedCondition, TTranslatedValueCond
170
178
tag = ValueConditionConditionalBranchTag ( ) and
171
179
(
172
180
kind instanceof TrueEdge and
173
- result = this .getConditionContext ( ) .getChildTrueSuccessor ( this )
181
+ result = this .getConditionContext ( ) .getChildTrueSuccessor ( this , any ( GotoEdge edge ) )
174
182
or
175
183
kind instanceof FalseEdge and
176
- result = this .getConditionContext ( ) .getChildFalseSuccessor ( this )
184
+ result = this .getConditionContext ( ) .getChildFalseSuccessor ( this , any ( GotoEdge edge ) )
177
185
)
178
186
}
179
187
0 commit comments