-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTTAddr.java
More file actions
45 lines (35 loc) · 1.09 KB
/
Copy pathASTTAddr.java
File metadata and controls
45 lines (35 loc) · 1.09 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
import java.util.Set;
public class ASTTAddr implements ASTType {
private final ASTType type;
private final int depth;
public ASTTAddr(ASTType _type, int _depth) {
this.type = _type;
this.depth = _depth;
}
public ASTType getType() {
return type;
}
public int getDepth() {
return depth;
}
@Override
public String toStr() {
return "addr("+type.toStr()+")";
}
@Override
public boolean eqt(ASTType t) {
if (!(t instanceof ASTTAddr other))
return false;
return type.eqt(other.getType());
}
@Override
public boolean subtypeOf(ASTType t, Environment<ASTType> e, Set<String> seen) throws InterpreterError {
t = ASTTypeDef.unfold(t, e);
if (!(t instanceof ASTTAddr other))
return false;
ASTType thisInner = ASTTypeDef.unfold(this.type, e);
ASTType otherInner = ASTTypeDef.unfold(other.getType(), e);
// A<:>B
return thisInner.subtypeOf(otherInner, e, seen) && otherInner.subtypeOf(thisInner, e, seen);
}
}