Create analysis model for string literals in disjointness analysis that supports...
[IRC.git] / Robust / src / Analysis / Disjoint / HeapAnalysis.java
1 package Analysis.Disjoint;
2
3 import java.util.*;
4
5 import IR.*;
6 import IR.Flat.TempDescriptor;
7 import IR.Flat.FlatNode;
8 import IR.Flat.FlatNew;
9
10
11 public interface HeapAnalysis {
12   public EffectsAnalysis getEffectsAnalysis();
13   public Alloc getAllocationSiteFromFlatNew(FlatNew node);
14
15   // what are these for?  Well, if your heap analysis wants to model
16   // the command line argument heap as the initial context, AND you are
17   // assigning IDs to allocation sites, the problem is there is no explicit
18   // allocation site for the command line arguments in the source code.  So
19   // what you do is build your model and when these methods are invoked, return
20   // the alloc ID from your model.  So the structure is an array of Strings has
21   // elements that reference a single String, and that String has a field that
22   // references an array of char primitives.
23   public Alloc getCmdLineArgsAlloc();    // an array of String
24   public Alloc getCmdLineArgAlloc();     // a String
25   public Alloc getCmdLineArgBytesAlloc();// an array of char
26
27
28   // similar to above, new string literals have a runtime alloc site (not in
29   // code explicitly) so make one in your model and return it here
30   public Alloc getNewStringLiteralAlloc();     // a String
31   public Alloc getNewStringLiteralBytesAlloc();// an array of char
32
33
34   // Use these methods to find out what allocation sites
35   // the given pointer might point to at or after the 
36   // given program point.  In the case of a variable and
37   // a field or element dereference you get a hashtable
38   // where the keys are allocs for the variables and the
39   // values are from following the second hop
40   // NOTE: if the set of Alloc's that something can point
41   // to is DONTCARE, this will mean "the analysis doesn't care
42   // what it points to" so the client shouldn't either, NOT
43   // interpreting it as "it can't point to anything."  The
44   // meaning "it can't point to anything" will be represented
45   // by an empty set of Alloc.
46   static public final Set<Alloc>                     DONTCARE_PTR  = new HashSet<Alloc>();
47   static public final Hashtable< Alloc, Set<Alloc> > DONTCARE_DREF = new Hashtable< Alloc, Set<Alloc> >();
48
49   public Set<Alloc> canPointToAt( TempDescriptor x,
50                                   FlatNode programPoint );
51
52   public Set<Alloc> canPointToAfter( TempDescriptor x,
53                                      FlatNode programPoint );
54   
55   public Hashtable< Alloc, Set<Alloc> > canPointToAt( TempDescriptor x,
56                                                       FieldDescriptor f,
57                                                       FlatNode programPoint );
58
59   public Hashtable< Alloc, Set<Alloc> > canPointToAtElement( TempDescriptor x, // x[i]
60                                                              FlatNode programPoint );
61 }
62