From 09f116e3baaae1676a9714bb2c2c9bab445a8595 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 7 May 1999 22:57:22 +0000 Subject: [PATCH] Simplified and better commented git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@798 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/flow/CreateCheckNull.java | 30 ++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/jode/jode/flow/CreateCheckNull.java b/jode/jode/flow/CreateCheckNull.java index 185f28e..97a0ba6 100644 --- a/jode/jode/flow/CreateCheckNull.java +++ b/jode/jode/flow/CreateCheckNull.java @@ -28,14 +28,23 @@ public class CreateCheckNull { * * javac: * DUP - * stack_0.getClass(); + * POP.getClass(); * * jikes: * DUP - * if (!stack_0 != null) + * if (!POP != null) * throw null; */ + /** + * Transforms the code + *
+     *   DUP
+     *   POP.getClass()
+     * 
+ * to a CheckNullOperator. This is what javac generates when it + * calls ".new" on an operand. + */ public static boolean transformJavac(InstructionContainer ic, StructuredBlock last) { if (!(last.outer instanceof SequentialBlock) @@ -67,6 +76,16 @@ public class CreateCheckNull { return true; } + /** + * Transforms the code + *
+     *   DUP
+     *   if (POP == null)
+     *       throw null
+     * 
+ * to a CheckNullOperator. This is what jikes generates when it + * calls ".new" on an operand. + */ public static boolean transformJikes(IfThenElseBlock ifBlock, StructuredBlock last) { if (!(last.outer instanceof SequentialBlock) @@ -80,12 +99,9 @@ public class CreateCheckNull { || dup.count != 1 || dup.depth != 0) return false; - /* negate the instruction back to its original state */ - Expression expr = ifBlock.cond.negate(); - if (!(expr instanceof CompareUnaryOperator)) + if (!(ifBlock.cond instanceof CompareUnaryOperator)) return false; - - CompareUnaryOperator cmpOp = (CompareUnaryOperator) expr; + CompareUnaryOperator cmpOp = (CompareUnaryOperator) ifBlock.cond; if (cmpOp.getOperatorIndex() != Operator.NOTEQUALS_OP || !(cmpOp.getCompareType().isOfType(Type.tUObject))) return false;