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 package org.apache.commons.javaflow.bytecode.transformation.bcel.analyser;
18
19 import java.util.ArrayList;
20
21 import org.apache.bcel.generic.InstructionHandle;
22
23 /**
24 * An InstructionContext offers convenient access
25 * to information like control flow successors and
26 * such.
27 *
28 * @version $Id: InstructionContext.java 480487 2006-11-29 08:54:42Z bayard $
29 * @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
30 */
31 public interface InstructionContext{
32
33 /**
34 * This method symbolically executes the Instruction
35 * held in the InstructionContext.
36 * It "merges in" the incoming execution frame situation
37 * (see The Java Virtual Machine Specification, 2nd
38 * edition, page 146).
39 * By so doing, the outgoing execution frame situation
40 * is calculated.
41 *
42 * This method is JustIce-specific and is usually of
43 * no sense for users of the ControlFlowGraph class.
44 * They should use getInstruction().accept(Visitor),
45 * possibly in conjunction with the ExecutionVisitor.
46 *
47 * WARNING! These classes are a fork of the bcel verifier.
48 *
49 * @see ControlFlowGraph
50 * @see ExecutionVisitor
51 * @see #getOutFrame(ArrayList)
52 * @return true - if and only if the "outgoing" frame situation
53 * changed from the one before execute()ing.
54 */
55 boolean execute(Frame inFrame, ExecutionPath executionPredecessors, ExecutionVisitor ev);
56
57 Frame getInFrame();
58
59 /**
60 * This method returns the outgoing execution frame situation;
61 * therefore <B>it has to be calculated by execute(Frame, ArrayList)
62 * first.</B>
63 *
64 * @see #execute(Frame, ExecutionPath, ExecutionVisitor)
65 */
66 Frame getOutFrame(ExecutionPath executionPredecessors);
67
68 /**
69 * Returns the InstructionHandle this InstructionContext is wrapped around.
70 *
71 * @return The InstructionHandle this InstructionContext is wrapped around.
72 */
73 InstructionHandle getInstruction();
74
75 /**
76 * Returns the usual control flow successors.
77 * @see #getExceptionHandlers()
78 */
79 InstructionContext[] getSuccessors();
80
81 /**
82 * Returns the exception handlers that protect this instruction.
83 * They are special control flow successors.
84 */
85 ExceptionHandler[] getExceptionHandlers();
86 }