@@ -326,11 +326,12 @@ private void createFormal(polyglot.ast.Formal formal, int counter){
326
326
* Literal Creation
327
327
*/
328
328
private soot .Value createLiteral (polyglot .ast .Lit lit ) {
329
+ //System.out.println("lit: "+lit+" type: "+lit.getClass());
329
330
if (lit instanceof polyglot .ast .IntLit ) {
330
331
polyglot .ast .IntLit intLit = (polyglot .ast .IntLit )lit ;
331
332
long litValue = intLit .value ();
332
333
if (intLit .kind () == polyglot .ast .IntLit .INT ) {
333
- return soot .jimple .IntConstant .v ((int )litValue );
334
+ return soot .jimple .IntConstant .v ((int )litValue );
334
335
}
335
336
else {
336
337
return soot .jimple .LongConstant .v (litValue );
@@ -356,7 +357,7 @@ else if (lit instanceof polyglot.ast.FloatLit) {
356
357
}
357
358
else if (lit instanceof polyglot .ast .CharLit ) {
358
359
char litValue = ((polyglot .ast .CharLit )lit ).value ();
359
- return soot .jimple .IntConstant .v (( int ) litValue );
360
+ return soot .jimple .IntConstant .v (litValue );
360
361
}
361
362
else if (lit instanceof polyglot .ast .BooleanLit ) {
362
363
boolean litValue = ((polyglot .ast .BooleanLit )lit ).value ();
@@ -2119,13 +2120,40 @@ else if (operator == polyglot.ast.Binary.DIV){
2119
2120
rValue = soot .jimple .Jimple .v ().newDivExpr (lVal , rVal );
2120
2121
}
2121
2122
else if (operator == polyglot .ast .Binary .SHR ){
2122
- rValue = soot .jimple .Jimple .v ().newShrExpr (lVal , rVal );
2123
+ if (rVal .getType ().equals (soot .LongType .v ())){
2124
+ soot .Local intVal = lg .generateLocal (soot .IntType .v ());
2125
+ soot .jimple .CastExpr castExpr = soot .jimple .Jimple .v ().newCastExpr (rVal , soot .IntType .v ());
2126
+ soot .jimple .AssignStmt assignStmt = soot .jimple .Jimple .v ().newAssignStmt (intVal , castExpr );
2127
+ body .getUnits ().add (assignStmt );
2128
+ rValue = soot .jimple .Jimple .v ().newUshrExpr (lVal , intVal );
2129
+ }
2130
+ else {
2131
+ rValue = soot .jimple .Jimple .v ().newShrExpr (lVal , rVal );
2132
+ }
2123
2133
}
2124
2134
else if (operator == polyglot .ast .Binary .USHR ){
2125
- rValue = soot .jimple .Jimple .v ().newUshrExpr (lVal , rVal );
2135
+ if (rVal .getType ().equals (soot .LongType .v ())){
2136
+ soot .Local intVal = lg .generateLocal (soot .IntType .v ());
2137
+ soot .jimple .CastExpr castExpr = soot .jimple .Jimple .v ().newCastExpr (rVal , soot .IntType .v ());
2138
+ soot .jimple .AssignStmt assignStmt = soot .jimple .Jimple .v ().newAssignStmt (intVal , castExpr );
2139
+ body .getUnits ().add (assignStmt );
2140
+ rValue = soot .jimple .Jimple .v ().newUshrExpr (lVal , intVal );
2141
+ }
2142
+ else {
2143
+ rValue = soot .jimple .Jimple .v ().newUshrExpr (lVal , rVal );
2144
+ }
2126
2145
}
2127
2146
else if (operator == polyglot .ast .Binary .SHL ){
2128
- rValue = soot .jimple .Jimple .v ().newShlExpr (lVal , rVal );
2147
+ if (rVal .getType ().equals (soot .LongType .v ())){
2148
+ soot .Local intVal = lg .generateLocal (soot .IntType .v ());
2149
+ soot .jimple .CastExpr castExpr = soot .jimple .Jimple .v ().newCastExpr (rVal , soot .IntType .v ());
2150
+ soot .jimple .AssignStmt assignStmt = soot .jimple .Jimple .v ().newAssignStmt (intVal , castExpr );
2151
+ body .getUnits ().add (assignStmt );
2152
+ rValue = soot .jimple .Jimple .v ().newUshrExpr (lVal , intVal );
2153
+ }
2154
+ else {
2155
+ rValue = soot .jimple .Jimple .v ().newShlExpr (lVal , rVal );
2156
+ }
2129
2157
}
2130
2158
else if (operator == polyglot .ast .Binary .BIT_AND ){
2131
2159
rValue = soot .jimple .Jimple .v ().newAndExpr (lVal , rVal );
@@ -2814,7 +2842,8 @@ else if (type instanceof soot.LongType) {
2814
2842
* Cast Expression Creation
2815
2843
*/
2816
2844
private soot .Value getCastLocal (polyglot .ast .Cast castExpr ){
2817
-
2845
+
2846
+ //System.out.println("castExpr: "+castExpr);
2818
2847
2819
2848
// if its already the right type
2820
2849
if (castExpr .expr ().type ().equals (castExpr .type ())) {
@@ -2831,10 +2860,13 @@ private soot.Value getCastLocal(polyglot.ast.Cast castExpr){
2831
2860
}
2832
2861
soot .Type type = Util .getSootType (castExpr .type ());
2833
2862
2863
+ /*if (type.equals(soot.CharType.v())) {
2864
+ return val;
2865
+ }*/
2834
2866
soot .jimple .CastExpr cast = soot .jimple .Jimple .v ().newCastExpr (val , type );
2835
2867
Util .addLnPosTags (cast .getOpBox (), castExpr .position ().line (), castExpr .position ().line (), castExpr .position ().column () + castExpr .toString ().indexOf (')' ) , castExpr .position ().endColumn ());
2836
2868
soot .Local retLocal = lg .generateLocal (cast .getCastType ());
2837
-
2869
+ //System.out.println("cast ret type: "+retLocal.getType());
2838
2870
soot .jimple .Stmt castAssign = soot .jimple .Jimple .v ().newAssignStmt (retLocal , cast );
2839
2871
body .getUnits ().add (castAssign );
2840
2872
Util .addLnPosTags (castAssign , castExpr .position ());
0 commit comments