|
|
|
@ -40,7 +40,6 @@ public class CreateExpression { |
|
|
|
|
*/ |
|
|
|
|
public static boolean transform(InstructionContainer ic, |
|
|
|
|
StructuredBlock last) { |
|
|
|
|
|
|
|
|
|
int params = ic.getInstruction().getOperandCount(); |
|
|
|
|
if (params == 0) |
|
|
|
|
return false; |
|
|
|
@ -66,6 +65,17 @@ public class CreateExpression { |
|
|
|
|
Expression lastExpression = null; |
|
|
|
|
for (int i = params;;) { |
|
|
|
|
|
|
|
|
|
if (i >= 2 && sequBlock.subBlocks[0] instanceof SpecialBlock) { |
|
|
|
|
/* Transform (this is for string += under jikes) |
|
|
|
|
* PUSH arg2 |
|
|
|
|
* PUSH arg1 |
|
|
|
|
* SWAP |
|
|
|
|
*/ |
|
|
|
|
SpecialBlock swap = (SpecialBlock) sequBlock.subBlocks[0]; |
|
|
|
|
if (swap.type != SpecialBlock.SWAP) |
|
|
|
|
return false; |
|
|
|
|
/* XXX check if swapping is possible */ |
|
|
|
|
} else { |
|
|
|
|
if (!(sequBlock.subBlocks[0] instanceof InstructionBlock)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
@ -87,7 +97,7 @@ public class CreateExpression { |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
lastExpression = expr; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (!(sequBlock.outer instanceof SequentialBlock)) |
|
|
|
|
return false; |
|
|
|
|
sequBlock = (SequentialBlock) sequBlock.outer; |
|
|
|
@ -97,17 +107,38 @@ public class CreateExpression { |
|
|
|
|
*/ |
|
|
|
|
Expression[] exprs = new Expression[params]; |
|
|
|
|
sequBlock = (SequentialBlock) last.outer; |
|
|
|
|
int swapping = 0; |
|
|
|
|
for (int i=params; ;) { |
|
|
|
|
|
|
|
|
|
if (sequBlock.subBlocks[0] instanceof SpecialBlock) { |
|
|
|
|
// This must be a swap (see above).
|
|
|
|
|
swapping = 1; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
Expression expr = |
|
|
|
|
((InstructionBlock) sequBlock.subBlocks[0]).getInstruction(); |
|
|
|
|
|
|
|
|
|
if (!expr.isVoid()) { |
|
|
|
|
if (swapping == 1) { |
|
|
|
|
// We start swapping:
|
|
|
|
|
i--; |
|
|
|
|
swapping = 2; |
|
|
|
|
} else if (swapping == 2) { |
|
|
|
|
// We continue swapping:
|
|
|
|
|
i += 2; |
|
|
|
|
swapping = 3; |
|
|
|
|
} else if (swapping == 3) { |
|
|
|
|
// Now we end swapping:
|
|
|
|
|
i--; |
|
|
|
|
swapping = 0; |
|
|
|
|
} |
|
|
|
|
exprs[--i] = expr; |
|
|
|
|
if (i == 0) |
|
|
|
|
if (i == 0 && swapping == 0 |
|
|
|
|
|| i == 1 && swapping == 3) |
|
|
|
|
break; |
|
|
|
|
} else |
|
|
|
|
exprs[i] = exprs[i].combine(expr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sequBlock = (SequentialBlock)sequBlock.outer; |
|
|
|
|
} |
|
|
|
|