KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > internal > AST > ASTUnconditionalLoopNode


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

20
21 package soot.dava.internal.AST;
22
23 import java.util.*;
24 import soot.*;
25 import soot.dava.internal.SET.*;
26 import soot.dava.toolkits.base.AST.analysis.*;
27
28 public class ASTUnconditionalLoopNode extends ASTLabeledNode
29 {
30     private List body;
31
32     public ASTUnconditionalLoopNode( SETNodeLabel label, List body)
33     {
34     super( label);
35     this.body = body;
36
37     subBodies.add( body);
38     }
39
40     /*
41       Nomair A Naeem 20-FEB-2005
42       Added for UselessLabeledBlockRemover
43     */

44     public void replaceBody(List body){
45     this.body=body;
46     subBodies=new ArrayList();
47     subBodies.add(body);
48     }
49
50     public Object JavaDoc clone()
51     {
52     return new ASTUnconditionalLoopNode( get_Label(), body);
53     }
54
55     public void toString( UnitPrinter up ) {
56         label_toString( up );
57         up.literal( "while" );
58         up.literal( " " );
59         up.literal( "(" );
60         up.literal( "true" );
61         up.literal( ")" );
62         up.newline();
63
64         up.literal( "{" );
65         up.newline();
66
67         up.incIndent();
68         body_toString( up, body );
69         up.decIndent();
70
71         up.literal( "}" );
72         up.newline();
73     }
74
75     public String JavaDoc toString()
76     {
77     StringBuffer JavaDoc b = new StringBuffer JavaDoc();
78     
79     b.append( label_toString( ));
80
81     b.append( "while (true)");
82     b.append( NEWLINE);
83     
84     b.append( "{");
85     b.append( NEWLINE);
86
87     b.append( body_toString( body));
88
89     b.append( "}");
90     b.append( NEWLINE);
91
92     return b.toString();
93     }
94
95
96     /*
97       Nomair A. Naeem, 7-FEB-05
98       Part of Visitor Design Implementation for AST
99       See: soot.dava.toolkits.base.AST.analysis For details
100     */

101     public void apply(Analysis a){
102     a.caseASTUnconditionalLoopNode(this);
103     }
104 }
105
Popular Tags