Fixes for jikes +=

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@202 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 8fab80629c
commit 5c20b9600f
  1. 25
      jode/jode/flow/CreateAssignExpression.java

@ -50,8 +50,7 @@ public class CreateAssignExpression {
* rightHandSide * rightHandSide
* store(stack) *= (stack) * store(stack) *= (stack)
* *
* If the optional dup is present the store*= becomes non void. * If the optional dup is present the store*= becomes non void. */
*/
SequentialBlock opBlock = (SequentialBlock) last.outer; SequentialBlock opBlock = (SequentialBlock) last.outer;
StoreInstruction store = (StoreInstruction) ic.getInstruction(); StoreInstruction store = (StoreInstruction) ic.getInstruction();
@ -73,20 +72,19 @@ public class CreateAssignExpression {
InstructionBlock ib = (InstructionBlock) opBlock.subBlocks[0]; InstructionBlock ib = (InstructionBlock) opBlock.subBlocks[0];
if (!(opBlock.outer instanceof SequentialBlock) if (!(opBlock.outer instanceof SequentialBlock)
|| !(opBlock.outer.getSubBlocks()[0] instanceof SpecialBlock)) || !(opBlock.outer.getSubBlocks()[0] instanceof SpecialBlock)
|| !(ib.getInstruction() instanceof ComplexExpression))
return false; return false;
SequentialBlock sequBlock = (SequentialBlock) opBlock.outer; SequentialBlock sequBlock = (SequentialBlock) opBlock.outer;
ComplexExpression expr = (ComplexExpression) ib.getInstruction();
SpecialBlock dup = (SpecialBlock) sequBlock.subBlocks[0]; SpecialBlock dup = (SpecialBlock) sequBlock.subBlocks[0];
if (dup.type != SpecialBlock.DUP if (dup.type != SpecialBlock.DUP
|| dup.depth != 0 || dup.depth != 0
|| dup.count != store.getLValueOperandCount()) || dup.count != store.getLValueOperandCount())
return false; return false;
if (!(ib.getInstruction() instanceof ComplexExpression))
return false;
ComplexExpression expr = (ComplexExpression) ib.getInstruction();
int opIndex; int opIndex;
Expression rightHandSide; Expression rightHandSide;
@ -108,6 +106,12 @@ public class CreateAssignExpression {
rightHandSide = expr.getSubExpressions()[1]; rightHandSide = expr.getSubExpressions()[1];
} else { } else {
/* For String += the situation is more complex.
* what is marked as load(stack) * rightHandSide above is
* really (after simplification):
*
* PUSH ((load(stack) + right) + Hand) + Side
*/
Expression simple = expr.simplifyString(); Expression simple = expr.simplifyString();
rightHandSide = simple; rightHandSide = simple;
/* Now search for the leftmost operand ... */ /* Now search for the leftmost operand ... */
@ -125,13 +129,16 @@ public class CreateAssignExpression {
/* ... and remove it. */ /* ... and remove it. */
if (lastExpr.getParent() != null) { if (lastExpr.getParent() != null) {
((ComplexExpression)lastExpr.getParent()) ComplexExpression ce = (ComplexExpression)lastExpr.getParent();
.setSubExpressions(0,lastExpr.getSubExpressions()[1]); StringAddOperator addOp = (StringAddOperator) ce.getOperator();
addOp.clearFirstType();
ce.setSubExpressions(0,lastExpr.getSubExpressions()[1]);
} else } else
rightHandSide = lastExpr.getSubExpressions()[1]; rightHandSide = lastExpr.getSubExpressions()[1];
opIndex = Operator.ADD_OP; opIndex = Operator.ADD_OP;
} }
dup.removeBlock(); dup.removeBlock();
ib.setInstruction(rightHandSide); ib.setInstruction(rightHandSide);

Loading…
Cancel
Save