View Javadoc
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.bcel.verifier.structurals;
18  
19  import java.util.ArrayList;
20  
21  import org.apache.bcel.generic.InstructionHandle;
22  
23  /**
24   * An InstructionContext offers convenient access to information like control flow successors and such.
25   */
26  public interface InstructionContext {
27  
28      /**
29       * This method symbolically executes the Instruction held in the InstructionContext. It "merges in" the incoming
30       * execution frame situation (see The Java Virtual Machine Specification, 2nd edition, page 146). By so doing, the
31       * outgoing execution frame situation is calculated.
32       *
33       * This method is JustIce-specific and is usually of no sense for users of the ControlFlowGraph class. They should use
34       * getInstruction().accept(Visitor), possibly in conjunction with the ExecutionVisitor.
35       *
36       *
37       * @see ControlFlowGraph
38       * @see ExecutionVisitor
39       * @see #getOutFrame(ArrayList)
40       * @return true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
41       */
42      boolean execute(Frame inFrame, ArrayList<InstructionContext> executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);
43  
44      /**
45       * Returns the exception handlers that protect this instruction. They are special control flow successors.
46       */
47      ExceptionHandler[] getExceptionHandlers();
48  
49      Frame getInFrame();
50  
51      /**
52       * Returns the InstructionHandle this InstructionContext is wrapped around.
53       *
54       * @return The InstructionHandle this InstructionContext is wrapped around.
55       */
56      InstructionHandle getInstruction();
57  
58      /**
59       * This method returns the outgoing execution frame situation; therefore <B>it has to be calculated by execute(Frame,
60       * ArrayList) first.</B>
61       *
62       * @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
63       */
64      Frame getOutFrame(ArrayList<InstructionContext> executionPredecessors);
65  
66      /**
67       * Returns the usual control flow successors.
68       *
69       * @see #getExceptionHandlers()
70       */
71      InstructionContext[] getSuccessors();
72  
73      /**
74       * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
75       * InstructionContext object depends on the value of the tag. JustIce does not use it.
76       *
77       * @see #setTag(int tag)
78       */
79      int getTag();
80  
81      /**
82       * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the
83       * InstructionContext object depends on the value of the tag. JustIce does not use it.
84       *
85       * @see #getTag()
86       */
87      void setTag(int tag);
88  }