@@ -69,45 +69,63 @@ class BinaryOpExprTree extends StandardPostOrderTree instanceof BinaryOpExpr {
69
69
}
70
70
}
71
71
72
- class LogicalOrBinaryOpExprTree extends PostOrderTree instanceof BinaryOpExpr {
72
+ class LogicalOrBinaryOpExprTree extends PreOrderTree instanceof BinaryOpExpr {
73
73
LogicalOrBinaryOpExprTree ( ) { super .getOp ( ) = "||" }
74
74
75
75
final override predicate propagatesAbnormal ( AstNode child ) {
76
76
child = [ super .getRhs ( ) , super .getLhs ( ) ]
77
77
}
78
78
79
- override predicate first ( AstNode node ) { first ( super .getLhs ( ) , node ) }
80
-
79
+ // override predicate first(AstNode node) { first(super.getLhs(), node) }
81
80
override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
81
+ // Edge to the first node in the lhs
82
+ pred = this and
83
+ first ( super .getLhs ( ) , succ ) and
84
+ completionIsSimple ( c )
85
+ or
86
+ // Edge from the last node in the lhs to the first node in the rhs
82
87
last ( super .getLhs ( ) , pred , c ) and
83
- (
84
- succ = this and c .( BooleanCompletion ) .getValue ( ) = true
85
- or
86
- first ( super .getRhs ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = false
87
- )
88
+ first ( super .getRhs ( ) , succ ) and
89
+ c .( BooleanCompletion ) .getValue ( ) = false
90
+ }
91
+
92
+ override predicate last ( AstNode node , Completion c ) {
93
+ // Lhs. as the last node
94
+ last ( super .getLhs ( ) , node , c ) and
95
+ c .( BooleanCompletion ) .getValue ( ) = true
88
96
or
89
- last ( super .getRhs ( ) , pred , c ) and succ = this
97
+ // Rhs. as the last node
98
+ last ( super .getRhs ( ) , node , c ) // and
90
99
}
91
100
}
92
101
93
- class LogicalAndBinaryOpExprTree extends PostOrderTree instanceof BinaryOpExpr {
102
+ class LogicalAndBinaryOpExprTree extends PreOrderTree instanceof BinaryOpExpr {
94
103
LogicalAndBinaryOpExprTree ( ) { super .getOp ( ) = "&&" }
95
104
96
105
final override predicate propagatesAbnormal ( AstNode child ) {
97
106
child = [ super .getRhs ( ) , super .getLhs ( ) ]
98
107
}
99
108
100
- override predicate first ( AstNode node ) { first ( super .getLhs ( ) , node ) }
101
-
109
+ // override predicate first(AstNode node) { first(super.getLhs(), node) }
102
110
override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
111
+ // Edge to the first node in the lhs
112
+ pred = this and
113
+ first ( super .getLhs ( ) , succ ) and
114
+ completionIsSimple ( c )
115
+ or
116
+ // Edge from the last node in the lhs to the first node in the rhs
103
117
last ( super .getLhs ( ) , pred , c ) and
104
- (
105
- succ = this and c .( BooleanCompletion ) .getValue ( ) = false
106
- or
107
- first ( super .getRhs ( ) , succ ) and c .( BooleanCompletion ) .getValue ( ) = true
108
- )
118
+ first ( super .getRhs ( ) , succ ) and
119
+ c .( BooleanCompletion ) .getValue ( ) = true
120
+ }
121
+
122
+ override predicate last ( AstNode node , Completion c ) {
123
+ // Lhs. as the last node
124
+ last ( super .getLhs ( ) , node , c ) and
125
+ c .( BooleanCompletion ) .getValue ( ) = false
109
126
or
110
- last ( super .getRhs ( ) , pred , c ) and succ = this
127
+ // Rhs. as the last node
128
+ last ( super .getRhs ( ) , node , c )
111
129
}
112
130
}
113
131
0 commit comments