@@ -26,7 +26,7 @@ class Split extends TSplit {
26
26
string toString ( ) { none ( ) }
27
27
}
28
28
29
- private module ConditionalCompletionSplitting {
29
+ module ConditionalCompletionSplitting {
30
30
/** A split for conditional completions. */
31
31
class ConditionalCompletionSplit extends Split , TConditionalCompletionSplit {
32
32
ConditionalCompletion completion ;
@@ -38,62 +38,52 @@ private module ConditionalCompletionSplitting {
38
38
override string toString ( ) { result = completion .toString ( ) }
39
39
}
40
40
41
- private class ConditionalCompletionSplitKind extends SplitKind , TConditionalCompletionSplitKind {
41
+ private class ConditionalCompletionSplitKind_ extends SplitKind , TConditionalCompletionSplitKind {
42
42
override int getListOrder ( ) { result = 0 }
43
43
44
44
override predicate isEnabled ( ControlFlowElement n ) { this .appliesTo ( n ) }
45
45
46
46
override string toString ( ) { result = "ConditionalCompletion" }
47
47
}
48
48
49
- private class ConditionalCompletionSplitImpl extends SplitImpl instanceof ConditionalCompletionSplit
50
- {
51
- override ConditionalCompletionSplitKind getKind ( ) { any ( ) }
49
+ module ConditionalCompletionSplittingInput {
50
+ private import Completion as Comp
52
51
53
- override predicate hasEntry ( ControlFlowElement pred , ControlFlowElement succ , Completion c ) {
54
- succ ( pred , succ , c ) and
55
- last ( succ , _, super .getCompletion ( ) ) and
52
+ class ConditionalCompletion = Comp:: ConditionalCompletion ;
53
+
54
+ class ConditionalCompletionSplitKind extends ConditionalCompletionSplitKind_ , TSplitKind { }
55
+
56
+ class ConditionalCompletionSplit = ConditionalCompletionSplitting:: ConditionalCompletionSplit ;
57
+
58
+ bindingset [ parent, parentCompletion]
59
+ private predicate condPropagateAstExpr (
60
+ AstNode parent , ConditionalCompletion parentCompletion , AstNode child ,
61
+ ConditionalCompletion childCompletion
62
+ ) {
63
+ child = parent .( NotExpr ) .getOperand ( ) .getFullyConverted ( ) and
64
+ childCompletion .( BooleanCompletion ) .getDual ( ) = parentCompletion
65
+ or
66
+ childCompletion = parentCompletion and
56
67
(
57
- astLast ( succ .asAstNode ( ) .( NotExpr ) .getOperand ( ) .getFullyConverted ( ) , pred , c ) and
58
- super .getCompletion ( ) .( BooleanCompletion ) .getDual ( ) = c
68
+ child = parent .( LogicalAndExpr ) .getAnOperand ( ) .getFullyConverted ( )
59
69
or
60
- astLast ( succ .asAstNode ( ) .( LogicalAndExpr ) .getAnOperand ( ) .getFullyConverted ( ) , pred , c ) and
61
- super .getCompletion ( ) = c
70
+ child = parent .( LogicalOrExpr ) .getAnOperand ( ) .getFullyConverted ( )
62
71
or
63
- astLast ( succ .asAstNode ( ) .( LogicalOrExpr ) .getAnOperand ( ) .getFullyConverted ( ) , pred , c ) and
64
- super .getCompletion ( ) = c
72
+ child = parent .( IfExpr ) .getBranch ( _) .getFullyConverted ( )
65
73
or
66
- succ .asAstNode ( ) =
67
- any ( IfExpr ce |
68
- astLast ( ce .getBranch ( _) .getFullyConverted ( ) , pred , c ) and
69
- super .getCompletion ( ) = c
70
- )
71
- or
72
- exists ( Expr e , Exprs:: Conversions:: ConversionOrIdentityTree conv |
73
- succ .asAstNode ( ) = conv .getAst ( ) and
74
- conv .convertsFrom ( e ) and
75
- astLast ( e , pred , c ) and
76
- super .getCompletion ( ) = c
74
+ exists ( Exprs:: Conversions:: ConversionOrIdentityTree conv |
75
+ parent = conv .getAst ( ) and
76
+ conv .convertsFrom ( child )
77
77
)
78
78
)
79
79
}
80
80
81
- override predicate hasEntryScope ( CfgInput:: CfgScope scope , ControlFlowElement succ ) { none ( ) }
82
-
83
- override predicate hasExit ( ControlFlowElement pred , ControlFlowElement succ , Completion c ) {
84
- this .appliesTo ( pred ) and
85
- succ ( pred , succ , c ) and
86
- if c instanceof ConditionalCompletion then super .getCompletion ( ) = c else any ( )
87
- }
88
-
89
- override predicate hasExitScope ( CfgInput:: CfgScope scope , ControlFlowElement last , Completion c ) {
90
- this .appliesTo ( last ) and
91
- succExit ( scope , last , c ) and
92
- if c instanceof ConditionalCompletion then super .getCompletion ( ) = c else any ( )
93
- }
94
-
95
- override predicate hasSuccessor ( ControlFlowElement pred , ControlFlowElement succ , Completion c ) {
96
- none ( )
81
+ bindingset [ parent, parentCompletion]
82
+ predicate condPropagateExpr (
83
+ ControlFlowElement parent , ConditionalCompletion parentCompletion , ControlFlowElement child ,
84
+ ConditionalCompletion childCompletion
85
+ ) {
86
+ condPropagateAstExpr ( parent .asAstNode ( ) , parentCompletion , child .asAstNode ( ) , childCompletion )
97
87
}
98
88
}
99
89
}
0 commit comments