KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > internal > JReturnStmt


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1999 Patrick Lam
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27
28
29
30
31 package soot.jimple.internal;
32
33 import soot.*;
34 import soot.tagkit.*;
35
36 import soot.jimple.*;
37 import soot.baf.*;
38 import soot.jimple.*;
39 import soot.util.*;
40 import java.util.*;
41
42 public class JReturnStmt extends AbstractStmt implements ReturnStmt
43 {
44     ValueBox returnValueBox;
45
46     public JReturnStmt(Value returnValue)
47     {
48         this(Jimple.v().newImmediateBox(returnValue));
49     }
50
51     protected JReturnStmt(ValueBox returnValueBox)
52     {
53         this.returnValueBox = returnValueBox;
54     }
55
56     public Object JavaDoc clone()
57     {
58         return new JReturnStmt(Jimple.cloneIfNecessary(getOp()));
59     }
60
61     public String JavaDoc toString()
62     {
63         return Jimple.v().RETURN + " " + returnValueBox.getValue().toString();
64     }
65     
66     public void toString( UnitPrinter up) {
67         up.literal(Jimple.v().RETURN);
68         up.literal(" ");
69         returnValueBox.toString(up);
70     }
71     
72     public ValueBox getOpBox()
73     {
74         return returnValueBox;
75     }
76
77     public void setOp(Value returnValue)
78     {
79         returnValueBox.setValue(returnValue);
80     }
81
82     public Value getOp()
83     {
84         return returnValueBox.getValue();
85     }
86
87     public List getUseBoxes()
88     {
89         List useBoxes = new ArrayList();
90
91         useBoxes.addAll(returnValueBox.getValue().getUseBoxes());
92         useBoxes.add(returnValueBox);
93
94         return useBoxes;
95     }
96
97     public void apply(Switch sw)
98     {
99         ((StmtSwitch) sw).caseReturnStmt(this);
100     }
101
102     public void convertToBaf(JimpleToBafContext context, List out)
103     {
104        ((ConvertToBaf)(getOp())).convertToBaf(context, out);
105        
106        
107        Unit u;
108        out.add(u = Baf.v().newReturnInst(getOp().getType()));
109      
110        Unit currentUnit = this;
111
112     Iterator it = currentUnit.getTags().iterator();
113     while(it.hasNext()) {
114         u.addTag((Tag) it.next());
115     }
116     }
117
118      
119     public boolean fallsThrough(){return false;}
120     public boolean branches(){return false;}
121
122
123 }
124
125
Popular Tags