KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > toolkits > base > finders > AbruptEdgeFinder


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

19
20 package soot.dava.toolkits.base.finders;
21
22 import soot.*;
23 import java.util.*;
24 import soot.util.*;
25 import soot.dava.*;
26 import soot.dava.internal.asg.*;
27 import soot.dava.internal.SET.*;
28 import soot.dava.internal.AST.*;
29 import soot.dava.internal.javaRep.*;
30
31 public class AbruptEdgeFinder implements FactFinder
32 {
33     public AbruptEdgeFinder( Singletons.Global g ) {}
34     public static AbruptEdgeFinder v() { return G.v().soot_dava_toolkits_base_finders_AbruptEdgeFinder(); }
35
36     public void find( DavaBody body, AugmentedStmtGraph asg, SETNode SET) throws RetriggerAnalysisException
37     {
38     Dava.v().log( "AbruptEdgeFinder::find()");
39
40     SET.find_AbruptEdges( this);
41     }
42
43     public void find_Continues( SETNode SETParent, IterableSet body, IterableSet children)
44     {
45     if ((SETParent instanceof SETCycleNode) == false)
46         return;
47
48     SETCycleNode scn = (SETCycleNode) SETParent;
49     IterableSet naturalPreds = ((SETNode) children.getLast()).get_NaturalExits();
50
51     Iterator pit = scn.get_CharacterizingStmt().bpreds.iterator();
52     while (pit.hasNext()) {
53         AugmentedStmt pas = (AugmentedStmt) pit.next();
54         
55         if ((body.contains( pas)) && (naturalPreds.contains( pas) == false))
56         ((SETStatementSequenceNode) pas.myNode).insert_AbruptStmt( new DAbruptStmt( "continue", scn.get_Label()));
57     }
58     }
59
60     public void find_Breaks( SETNode prev, SETNode cur)
61     {
62     IterableSet naturalPreds = prev.get_NaturalExits();
63
64     Iterator pit = cur.get_EntryStmt().bpreds.iterator();
65     while (pit.hasNext()) {
66         AugmentedStmt pas = (AugmentedStmt) pit.next();
67         
68         if (prev.get_Body().contains( pas) == false)
69         continue;
70
71         if (naturalPreds.contains( pas) == false)
72         ((SETStatementSequenceNode) pas.myNode).insert_AbruptStmt( new DAbruptStmt( "break", prev.get_Label()));
73     }
74     }
75 }
76
Popular Tags