KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > typing > integer > TypeNode


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1997-2000 Etienne Gagnon. All rights reserved.
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 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27 package soot.jimple.toolkits.typing.integer;
28
29 import soot.*;
30 import soot.jimple.*;
31 import soot.util.*;
32 import java.util.*;
33
34 /**
35  * Each instance of this class represents one basic type.
36  **/

37 class TypeNode
38 {
39   public static final boolean DEBUG = false;
40
41   private final int id;
42   private final Type type;
43   
44   public TypeNode(int id, Type type)
45   {
46     this.id = id;
47     this.type = type;
48
49     if(DEBUG)
50       {
51     G.v().out.println("creating node " + this);
52       }
53   }
54   
55   /** Returns the unique id of this type node. **/
56   public int id()
57   {
58     return id;
59   }
60
61   /** Returns the type represented by this type node. **/
62   public Type type()
63   {
64     return type;
65   }
66
67   public boolean hasAncestor_1(TypeNode typeNode)
68   {
69     if(typeNode == this)
70       return true;
71
72     return ClassHierarchy.v().hasAncestor_1(id, typeNode.id);
73   }
74
75   public boolean hasAncestor_2(TypeNode typeNode)
76   {
77     if(typeNode == this)
78       return true;
79     
80     return ClassHierarchy.v().hasAncestor_2(id, typeNode.id);
81   }
82
83   /* public boolean hasDescendant_1(TypeNode typeNode)
84   {
85     return ClassHierarchy.v().hasDescendant_1(id, typeNode.id);
86   }
87
88   public boolean hasDescendant_2(TypeNode typeNode)
89   {
90     return ClassHierarchy.v().hasDescendant_2(id, typeNode.id);
91   }
92
93   public boolean hasDescendantOrSelf_1(TypeNode typeNode)
94   {
95     if(typeNode == this)
96       return true;
97
98     return hasDescendant_1(typeNode);
99   }
100
101   public boolean hasDescendantOrSelf_2(TypeNode typeNode)
102   {
103     if(typeNode == this)
104       return true;
105
106     return hasDescendant_2(typeNode);
107     }*/

108
109   public TypeNode lca_1(TypeNode typeNode)
110   {
111     return ClassHierarchy.v().lca_1(id, typeNode.id);
112   }
113
114   public TypeNode lca_2(TypeNode typeNode)
115   {
116     return ClassHierarchy.v().lca_2(id, typeNode.id);
117   }
118
119   public TypeNode gcd_1(TypeNode typeNode)
120   {
121     return ClassHierarchy.v().gcd_1(id, typeNode.id);
122   }
123
124   public TypeNode gcd_2(TypeNode typeNode)
125   {
126     return ClassHierarchy.v().gcd_2(id, typeNode.id);
127   }
128
129   public String JavaDoc toString()
130   {
131     if(type != null)
132       {
133     return type + "(" + id + ")";
134       }
135
136     if(this == ClassHierarchy.v().TOP)
137       {
138     return "TOP" + "(" + id + ")";
139       }
140
141     if(this == ClassHierarchy.v().R0_1)
142       {
143     return "R0_1" + "(" + id + ")";
144       }
145
146     if(this == ClassHierarchy.v().R0_127)
147       {
148     return "R0_127" + "(" + id + ")";
149       }
150
151     if(this == ClassHierarchy.v().R0_32767)
152       {
153     return "R0_32767" + "(" + id + ")";
154       }
155
156     return "ERROR!!!!";
157   }
158 }
159
Popular Tags