Skip to content
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

Merged
merged 14 commits into from
Jun 7, 2024

Conversation

kindlich
Copy link
Member

In correlation with: ZenCodeLang/StdLibs#5

Some minor fixes and added some tests that show things currently broken but needed by stdlibs

@kindlich kindlich force-pushed the feature/refactor-get-stdlib-to-compile branch from 714ec7e to f686dcd Compare June 1, 2024 19:46
@@ -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) {
Copy link
Member Author

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);
Copy link
Member Author

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);

@kindlich kindlich added the CraftTweaker All Issues that are needed by CraftTweaker label Jun 2, 2024
@kindlich kindlich added this to the Refactor milestone Jun 2, 2024
@stanhebben stanhebben merged commit 7dcdf88 into feature/refactor Jun 7, 2024
0 of 2 checks passed
@stanhebben stanhebben deleted the feature/refactor-get-stdlib-to-compile branch June 21, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CraftTweaker All Issues that are needed by CraftTweaker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants