1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 package org.apache.bcel.verifier.structurals; 19 20 21 import org.apache.bcel.generic.InstructionHandle; 22 23 /** 24 * This interface defines properties of JVM bytecode subroutines. 25 * Note that it is 'abused' to maintain the top-level code in a 26 * consistent fashion, too. 27 * 28 * @version $Id$ 29 */ 30 public interface Subroutine{ 31 /** 32 * Returns all the JsrInstructions that have the 33 * first instruction of this subroutine as their target. 34 * <B>Must not be invoked on the 'top-level subroutine'.</B> 35 */ getEnteringJsrInstructions()36 InstructionHandle[] getEnteringJsrInstructions(); 37 38 /** 39 * Returns the one and only RET that leaves the subroutine. 40 * Note that JustIce has a pretty rigid notion of a subroutine. 41 * <B>Must not be invoked on the 'top-level subroutine'.</B> 42 * 43 * @see Subroutines 44 */ getLeavingRET()45 InstructionHandle getLeavingRET(); 46 47 /** 48 * Returns all instructions that together form this subroutine. 49 * Note that an instruction is part of exactly one subroutine 50 * (the top-level code is considered to be a special subroutine) - 51 * else it is not reachable at all (dead code). 52 */ getInstructions()53 InstructionHandle[] getInstructions(); 54 55 /** 56 * Returns if the given InstructionHandle refers to an instruction 57 * that is part of this subroutine. This is a convenience method 58 * that saves iteration over the InstructionHandle objects returned 59 * by getInstructions(). 60 * 61 * @see #getInstructions() 62 */ contains(InstructionHandle inst)63 boolean contains(InstructionHandle inst); 64 65 /** 66 * Returns an int[] containing the indices of the local variable slots 67 * accessed by this Subroutine (read-accessed, write-accessed or both); 68 * local variables referenced by subroutines of this subroutine are 69 * not included. 70 * 71 * @see #getRecursivelyAccessedLocalsIndices() 72 */ getAccessedLocalsIndices()73 int[] getAccessedLocalsIndices(); 74 75 /** 76 * Returns an int[] containing the indices of the local variable slots 77 * accessed by this Subroutine (read-accessed, write-accessed or both); 78 * local variables referenced by subroutines of this subroutine are 79 * included. 80 * 81 * @see #getAccessedLocalsIndices() 82 */ getRecursivelyAccessedLocalsIndices()83 int[] getRecursivelyAccessedLocalsIndices(); 84 85 /** 86 * Returns the subroutines that are directly called from this subroutine. 87 */ subSubs()88 Subroutine[] subSubs(); 89 } 90