001/**
002 * www.jcoverage.com
003 * Copyright (C)2003 jcoverage ltd.
004 *
005 * This file is part of jcoverage.
006 *
007 * jcoverage is free software; you can redistribute it and/or modify
008 * it under the terms of the GNU General Public License as published
009 * by the Free Software Foundation; either version 2 of the License,
010 * or (at your option) any later version.
011 *
012 * jcoverage is distributed in the hope that it will be useful, but
013 * WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * General Public License for more details.
016 *
017 * You should have received a copy of the GNU General Public License
018 * along with jcoverage; if not, write to the Free Software
019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020 * USA
021 *
022 */
023package com.jcoverage.util;
024
025import org.apache.bcel.generic.IfInstruction;
026import org.apache.bcel.generic.InstructionHandle;
027import org.apache.bcel.generic.InvokeInstruction;
028import org.apache.bcel.generic.LineNumberGen;
029import org.apache.bcel.generic.RET;
030
031public class InstructionHelper {
032  public static boolean isInvokeInstruction(InstructionHandle handle) {
033    return handle.getInstruction() instanceof InvokeInstruction;
034  }
035
036  public static boolean isIfInstruction(LineNumberGen lng) {
037    return isIfInstruction(lng.getInstruction());
038  }
039
040  public static boolean isIfInstruction(InstructionHandle handle) {
041    return handle.getInstruction() instanceof IfInstruction;
042  }
043
044  public static boolean isRetInstruction(InstructionHandle instructionHandle) {
045    return instructionHandle.getInstruction() instanceof RET;
046  }
047
048  public static boolean isRetInstruction(LineNumberGen lineNumberGen) {
049    return isRetInstruction(lineNumberGen.getInstruction());
050  }
051}