01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Jerome Miecznikowski
03: * Copyright (C) 2004-2005 Nomair A. Naeem
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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.jimple.*;
24: import soot.dava.internal.SET.*;
25: import soot.dava.toolkits.base.AST.*;
26:
27: public abstract class ASTControlFlowNode extends ASTLabeledNode {
28: //protected ValueBox conditionBox;
29: ASTCondition condition;
30:
31: public ASTControlFlowNode(SETNodeLabel label,
32: ConditionExpr condition) {
33: super (label);
34: //this.conditionBox = Jimple.v().newConditionExprBox(condition);
35: this .condition = new ASTBinaryCondition(condition);
36: }
37:
38: /*
39: Nomair A. Naeem 17-FEB-05
40: Needed because of change of grammar of condition being stored as a ASTCondition rather
41: than the ConditionExpr which was the case before
42: */
43: public ASTControlFlowNode(SETNodeLabel label, ASTCondition condition) {
44: super (label);
45: this .condition = condition;
46: }
47:
48: public ASTCondition get_Condition() {
49: return condition;
50: }
51:
52: public void set_Condition(ASTCondition condition) {
53: this .condition = condition;
54: }
55:
56: public void perform_Analysis(ASTAnalysis a) {
57: /*
58: Nomair A Naeem 17-FEB-05
59: Changed because the ASTControlFlowNode does not have a ConditionBox anymore
60:
61: The if check is not an ideal way of implementation
62: What should be done is to do a DepthFirst of the Complete
63: Condition hierarcy and walk all values that are found
64:
65: Notice this condition will always return true UNLESS transformations aggregating
66: the control flow have been performed.
67:
68: This method is deprecated do not use it. Use the DepthFirstAdapter class in dava.toolkits.base.AST.analysis.
69: */
70: if (condition instanceof ASTBinaryCondition) {
71: ConditionExpr condExpr = ((ASTBinaryCondition) condition)
72: .getConditionExpr();
73: ASTWalker.v().walk_value(a, condExpr);
74: }
75:
76: if (a instanceof TryContentsFinder) {
77: TryContentsFinder.v().add_ExceptionSet(this,
78: TryContentsFinder.v().remove_CurExceptionSet());
79: }
80:
81: perform_AnalysisOnSubBodies(a);
82: }
83: }
|