|
|
@ -80,24 +80,12 @@ public class VariableStack { |
|
|
|
public Expression mergeIntoExpression(Expression expr, VariableSet used) { |
|
|
|
public Expression mergeIntoExpression(Expression expr, VariableSet used) { |
|
|
|
/* assert expr.getOperandCount() == stackMap.length */ |
|
|
|
/* assert expr.getOperandCount() == stackMap.length */ |
|
|
|
|
|
|
|
|
|
|
|
ComplexExpression parent = null; |
|
|
|
for (int i = stackMap.length-1; i >= 0; i--) { |
|
|
|
Expression inner = expr; |
|
|
|
|
|
|
|
while (inner instanceof ComplexExpression) { |
|
|
|
|
|
|
|
parent = (ComplexExpression)inner; |
|
|
|
|
|
|
|
inner = parent.getSubExpressions()[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Expression[] loads = new Expression[stackMap.length]; |
|
|
|
|
|
|
|
for (int i=0; i< stackMap.length; i++) { |
|
|
|
|
|
|
|
if (!used.contains(stackMap[i])) |
|
|
|
if (!used.contains(stackMap[i])) |
|
|
|
used.addElement(stackMap[i]); |
|
|
|
used.addElement(stackMap[i]); |
|
|
|
loads[i] = new LocalLoadOperator(stackMap[i].getType(), |
|
|
|
expr = expr.addOperand |
|
|
|
stackMap[i]); |
|
|
|
(new LocalLoadOperator(stackMap[i].getType(), stackMap[i])); |
|
|
|
} |
|
|
|
} |
|
|
|
Expression newExpr = new ComplexExpression((Operator)inner, loads); |
|
|
|
|
|
|
|
if (parent != null) |
|
|
|
|
|
|
|
parent.setSubExpressions(0, newExpr); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
expr = newExpr; |
|
|
|
|
|
|
|
return expr; |
|
|
|
return expr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -153,4 +141,14 @@ public class VariableStack { |
|
|
|
} else |
|
|
|
} else |
|
|
|
throw new jode.AssertError("Unknown SpecialBlock"); |
|
|
|
throw new jode.AssertError("Unknown SpecialBlock"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
StringBuffer result = new StringBuffer("["); |
|
|
|
|
|
|
|
for (int i=0; i < stackMap.length; i++) { |
|
|
|
|
|
|
|
if (i>0) |
|
|
|
|
|
|
|
result.append(", "); |
|
|
|
|
|
|
|
result.append(stackMap[i].getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.append("]").toString(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|