-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiConstructorVirtual.java
41 lines (32 loc) · 1.31 KB
/
iConstructorVirtual.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
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.ConstructorDeclaration;
public class iConstructorVirtual extends iConstructor {
ConstructorDeclaration x;
public iConstructorVirtual(Scope parent, ConstructorDeclaration x) {
super(parent, x);
this.x = x;
}
public boolean isVarArgs() {
return x.getParameters().getLast().map(p -> p.isVarArgs()).orElse(false);
}
public int getParameterCount() {
return x.getParameters().size();
}
@Override
public iClass[] getParameterTypes() {
throw new UnsupportedOperationException();
// return x.getParameters().stream().map(p -> new
// iClassVirtual(scope)).toArray(iClass[]::new);
}
public iObject newInstance(iObject... args) throws Throwable {
iObjectVirtual i = new iObjectVirtual(getScope(), new iClassVirtual(getScope(), getDeclaringClassNode()));
getScope().getExecutor().exec(x, i, args);
return i;
}
public iClass getDeclaringClass() {
return new iClassVirtual(getScope(), getDeclaringClassNode());
}
public ClassOrInterfaceDeclaration getDeclaringClassNode() {
return (ClassOrInterfaceDeclaration) x.getParentNode().get();
}
}