|
@@ -5,42 +5,30 @@
|
5
|
5
|
*/
|
6
|
6
|
package org.openzen.zencode.java;
|
7
|
7
|
|
8
|
|
-import org.openzen.zencode.shared.CodePosition;
|
9
|
|
-import org.openzen.zencode.shared.CompileException;
|
10
|
|
-import org.openzen.zencode.shared.LiteralSourceFile;
|
|
8
|
+import org.openzen.zencode.shared.*;
|
11
|
9
|
import org.openzen.zenscript.codemodel.*;
|
12
|
|
-import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
|
13
|
|
-import org.openzen.zenscript.codemodel.annotations.DefinitionAnnotation;
|
14
|
|
-import org.openzen.zenscript.codemodel.annotations.NativeDefinitionAnnotation;
|
15
|
|
-import org.openzen.zenscript.codemodel.context.CompilingPackage;
|
16
|
|
-import org.openzen.zenscript.codemodel.context.FileResolutionContext;
|
17
|
|
-import org.openzen.zenscript.codemodel.context.ModuleTypeResolutionContext;
|
|
10
|
+import org.openzen.zenscript.codemodel.annotations.*;
|
|
11
|
+import org.openzen.zenscript.codemodel.context.*;
|
18
|
12
|
import org.openzen.zenscript.codemodel.definition.*;
|
19
|
13
|
import org.openzen.zenscript.codemodel.expression.*;
|
20
|
|
-import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
|
21
|
|
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
|
|
14
|
+import org.openzen.zenscript.codemodel.generic.*;
|
22
|
15
|
import org.openzen.zenscript.codemodel.member.*;
|
23
|
|
-import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
|
24
|
|
-import org.openzen.zenscript.codemodel.partial.PartialStaticMemberGroupExpression;
|
25
|
|
-import org.openzen.zenscript.codemodel.scope.ExpressionScope;
|
26
|
|
-import org.openzen.zenscript.codemodel.scope.FileScope;
|
|
16
|
+import org.openzen.zenscript.codemodel.member.ref.*;
|
|
17
|
+import org.openzen.zenscript.codemodel.partial.*;
|
|
18
|
+import org.openzen.zenscript.codemodel.scope.*;
|
27
|
19
|
import org.openzen.zenscript.codemodel.type.*;
|
28
|
|
-import org.openzen.zenscript.codemodel.type.member.BuiltinID;
|
29
|
|
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
|
30
|
|
-import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
|
31
|
|
-import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
|
32
|
|
-import org.openzen.zenscript.codemodel.type.storage.StorageTag;
|
33
|
|
-import org.openzen.zenscript.codemodel.type.storage.StorageType;
|
|
20
|
+import org.openzen.zenscript.codemodel.type.member.*;
|
|
21
|
+import org.openzen.zenscript.codemodel.type.storage.*;
|
34
|
22
|
import org.openzen.zenscript.javashared.*;
|
35
|
|
-import org.openzen.zenscript.lexer.ParseException;
|
36
|
|
-import org.openzen.zenscript.lexer.ZSTokenParser;
|
37
|
|
-import org.openzen.zenscript.parser.BracketExpressionParser;
|
38
|
|
-import org.openzen.zenscript.parser.expression.ParsedExpression;
|
39
|
|
-import org.openzen.zenscript.parser.type.IParsedType;
|
40
|
|
-import stdlib.Strings;
|
41
|
|
-
|
42
|
|
-import java.io.IOException;
|
|
23
|
+import org.openzen.zenscript.lexer.*;
|
|
24
|
+import org.openzen.zenscript.parser.*;
|
|
25
|
+import org.openzen.zenscript.parser.expression.*;
|
|
26
|
+import org.openzen.zenscript.parser.type.*;
|
|
27
|
+import stdlib.*;
|
|
28
|
+
|
|
29
|
+import java.io.*;
|
43
|
30
|
import java.lang.reflect.*;
|
|
31
|
+import java.util.Arrays;
|
44
|
32
|
import java.util.*;
|
45
|
33
|
|
46
|
34
|
|
|
@@ -852,14 +840,21 @@ public class JavaNativeModule {
|
852
|
840
|
}
|
853
|
841
|
|
854
|
842
|
FunctionParameter[] parameters = new FunctionParameter[javaParameters.length];
|
|
843
|
+ int classParameters = 0;
|
855
|
844
|
for (int i = 0; i < parameters.length; i++) {
|
856
|
845
|
Parameter parameter = javaParameters[i];
|
|
846
|
+ if(parameter.getType().getCanonicalName().contentEquals("java.lang.Class")) {
|
|
847
|
+ classParameters++;
|
|
848
|
+ }
|
857
|
849
|
|
858
|
850
|
//AnnotatedType parameterType = parameter.getAnnotatedType();
|
859
|
851
|
StoredType type = loadStoredType(context, parameter);
|
860
|
852
|
Expression defaultValue = getDefaultValue(parameter, type);
|
861
|
853
|
parameters[i] = new FunctionParameter(type, parameter.getName(), defaultValue, parameter.isVarArgs());
|
862
|
854
|
}
|
|
855
|
+ if(classParameters > 0 && classParameters == typeParameters.length) {
|
|
856
|
+ parameters = Arrays.copyOfRange(parameters, classParameters, parameters.length);
|
|
857
|
+ }
|
863
|
858
|
|
864
|
859
|
if (exceptionTypes.length > 1)
|
865
|
860
|
throw new IllegalArgumentException("A method can only throw a single exception type!");
|
|
@@ -1110,8 +1105,14 @@ public class JavaNativeModule {
|
1110
|
1105
|
kind = JavaMethod.Kind.STATIC;
|
1111
|
1106
|
else
|
1112
|
1107
|
kind = JavaMethod.Kind.INSTANCE;
|
1113
|
|
-
|
1114
|
|
- return new JavaMethod(cls, kind, method.getName(), false, getMethodDescriptor(method), method.getModifiers(), result.isGeneric());
|
|
1108
|
+
|
|
1109
|
+ final int length = method.getTypeParameters().length;
|
|
1110
|
+ boolean compile = length > 0 && length == Arrays.stream(method.getParameterTypes())
|
|
1111
|
+ .filter(s -> s.getCanonicalName().contentEquals("java.lang.Class"))
|
|
1112
|
+ .count();
|
|
1113
|
+
|
|
1114
|
+ return new JavaMethod(cls, kind, method.getName(), compile, getMethodDescriptor(method), method
|
|
1115
|
+ .getModifiers(), result.isGeneric());
|
1115
|
1116
|
}
|
1116
|
1117
|
|
1117
|
1118
|
public void registerBEP(BracketExpressionParser bep) {
|