[Fb-contrib-commit] SF.net SVN: fb-contrib:[1471] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-01-11 04:06:53
|
Revision: 1471
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1471&view=rev
Author: dbrosius
Date: 2010-01-11 04:06:45 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
now using 1.5 --> use enums
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java 2010-01-11 03:52:17 UTC (rev 1470)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/InheritanceTypeChecking.java 2010-01-11 04:06:45 UTC (rev 1471)
@@ -87,10 +87,10 @@
boolean processed = false;
Iterator<IfStatement> isi = ifStatements.iterator();
while (isi.hasNext()) {
- int action = isi.next().processOpcode(this, bugReporter, seen);
- if (action == IfStatement.REMOVE_ACTION)
+ IfStatement.Action action = isi.next().processOpcode(this, bugReporter, seen);
+ if (action == IfStatement.Action.REMOVE_ACTION)
isi.remove();
- else if (action == IfStatement.PROCESSED_ACTION)
+ else if (action == IfStatement.Action.PROCESSED_ACTION)
processed = true;
}
@@ -104,15 +104,10 @@
}
private static class IfStatement {
- public static final int NO_ACTION = 0;
- public static final int REMOVE_ACTION = 1;
- public static final int PROCESSED_ACTION = 2;
-
- private final static int SEEN_ALOAD = 1;
- private final static int SEEN_INSTANCEOF = 2;
- private final static int SEEN_IFEQ = 3;
+ enum Action {NO_ACTION, REMOVE_ACTION, PROCESSED_ACTION}
+ enum State {SEEN_ALOAD, SEEN_INSTANCEOF, SEEN_IFEQ}
- private int state;
+ private State state;
private int reg;
private int firstPC;
private int branchTarget;
@@ -120,30 +115,30 @@
private Set<String> instanceOfTypes;
public IfStatement(BytecodeScanningDetector bsd, int seen) {
- state = SEEN_ALOAD;
+ state = State.SEEN_ALOAD;
reg = RegisterUtils.getALoadReg(bsd, seen);
matchCount = 0;
firstPC = bsd.getPC();
}
- public int processOpcode(BytecodeScanningDetector bsd, BugReporter bugReporter, int seen) {
+ public IfStatement.Action processOpcode(BytecodeScanningDetector bsd, BugReporter bugReporter, int seen) {
switch (state) {
case SEEN_ALOAD:
if (seen == INSTANCEOF) {
if (instanceOfTypes == null)
instanceOfTypes = new HashSet<String>();
instanceOfTypes.add(bsd.getClassConstantOperand());
- state = SEEN_INSTANCEOF;
- return PROCESSED_ACTION;
+ state = State.SEEN_INSTANCEOF;
+ return IfStatement.Action.PROCESSED_ACTION;
}
break;
case SEEN_INSTANCEOF:
if (seen == IFEQ) {
branchTarget = bsd.getBranchTarget();
- state = SEEN_IFEQ;
+ state = State.SEEN_IFEQ;
matchCount++;
- return PROCESSED_ACTION;
+ return IfStatement.Action.PROCESSED_ACTION;
}
break;
@@ -152,8 +147,8 @@
if ((seen == ALOAD)
|| ((seen >= ALOAD_0) && (seen <= ALOAD_3))) {
if (reg == RegisterUtils.getALoadReg(bsd, seen)) {
- state = SEEN_ALOAD;
- return PROCESSED_ACTION;
+ state = State.SEEN_ALOAD;
+ return IfStatement.Action.PROCESSED_ACTION;
}
}
if (matchCount > 1) {
@@ -170,13 +165,13 @@
.addClass(bsd)
.addMethod(bsd)
.addSourceLine(bsd, firstPC));
- return REMOVE_ACTION;
+ return IfStatement.Action.REMOVE_ACTION;
}
}
- return NO_ACTION;
+ return IfStatement.Action.NO_ACTION;
}
- return REMOVE_ACTION;
+ return IfStatement.Action.REMOVE_ACTION;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|