KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > flow > ContinueBlock


1 /* ContinueBlock Copyright (C) 1998-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; see the file COPYING.LESSER. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: ContinueBlock.java,v 3.5.4.1 2002/05/28 17:34:08 hoenicke Exp $
18  */

19
20 package jode.flow;
21 import jode.decompiler.TabbedPrintWriter;
22
23 /**
24  *
25  */

26 public class ContinueBlock extends StructuredBlock {
27     LoopBlock continuesBlock;
28     String JavaDoc continueLabel;
29
30     public ContinueBlock(LoopBlock continuesBlock, boolean needsLabel) {
31         this.continuesBlock = continuesBlock;
32         if (needsLabel)
33             continueLabel = continuesBlock.getLabel();
34         else
35             continueLabel = null;
36     }
37
38     public void checkConsistent() {
39         super.checkConsistent();
40         StructuredBlock sb = outer;
41         while (sb != continuesBlock) {
42             if (sb == null)
43                 throw new RuntimeException JavaDoc("Inconsistency");
44             sb = sb.outer;
45         }
46     }
47
48     /**
49      * Tells if this block is empty and only changes control flow.
50      */

51     public boolean isEmpty() {
52         return true;
53     }
54
55     /**
56      * Returns the block where the control will normally flow to, when
57      * this block is finished (not ignoring the jump after this block).
58      */

59     public StructuredBlock getNextBlock() {
60         /* This continues to continuesBlock. */
61         return continuesBlock;
62     }
63
64     /**
65      * Returns the flow block where the control will normally flow to,
66      * when this block is finished (not ignoring the jump after this
67      * block).
68      * @return null, if the control flows into a non empty structured
69      * block or if this is the outermost block.
70      */

71     public FlowBlock getNextFlowBlock() {
72         return null;
73     }
74
75     /**
76      * This is called after the analysis is completely done. It
77      * will remove all PUSH/stack_i expressions, (if the bytecode
78      * is correct).
79      * @param stack the stackmap at begin of the block
80      * @return null if the bytecode isn't correct and stack mapping
81      * didn't worked, otherwise the stack after the block has executed.
82      */

83     public VariableStack mapStackToLocal(VariableStack stack) {
84     continuesBlock.mergeContinueStack(stack);
85     return null;
86     }
87
88     public void dumpInstruction(TabbedPrintWriter writer)
89     throws java.io.IOException JavaDoc
90     {
91         writer.println("continue"+
92                        (continueLabel == null ? "" : " "+continueLabel) + ";");
93     }
94
95     public boolean needsBraces() {
96         return false;
97     }
98     
99     public boolean jumpMayBeChanged() {
100         return true;
101     }
102 }
103
Popular Tags