Some initial implementation of reachability for ownership analysis.
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / TokenTuple.java
1 package Analysis.OwnershipAnalysis;
2
3 import IR.*;
4 import IR.Flat.*;
5 import java.util.*;
6 import java.io.*;
7
8
9 // a token touple is a pair that indicates a
10 // heap region node and an arity
11 public class TokenTuple
12 {
13     private Integer token;
14     private boolean isNewSummary;
15
16     // only summary tokens should have ARITY_MANY?
17     public static final int ARITY_ONE  = 1;
18     public static final int ARITY_MANY = 2;
19     private int arity;
20
21     public TokenTuple( HeapRegionNode hrn ) {
22         token        = hrn.getID();
23         isNewSummary = hrn.isNewSummary();
24         arity        = ARITY_ONE;
25     }
26
27     public TokenTuple( Integer token,
28                        boolean isNewSummary,
29                        int     arity ) {
30         this.token        = token;
31         this.isNewSummary = isNewSummary;
32         this.arity        = arity;
33     }
34
35     public Integer getToken() { return token; }
36     public int     getArity() { return arity; }
37
38     public void increaseArity() {
39         if( isNewSummary ) {
40             arity = ARITY_MANY;
41         }
42     }
43
44     public boolean equals( TokenTuple tt ) {
45         return token.equals( tt.getToken() ) &&
46                arity ==      tt.getArity();
47     }
48
49     public TokenTuple copy() {
50         return new TokenTuple( token,
51                                isNewSummary,
52                                arity );
53     }
54 }