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