[Fb-contrib-commit] fb-contrib/src/com/mebigfatguy/fbcontrib/detect JDBCVendorReliance.java,1.6,1.7
Brought to you by:
dbrosius
From: Dave B. <dbr...@us...> - 2006-03-13 06:02:15
|
Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12759/src/com/mebigfatguy/fbcontrib/detect Modified Files: JDBCVendorReliance.java LocalSynchronizedCollection.java Log Message: more getLocalVariableEndRange to registerutils Index: JDBCVendorReliance.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/JDBCVendorReliance.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- JDBCVendorReliance.java 13 Mar 2006 05:57:54 -0000 1.6 +++ JDBCVendorReliance.java 13 Mar 2006 06:02:11 -0000 1.7 @@ -60,7 +60,7 @@ for (Type arg : argTypes) { String sig = arg.getSignature(); if (isJDBCClass(sig)) - jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, 0))); + jdbcLocals.put(new Integer(reg), new Integer(RegisterUtils.getLocalVariableEndRange(obj.getLocalVariableTable(), reg, 0))); reg += (sig.equals("J") || sig.equals("D")) ? 2 : 1; } @@ -112,7 +112,7 @@ OpcodeStack.Item itm = stack.getStackItem(0); if (itm.getUserValue() != null) { int reg = RegisterUtils.getAStoreReg(this, seen); - jdbcLocals.put(new Integer(reg), new Integer(getLocalVariableEndRange(reg, getNextPC()))); + jdbcLocals.put(new Integer(reg), new Integer(RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC()))); } } @@ -131,25 +131,7 @@ } } } - - /** - * returns the end pc of the visible range of this register at this pc - * - * @param reg the register to examine - * @param curPC the pc of the current instruction - * @return the endpc - */ - private int getLocalVariableEndRange(int reg, int curPC) { - int endRange = Integer.MAX_VALUE; - LocalVariableTable lvt = this.getMethod().getLocalVariableTable(); - if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, curPC); - if (lv != null) - endRange = lv.getStartPC() + lv.getLength(); - } - return endRange; - } - + /** * returns whether the class is a jdbc class * Index: LocalSynchronizedCollection.java =================================================================== RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/LocalSynchronizedCollection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- LocalSynchronizedCollection.java 13 Mar 2006 05:57:54 -0000 1.8 +++ LocalSynchronizedCollection.java 13 Mar 2006 06:02:11 -0000 1.9 @@ -94,7 +94,7 @@ int curReg = obj.isStatic() ? 0 : 1; for (Type t : argTypes) { sig = t.getSignature(); - syncRegs.put(new Integer(curReg), new CollectionRegInfo(getLocalVariableEndRange(curReg, 0))); + syncRegs.put(new Integer(curReg), new CollectionRegInfo(RegisterUtils.getLocalVariableEndRange(obj.getLocalVariableTable(), curReg, 0))); if ("J".equals(sig) || "D".equals(sig)) { curReg++; } @@ -168,14 +168,14 @@ int reg = RegisterUtils.getAStoreReg(this, seen); if (item.getUserValue() != null) { if (!syncRegs.containsKey(new Integer(reg))) { - CollectionRegInfo cri = new CollectionRegInfo(SourceLineAnnotation.fromVisitedInstruction(this), getLocalVariableEndRange(reg, getNextPC())); + CollectionRegInfo cri = new CollectionRegInfo(SourceLineAnnotation.fromVisitedInstruction(this), RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC())); syncRegs.put(new Integer(reg), cri); } } else { CollectionRegInfo cri = syncRegs.get(new Integer(reg)); if (cri == null) { - cri = new CollectionRegInfo(getLocalVariableEndRange(reg, getNextPC())); + cri = new CollectionRegInfo(RegisterUtils.getLocalVariableEndRange(getMethod().getLocalVariableTable(), reg, getNextPC())); syncRegs.put(new Integer(reg), cri); } cri.setIgnore(); @@ -228,25 +228,7 @@ } } } - - /** - * returns the end pc of the visible range of this register at this pc - * - * @param reg the register to examine - * @param curPC the pc of the current instruction - * @return the endpc - */ - private int getLocalVariableEndRange(int reg, int curPC) { - int endRange = Integer.MAX_VALUE; - LocalVariableTable lvt = this.getMethod().getLocalVariableTable(); - if (lvt != null) { - LocalVariable lv = lvt.getLocalVariable(reg, curPC); - if (lv != null) - endRange = lv.getStartPC() + lv.getLength(); - } - return endRange; - } - + static class CollectionRegInfo { private SourceLineAnnotation slAnnotation; |