@@ -18,8 +18,8 @@ private import ExprNodes
18
18
* It would be natural to define those predicates recursively. However, because
19
19
* of how `newtype`s work, this results in bad performance as a result of
20
20
* unnecessary recursion through the constructors of `TConstantValue`. Instead,
21
- * we define a set of predicats for each possible `ConstantValue` type, and each
22
- * set of predicates need to replicate logic, e.g., how a constant may be propagated
21
+ * we define a set of predicates for each possible `ConstantValue` type, and each
22
+ * set of predicates needs to replicate logic, e.g., how a constant may be propagated
23
23
* from an assignment to a variable read.
24
24
*
25
25
* For each `ConstantValue` type `T`, we define three predicates:
@@ -52,29 +52,29 @@ private module Propagation {
52
52
or
53
53
e =
54
54
any ( UnaryOperationCfgNode unop |
55
- unop .getOperator ( ) = "-" and
55
+ unop .getExpr ( ) instanceof UnaryMinusExpr and
56
56
isInt ( unop .getOperand ( ) , - i )
57
57
or
58
- unop .getOperator ( ) = "+" and
58
+ unop .getExpr ( ) instanceof UnaryPlusExpr and
59
59
isInt ( unop .getOperand ( ) , i )
60
60
)
61
61
or
62
- exists ( BinaryOperationCfgNode binop , string op , int left , int right |
62
+ exists ( BinaryOperationCfgNode binop , BinaryOperation b , int left , int right |
63
63
e = binop and
64
64
isInt ( binop .getLeftOperand ( ) , left ) and
65
65
isInt ( binop .getRightOperand ( ) , right ) and
66
- op = binop .getOperator ( )
66
+ b = binop .getExpr ( )
67
67
|
68
- op = "+" and
68
+ b instanceof AddExpr and
69
69
i = left + right
70
70
or
71
- op = "-" and
71
+ b instanceof SubExpr and
72
72
i = left - right
73
73
or
74
- op = "*" and
74
+ b instanceof MulExpr and
75
75
i = left * right
76
76
or
77
- op = "/" and
77
+ b instanceof DivExpr and
78
78
i = left / right
79
79
)
80
80
}
@@ -104,16 +104,16 @@ private module Propagation {
104
104
or
105
105
e =
106
106
any ( UnaryOperationCfgNode unop |
107
- unop .getOperator ( ) = "-" and
107
+ unop .getExpr ( ) instanceof UnaryMinusExpr and
108
108
isFloat ( unop .getOperand ( ) , - f )
109
109
or
110
- unop .getOperator ( ) = "+" and
110
+ unop .getExpr ( ) instanceof UnaryPlusExpr and
111
111
isFloat ( unop .getOperand ( ) , f )
112
112
)
113
113
or
114
- exists ( BinaryOperationCfgNode binop , string op , float left , float right |
114
+ exists ( BinaryOperationCfgNode binop , BinaryOperation b , float left , float right |
115
115
e = binop and
116
- op = binop .getOperator ( ) and
116
+ b = binop .getExpr ( ) and
117
117
exists ( ExprCfgNode l , ExprCfgNode r |
118
118
l = binop .getLeftOperand ( ) and
119
119
r = binop .getRightOperand ( )
@@ -125,16 +125,16 @@ private module Propagation {
125
125
isFloat ( l , left ) and isInt ( r , right )
126
126
)
127
127
|
128
- op = "+" and
128
+ b instanceof AddExpr and
129
129
f = left + right
130
130
or
131
- op = "-" and
131
+ b instanceof SubExpr and
132
132
f = left - right
133
133
or
134
- op = "*" and
134
+ b instanceof MulExpr and
135
135
f = left * right
136
136
or
137
- op = "/" and
137
+ b instanceof DivExpr and
138
138
f = left / right
139
139
)
140
140
}
@@ -246,7 +246,7 @@ private module Propagation {
246
246
e = binop and
247
247
isString ( binop .getLeftOperand ( ) , left ) and
248
248
isString ( binop .getRightOperand ( ) , right ) and
249
- binop .getOperator ( ) = "+" and
249
+ binop .getExpr ( ) instanceof AddExpr and
250
250
left .length ( ) + right .length ( ) <= 1000 and
251
251
s = left + right
252
252
)
0 commit comments