[Fb-contrib-commit] SF.net SVN: fb-contrib: [942] trunk/fb-contrib
Brought to you by:
dbrosius
From: <dbr...@us...> - 2007-10-31 05:17:02
|
Revision: 942 http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=942&view=rev Author: dbrosius Date: 2007-10-30 22:16:52 -0700 (Tue, 30 Oct 2007) Log Message: ----------- don't report useless trinaries when the ifeq is on something other than a boolean Modified Paths: -------------- trunk/fb-contrib/samples/SPP_Sample.java trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java Modified: trunk/fb-contrib/samples/SPP_Sample.java =================================================================== --- trunk/fb-contrib/samples/SPP_Sample.java 2007-10-18 05:38:45 UTC (rev 941) +++ trunk/fb-contrib/samples/SPP_Sample.java 2007-10-31 05:16:52 UTC (rev 942) @@ -91,4 +91,9 @@ return a && b; } + + public boolean testFPTrinaryOnInt(String s) + { + return (s.length() != 0); + } } Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java =================================================================== --- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-18 05:38:45 UTC (rev 941) +++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/SillynessPotPourri.java 2007-10-31 05:16:52 UTC (rev 942) @@ -47,6 +47,7 @@ private int lastPCs[]; private int lastOpcode; private int lastReg; + private boolean lastIfEqWasBoolean; /** branch targets, to a set of branch instructions */ private Map<Integer, Set<Integer>> branchTargets; @@ -82,6 +83,7 @@ stack.resetForMethodEntry(this); lastOpcode = -1; lastReg = -1; + lastIfEqWasBoolean = false; Arrays.fill(lastPCs, -1); branchTargets.clear(); super.visitCode(obj); @@ -110,8 +112,12 @@ branchInsSet.add(Integer.valueOf(getPC())); } - - if (seen == IRETURN) { + if (seen == IFEQ) { + if (stack.getStackDepth() > 0) { + OpcodeStack.Item itm = stack.getStackItem(0); + lastIfEqWasBoolean = "Z".equals(itm.getElementSignature()); + } + } else if ((seen == IRETURN) && lastIfEqWasBoolean) { byte[] bytes = getCode().getCode(); if ((lastPCs[0] != -1) && ((0x00FF & bytes[lastPCs[3]]) == ICONST_0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |