diff --git a/jode/jode/flow/SequentialBlock.java b/jode/jode/flow/SequentialBlock.java new file mode 100644 index 0000000..84caee1 --- /dev/null +++ b/jode/jode/flow/SequentialBlock.java @@ -0,0 +1,99 @@ +/* SequentialBlock (c) 1998 Jochen Hoenicke + * + * You may distribute under the terms of the GNU General Public License. + * + * IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF + * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" + * BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE, + * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * $Id$ + */ +package jode.flow; + +/** + * A sequential block combines exactly two structured blocks to a new + * one. The first sub block mustn't be another sequential block, + * instead the second sub block should be used for this. This + * condition is temporarily violated, while the t1 transformation is + * done. + */ +public class SequentialBlock { + StructuredBlock[] subBlocks; + + public SequentialBlock() { + subBlocks = new StructuredBlock[2]; + } + + public setFirst(StructuredBlock sb) { + subBlocks[0] = sb; + sb.outer = this; + } + + public setSecond(StructuredBlock sb) { + subBlocks[1] = sb; + sb.outer = this; + } + + /** + * Returns the block where the control will normally flow to, when + * the given sub block is finished (not ignoring the jump + * after this block). (This is overwritten by SequentialBlock and + * SwitchBlock). If this isn't called with a direct sub block, + * the behaviour is undefined, so take care. + * @return null, if the control flows to another FlowBlock. */ + StructuredBlock getNextBlock(StructuredBlock subBlock) { + if (subBlock == subBlocks[0]) + return subBlocks[1]; + return getNextBlock(); + } + + FlowBlock getNextFlowBlock(StructuredBlock subBlock) { + if (subBlock == subBlocks[0]) + return null; + return getNextFlowBlock(); + } + + /** + * Replaces the given sub block with a new block. + * @param oldBlock the old sub block. + * @param newBlock the new sub block. + * @return false, if oldBlock wasn't a direct sub block. + */ + boolean replaceSubBlock(StructuredBlock oldBlock, + StructuredBlock newBlock) { + for (int i=0; i<2; i++) { + if (subBlocks[i] == oldBlock) { + subBlocks[i] = newBlock; + return true; + } + } + return false; + } + + /** + * Returns all sub block of this structured block. + */ + StructuredBlock[] getSubBlocks() { + return subBlocks; + } + + /** + * Determines if there is a sub block, that flows through to the end + * of this block. If this returns true, you know that jump is null. + * @return true, if the jump may be safely changed. + */ + public boolean jumpMayBeChanged() { + return (subBlocks[1].jump != null || subBlocks[1].jumpMayBeChanged()); + } +} + + + + diff --git a/jode/jode/flow/VariableSet.java b/jode/jode/flow/VariableSet.java new file mode 100644 index 0000000..3d8b15d --- /dev/null +++ b/jode/jode/flow/VariableSet.java @@ -0,0 +1,156 @@ +/* VariableSet (c) 1998 Jochen Hoenicke + * + * You may distribute under the terms of the GNU General Public License. + * + * IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF + * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE + * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" + * BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE, + * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * $Id$ + */ +package jode.Flow; + +/** + * This class represents a set of Variables, which are mainly used in + * the in/out sets of StructuredBlock. The type of the Variables is + * LocalInfo.

+ * + * It defines some Helper-Function, like intersecting, merging, union + * and difference.

+ * + * Note that a variable set can contain LocalInfos that use the same + * slot, but are different. + */ +public class VariableSet extends java.util.Vector { + /** + * Creates a new empty variable set + */ + public VariableSet() { + } + + /** + * Adds a local variable to the variable set. + * @param li The local variable of type LocalInfo. + */ + public addElement(LocalInfo li) { + super.addElement((Object)li); + } + + /** + * Merges the current VariableSet with another. For all slots occuring + * in both variable sets, all corresponding LocalInfos are merged. + * The variable sets are not changed (use union for this). + * @param vs the other variable set. + */ + public void merge(VariableSet vs) { + for (int i=0; i=0; i--) { + LocalInfo li1 = (LocalInfo) elementData[i]; + for (int j=0; j