-
Notifications
You must be signed in to change notification settings - Fork 0
/
iClassVirtual.java
71 lines (56 loc) · 2.34 KB
/
iClassVirtual.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.stream.Stream;
import com.github.javaparser.ast.Modifier;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
public class iClassVirtual extends iClass {
ClassOrInterfaceDeclaration x;
public iClassVirtual(Scope parent, ClassOrInterfaceDeclaration x) {
super(parent, x);
this.x = x;
getScope().setClz(this);
if (x.getConstructors().size() == 0) {
x.addConstructor(Modifier.Keyword.PUBLIC);
}
}
public String getName() {
return x.getNameAsString();
}
@Override
public iObject cast(iObject obj) {
throw new UnsupportedOperationException();
}
public boolean isAssignableFrom(iClass cls) {
throw new UnsupportedOperationException();
}
public iClass getComponentType() {
throw new UnsupportedOperationException();
}
public iField getField(String name) throws Throwable {
throw new UnsupportedOperationException();
}
public iMethod getMethod(String name, iClass... parameterTypes) throws Throwable {
return x.getMethodsByName(name)// Signature(name, Stream.of(parameterTypes).map(c ->
// c.getName()).toArray(String[]::new))
.stream().map(m -> new iMethodVirtual(getScope(), m)).findAny().orElseThrow(NoSuchMethodException::new);
}
public iMethod[] getMethods() {
throw new UnsupportedOperationException();
}
public iConstructor getConstructor(iClass... parameterTypes) throws Throwable {
return new iConstructorVirtual(getScope(),
x.getConstructorByParameterTypes(Stream.of(parameterTypes).map(x -> x.getName()).toArray(String[]::new))
.orElseThrow(NoSuchMethodException::new));
}
public iConstructor[] getConstructors() {
return x.getConstructors().stream().map(c -> new iConstructorVirtual(getScope(), c))
.toArray(iConstructor[]::new);
}
public iObject newArray(int[] dimensions) {
throw new UnsupportedOperationException();
}
public void setItem(iObject a, int i, iObject v) {
throw new UnsupportedOperationException();
}
public iObject getItem(iObject a, int i) {
throw new UnsupportedOperationException();
}
}