|
|
@ -28,14 +28,23 @@ public class CreateCheckNull { |
|
|
|
* |
|
|
|
* |
|
|
|
* javac: |
|
|
|
* javac: |
|
|
|
* DUP |
|
|
|
* DUP |
|
|
|
* stack_0.getClass(); |
|
|
|
* POP.getClass(); |
|
|
|
* |
|
|
|
* |
|
|
|
* jikes: |
|
|
|
* jikes: |
|
|
|
* DUP |
|
|
|
* DUP |
|
|
|
* if (!stack_0 != null) |
|
|
|
* if (!POP != null) |
|
|
|
* throw null; |
|
|
|
* throw null; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Transforms the code |
|
|
|
|
|
|
|
* <pre> |
|
|
|
|
|
|
|
* DUP |
|
|
|
|
|
|
|
* POP.getClass() |
|
|
|
|
|
|
|
* </pre> |
|
|
|
|
|
|
|
* to a CheckNullOperator. This is what javac generates when it |
|
|
|
|
|
|
|
* calls ".new" on an operand. |
|
|
|
|
|
|
|
*/ |
|
|
|
public static boolean transformJavac(InstructionContainer ic, |
|
|
|
public static boolean transformJavac(InstructionContainer ic, |
|
|
|
StructuredBlock last) { |
|
|
|
StructuredBlock last) { |
|
|
|
if (!(last.outer instanceof SequentialBlock) |
|
|
|
if (!(last.outer instanceof SequentialBlock) |
|
|
@ -67,6 +76,16 @@ public class CreateCheckNull { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Transforms the code |
|
|
|
|
|
|
|
* <pre> |
|
|
|
|
|
|
|
* DUP |
|
|
|
|
|
|
|
* if (POP == null) |
|
|
|
|
|
|
|
* throw null |
|
|
|
|
|
|
|
* </pre> |
|
|
|
|
|
|
|
* to a CheckNullOperator. This is what jikes generates when it |
|
|
|
|
|
|
|
* calls ".new" on an operand. |
|
|
|
|
|
|
|
*/ |
|
|
|
public static boolean transformJikes(IfThenElseBlock ifBlock, |
|
|
|
public static boolean transformJikes(IfThenElseBlock ifBlock, |
|
|
|
StructuredBlock last) { |
|
|
|
StructuredBlock last) { |
|
|
|
if (!(last.outer instanceof SequentialBlock) |
|
|
|
if (!(last.outer instanceof SequentialBlock) |
|
|
@ -80,12 +99,9 @@ public class CreateCheckNull { |
|
|
|
|| dup.count != 1 || dup.depth != 0) |
|
|
|
|| dup.count != 1 || dup.depth != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
/* negate the instruction back to its original state */ |
|
|
|
if (!(ifBlock.cond instanceof CompareUnaryOperator)) |
|
|
|
Expression expr = ifBlock.cond.negate(); |
|
|
|
|
|
|
|
if (!(expr instanceof CompareUnaryOperator)) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
CompareUnaryOperator cmpOp = (CompareUnaryOperator) ifBlock.cond; |
|
|
|
CompareUnaryOperator cmpOp = (CompareUnaryOperator) expr; |
|
|
|
|
|
|
|
if (cmpOp.getOperatorIndex() != Operator.NOTEQUALS_OP |
|
|
|
if (cmpOp.getOperatorIndex() != Operator.NOTEQUALS_OP |
|
|
|
|| !(cmpOp.getCompareType().isOfType(Type.tUObject))) |
|
|
|
|| !(cmpOp.getCompareType().isOfType(Type.tUObject))) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|