*** empty log message ***

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@89 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 621ceac745
commit 719247eb04
  1. 35
      jode/jode/expr/Expression.java

@ -32,8 +32,12 @@ public abstract class Expression {
return type; return type;
} }
public Expression getParent() {
return parent;
}
public void setType(Type newType) { public void setType(Type newType) {
this.type = newType; type = type.intersection(newType);
} }
public void updateType() { public void updateType() {
@ -56,17 +60,19 @@ public abstract class Expression {
/** /**
* Checks if the given Expression (which should be a StoreInstruction) * Checks if the given Expression (which should be a StoreInstruction)
* can be combined into this expression. * can be combined into this expression.
* @param e The store expression. * @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) {
if (e instanceof ComplexExpression if (e instanceof IIncOperator
&& e.getOperator() instanceof StoreInstruction) { && ((IIncOperator)e.getOperator()).matches(getOperator()))
StoreInstruction store = (StoreInstruction) e.getOperator(); return 1;
if (store.matches(getOperator())) else if (e instanceof ComplexExpression
return 1; && e.getOperator() instanceof StoreInstruction
} && ((StoreInstruction) e.getOperator())
.matches(getOperator()))
return 1;
return 0; return 0;
} }
@ -78,11 +84,12 @@ public abstract class Expression {
* @return The combined expression. * @return The combined expression.
*/ */
public Expression combine(Expression e) { public Expression combine(Expression e) {
StoreInstruction store = (StoreInstruction) e.getOperator(); if (e.getOperator() instanceof IIncOperator)
((ComplexExpression)e).operator ((IIncOperator)e.getOperator()).makeNonVoid();
= new AssignOperator(store.getOperatorIndex(), store); else
((ComplexExpression)e).type ((StoreInstruction)e.getOperator()).makeNonVoid();
= this.type.intersection(store.getLValueType()); /* Do not call setType, we don't want to intersect. */
e.type = e.getOperator().getType();
return e; return e;
} }
@ -90,7 +97,7 @@ public abstract class Expression {
return this; return this;
} }
Expression simplifyStringBuffer() { public Expression simplifyStringBuffer() {
return null; return null;
} }

Loading…
Cancel
Save