@@ -18,8 +18,8 @@ private import ExprNodes
1818 * It would be natural to define those predicates recursively. However, because
1919 * of how `newtype`s work, this results in bad performance as a result of
2020 * 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
2323 * from an assignment to a variable read.
2424 *
2525 * For each `ConstantValue` type `T`, we define three predicates:
@@ -52,29 +52,29 @@ private module Propagation {
5252 or
5353 e =
5454 any ( UnaryOperationCfgNode unop |
55- unop .getOperator ( ) = "-" and
55+ unop .getExpr ( ) instanceof UnaryMinusExpr and
5656 isInt ( unop .getOperand ( ) , - i )
5757 or
58- unop .getOperator ( ) = "+" and
58+ unop .getExpr ( ) instanceof UnaryPlusExpr and
5959 isInt ( unop .getOperand ( ) , i )
6060 )
6161 or
62- exists ( BinaryOperationCfgNode binop , string op , int left , int right |
62+ exists ( BinaryOperationCfgNode binop , BinaryOperation b , int left , int right |
6363 e = binop and
6464 isInt ( binop .getLeftOperand ( ) , left ) and
6565 isInt ( binop .getRightOperand ( ) , right ) and
66- op = binop .getOperator ( )
66+ b = binop .getExpr ( )
6767 |
68- op = "+" and
68+ b instanceof AddExpr and
6969 i = left + right
7070 or
71- op = "-" and
71+ b instanceof SubExpr and
7272 i = left - right
7373 or
74- op = "*" and
74+ b instanceof MulExpr and
7575 i = left * right
7676 or
77- op = "/" and
77+ b instanceof DivExpr and
7878 i = left / right
7979 )
8080 }
@@ -104,16 +104,16 @@ private module Propagation {
104104 or
105105 e =
106106 any ( UnaryOperationCfgNode unop |
107- unop .getOperator ( ) = "-" and
107+ unop .getExpr ( ) instanceof UnaryMinusExpr and
108108 isFloat ( unop .getOperand ( ) , - f )
109109 or
110- unop .getOperator ( ) = "+" and
110+ unop .getExpr ( ) instanceof UnaryPlusExpr and
111111 isFloat ( unop .getOperand ( ) , f )
112112 )
113113 or
114- exists ( BinaryOperationCfgNode binop , string op , float left , float right |
114+ exists ( BinaryOperationCfgNode binop , BinaryOperation b , float left , float right |
115115 e = binop and
116- op = binop .getOperator ( ) and
116+ b = binop .getExpr ( ) and
117117 exists ( ExprCfgNode l , ExprCfgNode r |
118118 l = binop .getLeftOperand ( ) and
119119 r = binop .getRightOperand ( )
@@ -125,16 +125,16 @@ private module Propagation {
125125 isFloat ( l , left ) and isInt ( r , right )
126126 )
127127 |
128- op = "+" and
128+ b instanceof AddExpr and
129129 f = left + right
130130 or
131- op = "-" and
131+ b instanceof SubExpr and
132132 f = left - right
133133 or
134- op = "*" and
134+ b instanceof MulExpr and
135135 f = left * right
136136 or
137- op = "/" and
137+ b instanceof DivExpr and
138138 f = left / right
139139 )
140140 }
@@ -246,7 +246,7 @@ private module Propagation {
246246 e = binop and
247247 isString ( binop .getLeftOperand ( ) , left ) and
248248 isString ( binop .getRightOperand ( ) , right ) and
249- binop .getOperator ( ) = "+" and
249+ binop .getExpr ( ) instanceof AddExpr and
250250 left .length ( ) + right .length ( ) <= 1000 and
251251 s = left + right
252252 )
0 commit comments