beginning of points-to analysis
[IRC.git] / Robust / src / Analysis / Pointer / AllocFactory.java
1 package Analysis.Pointer;
2
3 import java.util.*;
4 import IR.*;
5 import IR.Flat.*;
6
7 public class AllocFactory {
8   public static class AllocNode {
9     int allocsite;
10     boolean summary;
11     TypeDescriptor type;
12     
13     public AllocNode(int allocsite, TypeDescriptor type, boolean summary) {
14       this.allocsite=allocsite;
15       this.summary=summary;
16       this.type=type;
17     }
18     
19     public int hashCode() {
20       return allocsite<<1^(summary?0:1);
21     }
22     
23     public boolean equals(Object o) {
24       if (o instanceof AllocNode) {
25         AllocNode an=(AllocNode)o;
26         return (allocsite==an.allocsite)&&(summary==an.summary);
27       }
28       return false;
29     }
30   }
31
32   public AllocFactory(State state, TypeUtil typeUtil) {
33     allocMap=new HashMap<FlatNode, Integer>();
34     this.typeUtil=typeUtil;
35     ClassDescriptor stringcd=typeUtil.getClass(TypeUtil.StringClass);
36     TypeDescriptor stringtd=new TypeDescriptor(stringcd);
37     TypeDescriptor stringarraytd=stringtd.makeArray(state);
38     StringArray=new AllocNode(0, stringarraytd, false);
39     Strings=new AllocNode(1, stringtd, true);
40   }
41   
42   HashMap<FlatNode, Integer> allocMap;
43   TypeUtil typeUtil;
44   int siteCounter=2;
45
46   public AllocNode StringArray;
47   public AllocNode Strings;
48 }