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. 55
      jode/jode/expr/ComplexExpression.java
  2. 19
      jode/jode/expr/Expression.java

@ -78,24 +78,45 @@ public class ComplexExpression extends Expression {
*/ */
public int canCombine(Expression e) { public int canCombine(Expression e) {
if (e instanceof ComplexExpression if (e instanceof ComplexExpression
&& e.getOperator() instanceof StoreInstruction) { && e.getOperator() instanceof StoreInstruction
&& ((StoreInstruction) e.getOperator()).matches(operator)) {
ComplexExpression ce = (ComplexExpression) e;
for (int i=0; i < ce.subExpressions.length-1; i++) {
if (!ce.subExpressions[i].equals(subExpressions[i]))
return -1;
}
return 1;
}
return subExpressions[0].canCombine(e);
}
/**
* 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; ComplexExpression ce = (ComplexExpression) e;
StoreInstruction store = (StoreInstruction) e.getOperator(); int i;
if (store.matches(operator)) { for (i=0; i < ce.subExpressions.length-1; i++) {
for (int i=0; i < ce.subExpressions.length-1; i++) { if (!ce.subExpressions[i].equals(subExpressions[i]))
if (!ce.subExpressions[i].equals(subExpressions[i])) break;
return -1; }
} if (i == ce.subExpressions.length-1)
return 1; return true;
} }
return subExpressions[0].canCombine(e); for (int i=0; i < subExpressions.length; i++) {
// for (int i=0; i < subExpressions.length; i++) { if (subExpressions[i].containsMatchingLoad(e))
// int can = subExpressions[i].canCombine(e); return true;
// if (can != 0) }
// return can; return false;
// }
}
return 0;
} }
/** /**

@ -65,17 +65,26 @@ public abstract class Expression {
* conflict was found. You may wish to check for >0. * conflict was found. You may wish to check for >0.
*/ */
public int canCombine(Expression e) { public int canCombine(Expression e) {
if (!e.isVoid()) return containsMatchingLoad(e)? 1 : 0;
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 IIncOperator if (e instanceof IIncOperator
&& ((IIncOperator)e.getOperator()).matches(getOperator())) && ((IIncOperator)e.getOperator()).matches(getOperator()))
return 1; return true;
else if (e instanceof ComplexExpression else if (e instanceof ComplexExpression
&& e.getOperator() instanceof StoreInstruction && e.getOperator() instanceof StoreInstruction
&& ((StoreInstruction) e.getOperator()) && ((StoreInstruction) e.getOperator())
.matches(getOperator())) .matches(getOperator()))
return 1; return true;
return 0; return false;
} }
/** /**

Loading…
Cancel
Save