[Fb-contrib-commit] SF.net SVN: fb-contrib:[1520] trunk/fb-contrib/src/com/mebigfatguy/ fbcontrib/
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2010-03-13 20:52:44
|
Revision: 1520
http://fb-contrib.svn.sourceforge.net/fb-contrib/?rev=1520&view=rev
Author: dbrosius
Date: 2010-03-13 20:52:37 +0000 (Sat, 13 Mar 2010)
Log Message:
-----------
add static methods to PRMC
Modified Paths:
--------------
trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
Modified: trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java
===================================================================
--- trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 20:14:27 UTC (rev 1519)
+++ trunk/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/PossiblyRedundantMethodCalls.java 2010-03-13 20:52:37 UTC (rev 1520)
@@ -111,6 +111,7 @@
private OpcodeStack stack = null;
private Map<Integer, MethodCall> localMethodCalls = null;
private Map<String, MethodCall> fieldMethodCalls = null;
+ private Map<String, MethodCall> staticMethodCalls = null;
private Set<Integer> branchTargets = null;
/**
@@ -132,12 +133,14 @@
stack = new OpcodeStack();
localMethodCalls = new HashMap<Integer, MethodCall>();
fieldMethodCalls = new HashMap<String, MethodCall>();
+ staticMethodCalls = new HashMap<String, MethodCall>();
branchTargets = new HashSet<Integer>();
super.visitClassContext(classContext);
} finally {
stack = null;
localMethodCalls = null;
fieldMethodCalls = null;
+ staticMethodCalls = null;
branchTargets = null;
}
}
@@ -187,12 +190,13 @@
localMethodCalls.remove(Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)));
} else if (seen == PUTFIELD) {
fieldMethodCalls.remove(getNameConstantOperand());
- } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE)) {
+ } else if ((seen == INVOKEVIRTUAL) || (seen == INVOKEINTERFACE) || (seen == INVOKESTATIC)) {
String className = getClassConstantOperand();
String methodName = getNameConstantOperand();
String signature = getSigConstantOperand();
int parmCount = Type.getArgumentTypes(signature).length;
- if (stack.getStackDepth() > parmCount) {
+ int neededStackSize = parmCount - ((seen == INVOKESTATIC) ? 1 : 0);
+ if (stack.getStackDepth() > neededStackSize) {
Object[] parmConstants = new Object[parmCount];
for (int i = 0; i < parmCount; i++) {
OpcodeStack.Item parm = stack.getStackItem(i);
@@ -200,18 +204,28 @@
if (parmConstants[i] == null)
return;
}
- OpcodeStack.Item obj = stack.getStackItem(parmCount);
- int reg = obj.getRegisterNumber();
- XField field = obj.getXField();
+
MethodCall mc;
- if (reg >= 0) {
- mc = localMethodCalls.get(Integer.valueOf(reg));
- } else if (field != null) {
- mc = fieldMethodCalls.get(field.getName());
- } else
- return;
+ int reg = -1;
+ XField field = null;
+ if (seen == INVOKESTATIC) {
+ mc = staticMethodCalls.get(className);
+ } else {
+ OpcodeStack.Item obj = stack.getStackItem(parmCount);
+ reg = obj.getRegisterNumber();
+ field = obj.getXField();
+
+
+ if (reg >= 0) {
+ mc = localMethodCalls.get(Integer.valueOf(reg));
+ } else if (field != null) {
+ mc = fieldMethodCalls.get(field.getName());
+ } else
+ return;
+ }
+
if (mc != null) {
if (!signature.endsWith("V") && methodName.equals(mc.getName()) && signature.equals(mc.getSignature()) && !isRiskyName(className, methodName)) {
Object[] parms = mc.getParms();
@@ -233,16 +247,25 @@
.addString(methodName + signature));
}
}
- if (reg >= 0) {
- localMethodCalls.remove(Integer.valueOf(reg));
+
+ if (seen == INVOKESTATIC) {
+ staticMethodCalls.remove(className);
} else {
- fieldMethodCalls.remove(field.getName());
+ if (reg >= 0) {
+ localMethodCalls.remove(Integer.valueOf(reg));
+ } else {
+ fieldMethodCalls.remove(field.getName());
+ }
}
} else {
- if (reg >= 0) {
- localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants));
- } else if (field != null) {
- fieldMethodCalls.put(field.getName(), new MethodCall(methodName, signature, parmConstants));
+ if (seen == INVOKESTATIC) {
+ staticMethodCalls.put(className, new MethodCall(methodName, signature, parmConstants));
+ } else {
+ if (reg >= 0) {
+ localMethodCalls.put(Integer.valueOf(reg), new MethodCall(methodName, signature, parmConstants));
+ } else if (field != null) {
+ fieldMethodCalls.put(field.getName(), new MethodCall(methodName, signature, parmConstants));
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|