KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > javaToJimple > InnerClassInfoFinder


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
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.javaToJimple;
21 import java.util.*;
22
23 public class InnerClassInfoFinder extends polyglot.visit.NodeVisitor {
24
25     private ArrayList localClassDeclList;
26     private ArrayList anonBodyList;
27     private ArrayList memberList;
28     //private ArrayList declaredInstList;
29
//private ArrayList usedInstList;
30

31     public ArrayList memberList(){
32         return memberList;
33     }
34
35     /*public ArrayList declaredInstList(){
36         return declaredInstList;
37     }
38
39     public ArrayList usedInstList(){
40         return usedInstList;
41     }*/

42
43     public ArrayList localClassDeclList(){
44         return localClassDeclList;
45     }
46
47     public ArrayList anonBodyList(){
48         return anonBodyList;
49     }
50
51     public InnerClassInfoFinder(){
52         //declFound = null;
53
localClassDeclList = new ArrayList();
54         anonBodyList = new ArrayList();
55         memberList = new ArrayList();
56         //declaredInstList = new ArrayList();
57
//usedInstList = new ArrayList();
58
}
59
60     public polyglot.visit.NodeVisitor enter(polyglot.ast.Node parent, polyglot.ast.Node n) {
61     
62         if (n instanceof polyglot.ast.LocalClassDecl) {
63             localClassDeclList.add(n);
64         }
65         if (n instanceof polyglot.ast.New) {
66             if (((polyglot.ast.New)n).anonType() != null){
67                 anonBodyList.add(n);
68             }
69             /*polyglot.types.ProcedureInstance pi = ((polyglot.ast.New)n).constructorInstance();
70             if (pi.isPrivate()){
71                 usedInstList.add(new polyglot.util.IdentityKey(pi));
72             }*/

73         }
74         
75         if (n instanceof polyglot.ast.ProcedureDecl) {
76             memberList.add(n);
77             /*polyglot.types.ProcedureInstance pi = ((polyglot.ast.ProcedureDecl)n).procedureInstance();
78             if (pi.flags().isPrivate()){
79                 declaredInstList.add(new polyglot.util.IdentityKey(pi));
80             }*/

81         }
82         if (n instanceof polyglot.ast.FieldDecl) {
83             memberList.add(n);
84             /*polyglot.types.FieldInstance fi = ((polyglot.ast.FieldDecl)n).fieldInstance();
85             if (fi.flags().isPrivate()){
86                 declaredInstList.add(new polyglot.util.IdentityKey(fi));
87             }*/

88         }
89         if (n instanceof polyglot.ast.Initializer) {
90             memberList.add(n);
91         }
92
93         /*if (n instanceof polyglot.ast.Field) {
94             polyglot.types.FieldInstance fi = ((polyglot.ast.Field)n).fieldInstance();
95             if (fi.isPrivate()){
96                 usedInstList.add(new polyglot.util.IdentityKey(fi));
97             }
98         }
99         if (n instanceof polyglot.ast.Call){
100             polyglot.types.ProcedureInst pi = ((polyglot.ast.Call)n).methodInstance();
101             if (pi.isPrivate()){
102                 usedInstList.add(new polyglot.util.IdentityKey(pi));
103             }
104         }
105         if (n instanceof polyglot.ast.ConstructorCall){
106             polyglot.types.ProcedureInstance pi = ((polyglot.ast.ConstructorCall)n).constructorInstance();
107             if (pi.isPrivate()){
108                 usedInstList.add(new polyglot.util.IdentityKey(pi));
109             }
110         }*/

111         
112         
113         return enter(n);
114     }
115 }
116
Popular Tags