KickJava   Java API By Example, From Geeks To Geeks.

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


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 soot.*;
24 import java.util.*;
25 import soot.jimple.*;
26 import soot.dava.internal.asg.*;
27 import soot.dava.toolkits.base.AST.*;
28 import soot.dava.toolkits.base.AST.analysis.*;
29
30 public class ASTStatementSequenceNode extends ASTNode
31 {
32     private List statementSequence;
33
34     public ASTStatementSequenceNode( List statementSequence)
35     {
36     super();
37
38     this.statementSequence = statementSequence;
39     }
40
41     public Object JavaDoc clone()
42     {
43     return new ASTStatementSequenceNode( statementSequence);
44     }
45
46     public void perform_Analysis( ASTAnalysis a)
47     {
48     if (a.getAnalysisDepth() > ASTAnalysis.ANALYSE_AST) {
49
50         Iterator it = statementSequence.iterator();
51         while (it.hasNext())
52         ASTWalker.v().walk_stmt( a, ((AugmentedStmt) it.next()).get_Stmt());
53     }
54
55     if (a instanceof TryContentsFinder) {
56         TryContentsFinder tcf = (TryContentsFinder) a;
57         tcf.v().add_ExceptionSet( this, tcf.v().remove_CurExceptionSet());
58     }
59     }
60
61     public void toString( UnitPrinter up ) {
62     Iterator it = statementSequence.iterator();
63     while (it.hasNext()) {
64             AugmentedStmt as = (AugmentedStmt) it.next();
65         //System.out.println("Stmt is:"+as.get_Stmt());
66
Unit u = as.get_Stmt();
67             up.startUnit( u );
68             u.toString( up );
69             up.literal(";");
70             up.endUnit( u );
71             up.newline();
72         }
73     }
74
75     public String JavaDoc toString()
76     {
77     StringBuffer JavaDoc b = new StringBuffer JavaDoc();
78
79     Iterator it = statementSequence.iterator();
80     while (it.hasNext()) {
81         b.append( ((Unit) ((AugmentedStmt) it.next()).get_Stmt()).toString());
82         b.append( ";");
83         b.append( NEWLINE);
84     }
85
86     return b.toString();
87     }
88
89
90     /*
91       Nomair A. Naeem, 7-FEB-05
92       Part of Visitor Design Implementation for AST
93       See: soot.dava.toolkits.base.AST.analysis For details
94     */

95     public List getStatements(){
96     return statementSequence;
97     }
98
99     public void apply(Analysis a){
100     a.caseASTStatementSequenceNode(this);
101     }
102
103
104
105
106     /*
107       Nomair A. Naeem added 3-MAY-05
108     */

109     public void setStatements(List statementSequence){
110     this.statementSequence=statementSequence;
111     }
112 }
113
Popular Tags