KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > internal > SET > SETSwitchNode


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.internal.SET;
21
22 import soot.*;
23 import java.util.*;
24 import soot.util.*;
25 import soot.jimple.*;
26 import soot.dava.internal.asg.*;
27 import soot.dava.internal.AST.*;
28 import soot.dava.internal.javaRep.*;
29 import soot.dava.toolkits.base.finders.*;
30
31 public class SETSwitchNode extends SETDagNode
32 {
33     private List switchNodeList;
34     private Value key;
35     private IterableSet junkBody;
36
37     public SETSwitchNode( AugmentedStmt characterizingStmt, Value key, IterableSet body, List switchNodeList, IterableSet junkBody)
38     {
39     super( characterizingStmt, body);
40
41     this.key = key;
42     this.switchNodeList = switchNodeList;
43     this.junkBody = junkBody;
44
45     Iterator it = switchNodeList.iterator();
46     while (it.hasNext())
47         add_SubBody( ((SwitchNode) it.next()).get_Body());
48
49     add_SubBody( junkBody);
50     }
51     
52
53     public IterableSet get_NaturalExits()
54     {
55     return new IterableSet();
56     }
57
58     public ASTNode emit_AST()
59     {
60     LinkedList indexList = new LinkedList();
61     Map index2ASTBody = new HashMap();
62     
63     Iterator it = switchNodeList.iterator();
64     while (it.hasNext()) {
65         SwitchNode sn = (SwitchNode) it.next();
66
67         Object JavaDoc lastIndex = sn.get_IndexSet().last();
68         Iterator iit = sn.get_IndexSet().iterator();
69         while (iit.hasNext()) {
70         Object JavaDoc index = iit.next();
71
72         indexList.addLast( index);
73
74         if (index != lastIndex)
75             index2ASTBody.put( index, null);
76         else
77             index2ASTBody.put( index, emit_ASTBody( (IterableSet) get_Body2ChildChain().get( sn.get_Body())));
78         }
79     }
80
81     return new ASTSwitchNode( get_Label(), key, indexList, index2ASTBody);
82     }
83
84     public AugmentedStmt get_EntryStmt()
85     {
86     return get_CharacterizingStmt();
87     }
88 }
89
Popular Tags