Source code

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