001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.bcel.verifier.structurals; 020 021import java.util.ArrayList; 022 023import org.apache.bcel.generic.InstructionHandle; 024 025/** 026 * An InstructionContext offers convenient access to information like control flow successors and such. 027 */ 028public interface InstructionContext { 029 030 /** 031 * This method symbolically executes the Instruction held in the InstructionContext. It "merges in" the incoming 032 * execution frame situation (see The Java Virtual Machine Specification, 2nd edition, page 146). By so doing, the 033 * outgoing execution frame situation is calculated. 034 * 035 * This method is JustIce-specific and is usually of no sense for users of the ControlFlowGraph class. They should use 036 * getInstruction().accept(Visitor), possibly in conjunction with the ExecutionVisitor. 037 * 038 * 039 * @see ControlFlowGraph 040 * @see ExecutionVisitor 041 * @see #getOutFrame(ArrayList) 042 * @return true - if and only if the "outgoing" frame situation changed from the one before execute()ing. 043 */ 044 boolean execute(Frame inFrame, ArrayList<InstructionContext> executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev); 045 046 /** 047 * Returns the exception handlers that protect this instruction. They are special control flow successors. 048 */ 049 ExceptionHandler[] getExceptionHandlers(); 050 051 Frame getInFrame(); 052 053 /** 054 * Returns the InstructionHandle this InstructionContext is wrapped around. 055 * 056 * @return The InstructionHandle this InstructionContext is wrapped around. 057 */ 058 InstructionHandle getInstruction(); 059 060 /** 061 * This method returns the outgoing execution frame situation; therefore <B>it has to be calculated by execute(Frame, 062 * ArrayList) first.</B> 063 * 064 * @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor) 065 */ 066 Frame getOutFrame(ArrayList<InstructionContext> executionPredecessors); 067 068 /** 069 * Returns the usual control flow successors. 070 * 071 * @see #getExceptionHandlers() 072 */ 073 InstructionContext[] getSuccessors(); 074 075 /** 076 * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the 077 * InstructionContext object depends on the value of the tag. JustIce does not use it. 078 * 079 * @see #setTag(int tag) 080 */ 081 int getTag(); 082 083 /** 084 * The getTag and setTag methods may be used for temporary flagging, such as graph coloring. Nothing in the 085 * InstructionContext object depends on the value of the tag. JustIce does not use it. 086 * 087 * @see #getTag() 088 */ 089 void setTag(int tag); 090}