1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.bcel.verifier.structurals;
20
21 import java.util.ArrayList;
22
23 import org.apache.bcel.generic.InstructionHandle;
24
25 /**
26 * An InstructionContext offers convenient access to information like control flow successors and such.
27 */
28 public interface InstructionContext {
29
30 /**
31 * This method symbolically executes the Instruction held in the InstructionContext. It "merges in" the incoming
32 * execution frame situation (see The Java Virtual Machine Specification, 2nd edition, page 146). By so doing, the
33 * outgoing execution frame situation is calculated.
34 *
35 * This method is JustIce-specific and is usually of no sense for users of the ControlFlowGraph class. They should use
36 * getInstruction().accept(Visitor), possibly in conjunction with the ExecutionVisitor.
37 *
38 *
39 * @see ControlFlowGraph
40 * @see ExecutionVisitor
41 * @see #getOutFrame(ArrayList)
42 * @return true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
43 */
44 boolean execute(Frame inFrame, ArrayList<InstructionContext> executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);
45
46 /**
47 * Returns the exception handlers that protect this instruction. They are special control flow successors.
48 */
49 ExceptionHandler[] getExceptionHandlers();
50
51 Frame getInFrame();
52
53 /**
54 * Returns the InstructionHandle this InstructionContext is wrapped around.
55 *
56 * @return The InstructionHandle this InstructionContext is wrapped around.
57 */
58 InstructionHandle getInstruction();
59
60 /**
61 * This method returns the outgoing execution frame situation; therefore <B>it has to be calculated by execute(Frame,
62 * ArrayList) first.</B>
63 *
64 * @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
65 */
66 Frame getOutFrame(ArrayList<InstructionContext> executionPredecessors);
67
68 /**
69 * Returns the usual control flow successors.
70 *
71 * @see #getExceptionHandlers()
72 */
73 InstructionContext[] getSuccessors();
74
75 /**
76 * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
77 * InstructionContext object depends on the value of the tag. JustIce does not use it.
78 *
79 * @see #setTag(int tag)
80 */
81 int getTag();
82
83 /**
84 * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
85 * InstructionContext object depends on the value of the tag. JustIce does not use it.
86 *
87 * @see #getTag()
88 */
89 void setTag(int tag);
90 }