-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiObject.java
48 lines (39 loc) · 1.19 KB
/
iObject.java
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
import com.github.javaparser.ast.Node;
public abstract class iObject {
Scope current_scope;
public iObject(Scope parent, Node node) {
this.current_scope = parent.getChild(node);
}
public Scope getScope() {
return current_scope;
}
public iClass asClass() throws Throwable {
return (iClass) this;
}
public iField asField() throws Throwable {
return (iField) this;
}
public iObjectWrapped asWrapped() {
return (iObjectWrapped) this;
}
public iObjectVariable asVariable() {
return (iObjectVariable) this;
}
public iClass getClazz() {
throw new UnsupportedOperationException();
}
public iObject asExecArg() {
try {
if (this instanceof iField)
return asField().get(null);
else if (this instanceof iClass)
return new iObjectWrapped(getScope(), null);
else if (this instanceof iObjectVariable)
return asVariable().get();
else
return this;
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
}