KickJava   Java API By Example, From Geeks To Geeks.

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


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 soot.jimple.*;
25 import soot.dava.internal.SET.*;
26 import soot.dava.toolkits.base.AST.*;
27
28 public abstract class ASTControlFlowNode extends ASTLabeledNode
29 {
30     //protected ValueBox conditionBox;
31
ASTCondition condition;
32
33     public ASTControlFlowNode( SETNodeLabel label, ConditionExpr condition)
34     {
35     super( label);
36         //this.conditionBox = Jimple.v().newConditionExprBox(condition);
37
this.condition = new ASTBinaryCondition(condition);
38     }
39
40     /*
41       Nomair A. Naeem 17-FEB-05
42       Needed because of change of grammar of condition being stored as a ASTCondition rather
43       than the ConditionExpr which was the case before
44     */

45     public ASTControlFlowNode( SETNodeLabel label, ASTCondition condition)
46     {
47     super( label);
48     this.condition = condition;
49     }
50
51
52     public ASTCondition get_Condition()
53     {
54     return condition;
55     }
56
57
58     public void set_Condition(ASTCondition condition){
59     this.condition=condition;
60     }
61
62     public void perform_Analysis( ASTAnalysis a)
63     {
64     /*
65       Nomair A Naeem 17-FEB-05
66       Changed because the ASTControlFlowNode does not have a ConditionBox anymore
67
68       The if check is not an ideal way of implementation
69       What should be done is to do a DepthFirst of the Complete
70       Condition hierarcy and walk all values that are found
71       
72       Notice this condition will always return true UNLESS transformations aggregating
73       the control flow have been performed.
74
75       This method is deprecated do not use it. Use the DepthFirstAdapter class in dava.toolkits.base.AST.analysis.
76     */

77     if(condition instanceof ASTBinaryCondition){
78         ConditionExpr condExpr = ((ASTBinaryCondition)condition).getConditionExpr();
79         ASTWalker.v().walk_value( a, condExpr);
80     }
81
82     if (a instanceof TryContentsFinder) {
83         TryContentsFinder tcf = (TryContentsFinder) a;
84         tcf.v().add_ExceptionSet( this, tcf.v().remove_CurExceptionSet());
85     }
86
87     perform_AnalysisOnSubBodies( a);
88     }
89 }
90
Popular Tags