-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP to get stdlib to compile #139
WIP to get stdlib to compile #139
Conversation
The array here starts with the expanded type whereas the logic expects it to start at the first argument
714ec7e
to
f686dcd
Compare
...er/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaMethodBytecodeCompiler.java
Show resolved
Hide resolved
@@ -70,7 +70,7 @@ public Void visitConstructor(ConstructorMember member) { | |||
public Void visitMethod(MethodMember member) { | |||
final boolean isStatic = member.isStatic(); | |||
final JavaCompilingMethod method = class_.getMethod(member); | |||
if (!method.compile) { | |||
if (method == null || !method.compile) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This null
-check "shouldn't" be necessary.
We have this as null, when there is a [Native(...)]
annotation added to a method but no matching definition has been added to the JavaNativeClass.
Now the question would be if that was an error case (in which case we wouldn't need the null-check here but rather catch the error before) or whether that's an intended scenario, in which case we'd need to check if this null-check is enough or whether we should move that elsewhere?
@@ -120,8 +120,13 @@ public void addMethod(MethodSymbol method, NativeTag native_) { | |||
|
|||
if (native_ != null && nativeClass != null) { | |||
final String signature = getContext().getMethodSignature(method.getHeader()); | |||
JavaNativeMethod javaMethod = (JavaNativeMethod) nativeClass.getMethod(native_.value); | |||
addMethod(method, new JavaCompilingMethod(compiled, javaMethod, signature)); | |||
JavaMethod method1 = nativeClass.getMethod(native_.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Question: We have JavaNativeMethod and JavaSpecialMethod, which one is used when?
This cast failed before for the COLLECTION_TO_ARRAY
special method, since SpecialMethod is not instanceof JavaNativeMethod.
# List.zs
[Native("toArray")]
public implicit as T[];
//JavaPrepareDefinitionVisitor.java
JavaNativeClass list = new JavaNativeClass(new JavaClass("java.util", "List", JavaClass.Kind.INTERFACE));
list.addMethod("toArray", JavaSpecialMethod.COLLECTION_TO_ARRAY);
...a/org/openzen/zenscript/scriptingexample/tests/actual_test/arrays/ArraysWithStdLibTests.java
Show resolved
Hide resolved
(Even if they're funky)
In correlation with: ZenCodeLang/StdLibs#5
Some minor fixes and added some tests that show things currently broken but needed by stdlibs