KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > jimple > toolkits > pointer > MemoryEfficientRasUnion


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Ondrej 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.jimple.toolkits.pointer;
21 import soot.*;
22 import java.util.*;
23
24 public class MemoryEfficientRasUnion extends Union {
25     HashSet subsets;
26
27     public boolean isEmpty() {
28     if( subsets == null ) return true;
29     for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) {
30         final PointsToSet subset = (PointsToSet) subsetIt.next();
31         if( !subset.isEmpty() ) return false;
32     }
33     return true;
34     }
35     public boolean hasNonEmptyIntersection( PointsToSet other ) {
36     if( subsets == null ) return true;
37     for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) {
38         final PointsToSet subset = (PointsToSet) subsetIt.next();
39         if( other instanceof Union ) {
40         if( other.hasNonEmptyIntersection( subset ) ) return true;
41         } else {
42         if( subset.hasNonEmptyIntersection( other ) ) return true;
43         }
44     }
45     return false;
46     }
47     public boolean addAll( PointsToSet s ) {
48     boolean ret = false;
49     if( subsets == null ) subsets = new HashSet();
50     if( s instanceof Union ) {
51         MemoryEfficientRasUnion meru = (MemoryEfficientRasUnion) s;
52         if( meru.subsets == null || subsets.containsAll( meru.subsets ) ) {
53         return false;
54         }
55         return subsets.addAll( meru.subsets );
56     } else {
57         PointsToSet r = (PointsToSet) s;
58         return subsets.add( s );
59     }
60     }
61     public Object JavaDoc clone() {
62     MemoryEfficientRasUnion ret = new MemoryEfficientRasUnion();
63     ret.addAll( this );
64     return ret;
65     }
66     public Set possibleTypes() {
67     if( subsets == null ) {
68         return Collections.EMPTY_SET;
69     }
70     HashSet ret = new HashSet();
71     for( Iterator subsetIt = subsets.iterator(); subsetIt.hasNext(); ) {
72         final PointsToSet subset = (PointsToSet) subsetIt.next();
73         ret.addAll( subset.possibleTypes() );
74     }
75     return ret;
76     }
77     public MemoryEfficientRasUnion() {
78     }
79
80
81 }
82
Popular Tags