-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBind.java
More file actions
85 lines (70 loc) · 1.66 KB
/
Copy pathBind.java
File metadata and controls
85 lines (70 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package data;
import syntaxtree.Identifier;
public class Bind implements Addr{
private Identifier var;
private Contour time;
public Bind(Identifier v, Contour t){
var = v;
time = t;
}
public Identifier getVar(){
return var;
}
public Contour getContour(){
return time;
}
public int hashCode(){
final int PRIME = 31;
int result = 1;
result = PRIME * result + ( (var == null) ? 0 : var.hashCode());
result = PRIME * result + ( (time == null) ? 0 : time.hashCode());
return result;
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null) return false;
if (getClass() != o.getClass()){
return false;
}
Bind bind = (Bind) o;
if ( var == null){
if(bind.getVar() == null){
return time.equals(bind.getContour());
}
return false;
}
if (!var.equals(bind.getVar())){
return false;
}
if (time == null){
if (bind.getClass() == null) return true;
return false;
}
return time.equals(bind.getContour());
}
public int compareTo(Addr addr){
int classCompare = getClass().getName().compareTo(addr.getClass().getName());
if (classCompare != 0 ){
return classCompare;
}
Bind b = (Bind) addr;
int cvar = var.compareTo(b.getVar());
System.out.println(cvar);
if (cvar != 0){
return cvar;
}
return time.compareTo(b.getContour());
}
public String toString(){
return "(" + var + ", " + time.toString() + ")";
}
public static void main(String argv[]){
Contour c = new Contour();
c = c.tick(2, 1);
Bind b1 = new Bind(new Identifier("x"),c);
Bind b2 = new Bind(new Identifier("x"),c);
Addr a1 = b1;
Addr a2 = b2;
System.out.println(a1.equals(a2));
}
}