|
|
@ -117,8 +117,15 @@ public class ComplexExpression extends Expression { |
|
|
|
if (e.getOperator() instanceof LocalStoreOperator |
|
|
|
if (e.getOperator() instanceof LocalStoreOperator |
|
|
|
&& e.getOperandCount() == 0) { |
|
|
|
&& e.getOperandCount() == 0) { |
|
|
|
// Special case for locals created on inlining methods, which may
|
|
|
|
// Special case for locals created on inlining methods, which may
|
|
|
|
// combine everywhere
|
|
|
|
// combine everywhere, as long as there are no side effects.
|
|
|
|
return containsMatchingLoad(e) ? 1 : 0; |
|
|
|
|
|
|
|
|
|
|
|
for (int i=0; i < subExpressions.length; i++) { |
|
|
|
|
|
|
|
int result = subExpressions[i].canCombine(e); |
|
|
|
|
|
|
|
if (result != 0) |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
if (subExpressions[i].hasSideEffects(e)) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e instanceof ComplexExpression) { |
|
|
|
if (e instanceof ComplexExpression) { |
|
|
@ -216,18 +223,17 @@ public class ComplexExpression extends Expression { |
|
|
|
return subExpressions; |
|
|
|
return subExpressions; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// public void setSubExpressions(int i, Expression expr) {
|
|
|
|
public void setSubExpressions(int i, Expression expr) { |
|
|
|
// int diff = expr.getOperandCount()
|
|
|
|
int diff = expr.getOperandCount() |
|
|
|
// - subExpressions[i].getOperandCount();
|
|
|
|
- subExpressions[i].getOperandCount(); |
|
|
|
// subExpressions[i] = expr;
|
|
|
|
subExpressions[i] = expr; |
|
|
|
// for (ComplexExpression ce = this; ce != null;
|
|
|
|
for (ComplexExpression ce = this; ce != null; |
|
|
|
// ce = (ComplexExpression) ce.parent)
|
|
|
|
ce = (ComplexExpression) ce.parent) |
|
|
|
// ce.operandcount += diff;
|
|
|
|
ce.operandcount += diff; |
|
|
|
// updateType();
|
|
|
|
updateType(); |
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void updateSubTypes() { |
|
|
|
void updateSubTypes() { |
|
|
|
boolean changed = false; |
|
|
|
|
|
|
|
for (int i=0; i < subExpressions.length; i++) { |
|
|
|
for (int i=0; i < subExpressions.length; i++) { |
|
|
|
Type opType; |
|
|
|
Type opType; |
|
|
|
if (operator instanceof CheckNullOperator |
|
|
|
if (operator instanceof CheckNullOperator |
|
|
@ -240,21 +246,24 @@ public class ComplexExpression extends Expression { |
|
|
|
opType = operator.getOperandType(i); |
|
|
|
opType = operator.getOperandType(i); |
|
|
|
} else |
|
|
|
} else |
|
|
|
opType = Type.tSubType(operator.getOperandType(i)); |
|
|
|
opType = Type.tSubType(operator.getOperandType(i)); |
|
|
|
|
|
|
|
if (opType != Type.tError) { |
|
|
|
Type exprType = subExpressions[i].getType(); |
|
|
|
Type exprType = subExpressions[i].getType(); |
|
|
|
opType = opType.intersection(exprType); |
|
|
|
opType = opType.intersection(exprType); |
|
|
|
if (!opType.equals(exprType) && opType != Type.tError) { |
|
|
|
if (!opType.equals(exprType)) { |
|
|
|
if (Decompiler.isTypeDebugging) |
|
|
|
if (Decompiler.isTypeDebugging) |
|
|
|
Decompiler.err.println("change in "+this+": " |
|
|
|
Decompiler.err.println("change in "+this+": " |
|
|
|
+exprType |
|
|
|
+exprType+"->"+opType); |
|
|
|
+"->"+opType); |
|
|
|
if (opType == Type.tError) |
|
|
|
|
|
|
|
Decompiler.err.println("Type error in "+this+": " |
|
|
|
|
|
|
|
+exprType+"->" |
|
|
|
|
|
|
|
+operator.getOperandType(i)); |
|
|
|
subExpressions[i].setType(opType); |
|
|
|
subExpressions[i].setType(opType); |
|
|
|
changed = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateType() { |
|
|
|
public void updateType() { |
|
|
|
if (subExpressions.length > 0) { |
|
|
|
|
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
updateSubTypes(); |
|
|
|
updateSubTypes(); |
|
|
|
Type types[] = new Type[subExpressions.length]; |
|
|
|
Type types[] = new Type[subExpressions.length]; |
|
|
@ -271,21 +280,26 @@ public class ComplexExpression extends Expression { |
|
|
|
types[i] = Type.tSuperType |
|
|
|
types[i] = Type.tSuperType |
|
|
|
(subExpressions[i].getType()); |
|
|
|
(subExpressions[i].getType()); |
|
|
|
Type opType = operator.getOperandType(i); |
|
|
|
Type opType = operator.getOperandType(i); |
|
|
|
|
|
|
|
if (types[i] == Type.tError) |
|
|
|
|
|
|
|
continue; |
|
|
|
types[i] = types[i].intersection(opType); |
|
|
|
types[i] = types[i].intersection(opType); |
|
|
|
if (!types[i].equals(opType) |
|
|
|
if (types[i].equals(opType)) |
|
|
|
&& types[i] != Type.tError) { |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
if (Decompiler.isTypeDebugging) |
|
|
|
if (Decompiler.isTypeDebugging) |
|
|
|
Decompiler.err.println("change in "+this+": " |
|
|
|
Decompiler.err.println("change in "+this+" at "+i+": " |
|
|
|
+operator.getOperandType(i) |
|
|
|
+opType+"->"+types[i]); |
|
|
|
+"->"+types[i]); |
|
|
|
if (types[i] == Type.tError) |
|
|
|
|
|
|
|
Decompiler.err.println("Type error in "+this+" at "+i+": " |
|
|
|
|
|
|
|
+subExpressions[i].getType() |
|
|
|
|
|
|
|
+"->"+opType); |
|
|
|
|
|
|
|
else |
|
|
|
changed = true; |
|
|
|
changed = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!changed) |
|
|
|
if (!changed) |
|
|
|
break; |
|
|
|
break; |
|
|
|
operator.setOperandType(types); |
|
|
|
operator.setOperandType(types); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Type newType = type.intersection(operator.getType()); |
|
|
|
Type newType = type.intersection(operator.getType()); |
|
|
|
if (!newType.equals(type)) { |
|
|
|
if (!newType.equals(type)) { |
|
|
|
type = newType; |
|
|
|
type = newType; |
|
|
@ -344,6 +358,32 @@ public class ComplexExpression extends Expression { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* This method should remove local variables that are only written |
|
|
|
|
|
|
|
* and read one time directly after another. <br> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* In this case this is a non void LocalStoreOperator, whose local |
|
|
|
|
|
|
|
* isn't used in other places. |
|
|
|
|
|
|
|
* @return an expression where the locals are removed. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public Expression removeOnetimeLocals() { |
|
|
|
|
|
|
|
// System.err.println("removeOneTimeLocals: "+this);
|
|
|
|
|
|
|
|
if (operator instanceof LocalStoreOperator |
|
|
|
|
|
|
|
&& operator.getType() != Type.tVoid) { |
|
|
|
|
|
|
|
jode.decompiler.LocalInfo local = ((LocalStoreOperator)operator).getLocalInfo(); |
|
|
|
|
|
|
|
if ((local.getUseCount() == 2 /*XXX*/)) { |
|
|
|
|
|
|
|
/* remove LocalInfo somehow XXX */ |
|
|
|
|
|
|
|
return subExpressions[0].removeOnetimeLocals(); |
|
|
|
|
|
|
|
} // else
|
|
|
|
|
|
|
|
// System.err.println("Can't remove local "+local);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i=0; i< subExpressions.length; i++) { |
|
|
|
|
|
|
|
subExpressions[i] = subExpressions[i].removeOnetimeLocals(); |
|
|
|
|
|
|
|
subExpressions[i].parent = this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return this; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Expression simplifyStringBuffer() { |
|
|
|
public Expression simplifyStringBuffer() { |
|
|
|
if (operator instanceof InvokeOperator |
|
|
|
if (operator instanceof InvokeOperator |
|
|
|
&& (((InvokeOperator)operator).getClassType() |
|
|
|
&& (((InvokeOperator)operator).getClassType() |
|
|
@ -459,7 +499,8 @@ public class ComplexExpression extends Expression { |
|
|
|
operator.OPASSIGN_OP+operator.ADD_OP || |
|
|
|
operator.OPASSIGN_OP+operator.ADD_OP || |
|
|
|
operator.getOperatorIndex() == |
|
|
|
operator.getOperatorIndex() == |
|
|
|
operator.OPASSIGN_OP+operator.NEG_OP) && |
|
|
|
operator.OPASSIGN_OP+operator.NEG_OP) && |
|
|
|
(one.getValue().equals("1"))) { |
|
|
|
(one.getValue().equals("1") |
|
|
|
|
|
|
|
|| one.getValue().equals("1.0"))) { |
|
|
|
|
|
|
|
|
|
|
|
int op = (operator.getOperatorIndex() == |
|
|
|
int op = (operator.getOperatorIndex() == |
|
|
|
operator.OPASSIGN_OP+operator.ADD_OP) |
|
|
|
operator.OPASSIGN_OP+operator.ADD_OP) |
|
|
|