|
|
@ -59,58 +59,47 @@ public abstract class Expression { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Checks if the given Expression (which should be a StoreInstruction) |
|
|
|
* Checks if the given Expression (which should be a CombineableOperator) |
|
|
|
* can be combined into this expression. |
|
|
|
* can be combined into this expression. |
|
|
|
* @param e The store expression, must be of type void. |
|
|
|
* @param e The store expression, must be of type void. |
|
|
|
* @return 1, if it can, 0, if no match was found and -1, if a |
|
|
|
* @return 1, if it can, 0, if no match was found and -1, if a |
|
|
|
* 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) { |
|
|
|
|
|
|
|
// jode.Decompiler.err.println("Try to combine "+e+" into "+this);
|
|
|
|
return containsMatchingLoad(e)? 1 : 0; |
|
|
|
return containsMatchingLoad(e)? 1 : 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Checks if this expression contains a load, that matches the |
|
|
|
* Checks if this expression contains a load, that matches the |
|
|
|
* given Expression (which should be a |
|
|
|
* given Expression (which should be a StoreInstruction/IIncOperator). |
|
|
|
* StoreInstruction/IIncOperator). |
|
|
|
|
|
|
|
* @param e The store expression. |
|
|
|
* @param e The store expression. |
|
|
|
* @return if this expression contains a matching load. |
|
|
|
* @return if this expression contains a matching load. |
|
|
|
|
|
|
|
* @exception ClassCastException, if e.getOperator |
|
|
|
|
|
|
|
* is not a CombineableOperator. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean containsMatchingLoad(Expression e) { |
|
|
|
public boolean containsMatchingLoad(Expression e) { |
|
|
|
if (e instanceof IIncOperator |
|
|
|
return ((CombineableOperator)e.getOperator()).matches(getOperator()); |
|
|
|
&& ((IIncOperator)e.getOperator()).matches(getOperator())) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
else if (e instanceof ComplexExpression |
|
|
|
|
|
|
|
&& e.getOperator() instanceof StoreInstruction |
|
|
|
|
|
|
|
&& ((StoreInstruction) e.getOperator()) |
|
|
|
|
|
|
|
.matches(getOperator())) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Combines the given Expression (which should be a StoreInstruction) |
|
|
|
* Combines the given Expression (which should be a StoreInstruction) |
|
|
|
* into this expression. You must only call this if |
|
|
|
* into this expression. You must only call this if |
|
|
|
* canCombine returns the value 1. |
|
|
|
* canCombine returns the value 1. |
|
|
|
* @param e The store expression. |
|
|
|
* @param e The store expression, |
|
|
|
|
|
|
|
* the operator must be a CombineableOperator. |
|
|
|
* @return The combined expression. |
|
|
|
* @return The combined expression. |
|
|
|
|
|
|
|
* @exception ClassCastException, if e.getOperator |
|
|
|
|
|
|
|
* is not a CombineableOperator. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Expression combine(Expression e) { |
|
|
|
public Expression combine(Expression e) { |
|
|
|
if (e.getOperator() instanceof IIncOperator) { |
|
|
|
CombineableOperator op = (CombineableOperator) e.getOperator(); |
|
|
|
if (((IIncOperator)e.getOperator()).matches(getOperator())) { |
|
|
|
if (op.matches(getOperator())) { |
|
|
|
((IIncOperator)e.getOperator()).makeNonVoid(); |
|
|
|
op.makeNonVoid(); |
|
|
|
/* Do not call setType, we don't want to intersect. */ |
|
|
|
|
|
|
|
e.type = e.getOperator().getType(); |
|
|
|
|
|
|
|
return e; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (((StoreInstruction)e.getOperator()).matches(getOperator())) { |
|
|
|
|
|
|
|
((StoreInstruction)e.getOperator()).makeNonVoid(); |
|
|
|
|
|
|
|
/* Do not call setType, we don't want to intersect. */ |
|
|
|
/* Do not call setType, we don't want to intersect. */ |
|
|
|
e.type = e.getOperator().getType(); |
|
|
|
e.type = e.getOperator().getType(); |
|
|
|
return e; |
|
|
|
return e; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|