1 salcianu 1.1.2.1 // ExactTemp.java, created Sun Apr  2 16:06:58 2000 by salcianu
 2 cananian 1.1.2.4 // Copyright (C) 2000 Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>
 3 salcianu 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 salcianu 1.1.2.1 package harpoon.Util.TypeInference;
 5 salcianu 1.1.2.1 
 6 salcianu 1.1.2.1 import harpoon.IR.Quads.Quad;
 7 salcianu 1.1.2.1 import harpoon.Temp.Temp;
 8 salcianu 1.1.2.1 
 9 salcianu 1.1.2.1 
10 salcianu 1.1.2.1 /**
11 salcianu 1.1.2.2  * <code>ExactTemp</code> is simply a pair of a <code>Quad</code>
12 salcianu 1.1.2.2  and a <code>Temp</code>. This is usually used to represent the
13 salcianu 1.1.2.2  temp t defined in instruction q to make the distinction between this
14 salcianu 1.1.2.2  definition of t and some other one (this is particularly useful if
15 salcianu 1.1.2.2  the code is not in the SSA form).<br>
16 salcianu 1.1.2.2  However, since an <code>ExactTemp</code> is just a pair <q,t>, it can
17 salcianu 1.1.2.2  be used to simply denote the temp t used (not defined) in the instruction
18 salcianu 1.1.2.2  q (as for example in the constructor of <code>TypeInference</code>).
19 salcianu 1.1.2.1  * 
20 cananian 1.1.2.4  * @author  Alexandru SALCIANU <salcianu@retezat.lcs.mit.edu>
21 cananian 1.2      * @version $Id: ExactTemp.java,v 1.2 2002/02/25 21:09:37 cananian Exp $
22 salcianu 1.1.2.1  */
23 salcianu 1.1.2.3 public class ExactTemp implements java.io.Serializable {
24 salcianu 1.1.2.2 
25 salcianu 1.1.2.1     Quad q;
26 salcianu 1.1.2.1     Temp t;
27 salcianu 1.1.2.1 
28 salcianu 1.1.2.1     /** Creates a <code>ExactTemp</code>. */
29 salcianu 1.1.2.1     public ExactTemp(Quad q, Temp t) {
30 salcianu 1.1.2.1         this.q = q;
31 salcianu 1.1.2.1         this.t = t;
32 salcianu 1.1.2.1     }
33 salcianu 1.1.2.1 
34 salcianu 1.1.2.1     /** Checks the equality of two <code>ExactTemp</code>s. */
35 salcianu 1.1.2.1     public boolean equals(Object obj){
36 salcianu 1.1.2.1         if(obj == null) return false;
37 salcianu 1.1.2.1         
38 salcianu 1.1.2.1         ExactTemp et2 = (ExactTemp) obj;
39 salcianu 1.1.2.1         return q.equals(et2.q) && t.equals(et2.t);
40 salcianu 1.1.2.1     }
41 salcianu 1.1.2.1 
42 salcianu 1.1.2.2     // caching hack 
43 salcianu 1.1.2.1     private int hash = -1;
44 salcianu 1.1.2.1     public int hashCode(){
45 salcianu 1.1.2.1         if(hash == -1)
46 salcianu 1.1.2.1             hash = q.hashCode() + t.hashCode();
47 salcianu 1.1.2.1         return hash;
48 salcianu 1.1.2.1     }
49 salcianu 1.1.2.1 
50 salcianu 1.1.2.1     /** Pretty printer for debug. */
51 salcianu 1.1.2.1     public String toString(){
52 salcianu 1.1.2.2         return "< " + q.getSourceFile() + ":" + q.getLineNumber() +
53 salcianu 1.1.2.2             " " + q + " , " + t + " >"; 
54 salcianu 1.1.2.1     }
55 salcianu 1.1.2.1 
56 cananian 1.2     }