KickJava   Java API By Example, From Geeks To Geeks.

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


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Jerome Miecznikowski
3  * Copyright (C) 2004-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 soot.*;
24 import java.util.*;
25 import soot.dava.internal.SET.*;
26 import soot.dava.toolkits.base.AST.*;
27 import soot.dava.toolkits.base.AST.analysis.*;
28
29 public class ASTLabeledBlockNode extends ASTLabeledNode
30 {
31     private List body;
32     private SETNodeLabel label;
33     
34     public ASTLabeledBlockNode( SETNodeLabel label, List body){
35     super( label);
36     this.body = body;
37     
38     subBodies.add( body);
39     }
40
41     /*
42       Nomair A Naeem 20-FEB-2005
43       Added for OrAggregatorOne/UselessLabeledBlockRemover
44     */

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

108     public void apply(Analysis a){
109     a.caseASTLabeledBlockNode(this);
110     }
111 }
112
Popular Tags