KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > flow > RetBlock


1 /* RetBlock 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: RetBlock.java.in,v 4.1.2.1 2002/05/28 17:34:09 hoenicke Exp $
18  */

19
20 package jode.flow;
21 import jode.decompiler.LocalInfo;
22
23 import java.util.Collections JavaDoc;
24 import java.util.Set JavaDoc;
25
26 /**
27  * This block represents a ret instruction. A ret instruction is
28  * used to call the finally block, or to call the monitorexit block in
29  * a synchronized block.
30  *
31  * @author Jochen Hoenicke
32  */

33 public class RetBlock extends StructuredBlock {
34     /**
35      * The local containing the return address
36      */

37     LocalInfo local;
38
39     public RetBlock(LocalInfo local) {
40     this.local = local;
41     }
42
43     /**
44      * Fill all in variables into the given VariableSet.
45      * @param in The VariableSet, the in variables should be stored to.
46      */

47     public void fillInGenSet(Set JavaDoc in, Set JavaDoc gen) {
48     in.add(local);
49     gen.add(local);
50     }
51
52     /**
53      * This does take the instr into account and modifies stack
54      * accordingly. It then calls super.mapStackToLocal.
55      * @param stack the stack before the instruction is called
56      * @return stack the stack afterwards.
57      */

58     public VariableStack mapStackToLocal(VariableStack stack) {
59     if (!stack.isEmpty())
60         throw new IllegalArgumentException JavaDoc("stack is not empty at RET");
61     return null;
62     }
63
64     public Set JavaDoc getDeclarables() {
65     return Collections.singleton(local);
66     }
67
68     public void dumpInstruction(jode.decompiler.TabbedPrintWriter writer)
69         throws java.io.IOException JavaDoc
70     {
71     writer.println("RET "+local);
72     }
73 }
74
Popular Tags