containsMatchingLoad added (for for blocks)

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@108 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent ba05fcd077
commit 230ad289d5
  1. 39
      jode/jode/expr/ComplexExpression.java
  2. 19
      jode/jode/expr/Expression.java

@ -78,10 +78,10 @@ public class ComplexExpression extends Expression {
*/
public int canCombine(Expression e) {
if (e instanceof ComplexExpression
&& e.getOperator() instanceof StoreInstruction) {
&& e.getOperator() instanceof StoreInstruction
&& ((StoreInstruction) e.getOperator()).matches(operator)) {
ComplexExpression ce = (ComplexExpression) e;
StoreInstruction store = (StoreInstruction) e.getOperator();
if (store.matches(operator)) {
for (int i=0; i < ce.subExpressions.length-1; i++) {
if (!ce.subExpressions[i].equals(subExpressions[i]))
return -1;
@ -89,13 +89,34 @@ public class ComplexExpression extends Expression {
return 1;
}
return subExpressions[0].canCombine(e);
// for (int i=0; i < subExpressions.length; i++) {
// int can = subExpressions[i].canCombine(e);
// if (can != 0)
// return can;
// }
}
return 0;
/**
* Checks if this expression contains a load, that matches the
* given Expression (which should be a
* StoreInstruction/IIncOperator).
* @param e The store expression.
* @return if this expression contains a matching load.
*/
public boolean containsMatchingLoad(Expression e) {
if (e instanceof ComplexExpression
&& e.getOperator() instanceof StoreInstruction
&& ((StoreInstruction) e.getOperator()).matches(operator)) {
ComplexExpression ce = (ComplexExpression) e;
int i;
for (i=0; i < ce.subExpressions.length-1; i++) {
if (!ce.subExpressions[i].equals(subExpressions[i]))
break;
}
if (i == ce.subExpressions.length-1)
return true;
}
for (int i=0; i < subExpressions.length; i++) {
if (subExpressions[i].containsMatchingLoad(e))
return true;
}
return false;
}
/**

@ -65,17 +65,26 @@ public abstract class Expression {
* conflict was found. You may wish to check for >0.
*/
public int canCombine(Expression e) {
if (!e.isVoid())
return 0;
return containsMatchingLoad(e)? 1 : 0;
}
/**
* Checks if this expression contains a load, that matches the
* given Expression (which should be a
* StoreInstruction/IIncOperator).
* @param e The store expression.
* @return if this expression contains a matching load.
*/
public boolean containsMatchingLoad(Expression e) {
if (e instanceof IIncOperator
&& ((IIncOperator)e.getOperator()).matches(getOperator()))
return 1;
return true;
else if (e instanceof ComplexExpression
&& e.getOperator() instanceof StoreInstruction
&& ((StoreInstruction) e.getOperator())
.matches(getOperator()))
return 1;
return 0;
return true;
return false;
}
/**

Loading…
Cancel
Save