/*
 * fb-contrib - Auxiliary detectors for Java programs
 * Copyright (C) 2005-2015 Kevin Lubick
 * Copyright (C) 2005-2015 Dave Brosius
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.mebigfatguy.fbcontrib.utils;

import static org.apache.bcel.Constants.ALOAD;
import static org.apache.bcel.Constants.ALOAD_0;
import static org.apache.bcel.Constants.ALOAD_3;
import static org.apache.bcel.Constants.ASTORE;
import static org.apache.bcel.Constants.ASTORE_0;
import static org.apache.bcel.Constants.ASTORE_3;
import static org.apache.bcel.Constants.INVOKEINTERFACE;
import static org.apache.bcel.Constants.INVOKESPECIAL;
import static org.apache.bcel.Constants.INVOKESTATIC;
import static org.apache.bcel.Constants.INVOKEVIRTUAL;

/**
 * a collection of static methods for categorizing opcodes into groups 
 */
public class OpcodeUtils {

	private OpcodeUtils(){}
	
	public static boolean isALoad(int seen) {
		return (seen == ALOAD) || ((seen >= ALOAD_0) && (seen <= ALOAD_3));
	}

	public static boolean isAStore(int seen) {
		return (seen == ASTORE) || ((seen >= ASTORE_0) && (seen <= ASTORE_3));
	}

	public static boolean isInvokeInterfaceSpecialStaticOrVirtual(int seen) {
		return (seen == INVOKESPECIAL) || (seen == INVOKEINTERFACE) || (seen == INVOKEVIRTUAL)	|| (seen == INVOKESTATIC);
	}
	
}

@@ -1433,16 +1433,77 @@
 RTUAL;%0A%0A
+import java.util.BitSet;%0A%0Aimport org.apache.bcel.Constants;%0A%0A
 /**%0A * a
@@ -1602,16 +1602,759 @@
 tils %7B%0A%0A
+%09private static final BitSet BRANCH_OPS = new BitSet();%0A%09static %7B%0A%09%09BRANCH_OPS.set(Constants.GOTO);%0A%09%09BRANCH_OPS.set(Constants.GOTO_W);%0A%09%09BRANCH_OPS.set(Constants.IF_ACMPEQ);%09%09%0A%09%09BRANCH_OPS.set(Constants.IF_ACMPNE);%09%09%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPEQ);%09%09%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPGE);%09%09%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPGT);%09%09%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPLE);%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPLT);%0A%09%09BRANCH_OPS.set(Constants.IF_ICMPNE);%0A%09%09BRANCH_OPS.set(Constants.IFEQ);%0A%09%09BRANCH_OPS.set(Constants.IFGE);%0A%09%09BRANCH_OPS.set(Constants.IFGT);%0A%09%09BRANCH_OPS.set(Constants.IFLE);%0A%09%09BRANCH_OPS.set(Constants.IFLT);%0A%09%09BRANCH_OPS.set(Constants.IFNE);%0A%09%09BRANCH_OPS.set(Constants.IFNONNULL);%0A%09%09BRANCH_OPS.set(Constants.IFNULL);%09%0A%09%7D%0A%09%0A
 %09private
@@ -2677,32 +2677,32 @@
 ual(int seen) %7B%0A
-
 %09%09return (seen =
@@ -2806,10 +2806,90 @@
 );%0A%09%7D%0A%09%0A
+%09public static boolean isBranch(int seen) %7B%0A%09%09return BRANCH_OPS.get(seen);%0A%09%7D%0A%09%0A
 %7D%0A

add isBranch