Skip to content

Commit

Permalink
Fixes on the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
stanhebben committed Jun 7, 2024
1 parent 055207f commit 9f602a5
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 == null || !method.compile) {
if (!method.compile) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.openzen.zenscript.codemodel.identifiers.instances.MethodInstance;
import org.openzen.zenscript.codemodel.type.TypeID;
import org.openzen.zenscript.javashared.*;
import org.openzen.zenscript.javashared.compiling.JavaCompilingMethod;

import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
Expand Down Expand Up @@ -134,6 +135,10 @@ public String getMapping(JavaClass class_) {
return method.getMapping(class_);
}

@Override
public JavaCompilingMethod asCompilingMethod(JavaClass compiled, String signature) {
return new JavaCompilingMethod(compiled, signature);
}

private Modifiers getMethodModifiers(Member method) {
Modifiers result = Modifiers.PUBLIC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.openzen.zenscript.codemodel.expression.Expression;
import org.openzen.zenscript.codemodel.type.TypeID;
import org.openzen.zenscript.codemodel.type.builtin.BuiltinMethodSymbol;
import org.openzen.zenscript.javashared.compiling.JavaCompilingMethod;

public class JavaBuiltinMethod implements JavaMethod {
private final BuiltinMethodSymbol method;
Expand Down Expand Up @@ -36,4 +37,9 @@ public <T> T compileSpecial(JavaMethodCompiler<T> compiler, TypeID returnType, E
public String getMapping(JavaClass class_) {
return class_.internalName + "::builtin::" + method.getID().toString();
}

@Override
public JavaCompilingMethod asCompilingMethod(JavaClass compiled, String signature) {
return new JavaCompilingMethod(compiled, signature);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.openzen.zenscript.codemodel.expression.CallArguments;
import org.openzen.zenscript.codemodel.expression.Expression;
import org.openzen.zenscript.codemodel.type.TypeID;
import org.openzen.zenscript.javashared.compiling.JavaCompilingMethod;

public interface JavaMethod {
<T> T compileConstructor(JavaMethodCompiler<T> compiler, TypeID type, CallArguments arguments);
Expand All @@ -11,4 +12,6 @@ public interface JavaMethod {
<T> T compileSpecial(JavaMethodCompiler<T> compiler, TypeID returnType, Expression target, CallArguments arguments);

String getMapping(JavaClass class_);

JavaCompilingMethod asCompilingMethod(JavaClass compiled, String signature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.openzen.zenscript.codemodel.expression.CallArguments;
import org.openzen.zenscript.codemodel.expression.Expression;
import org.openzen.zenscript.codemodel.type.TypeID;
import org.openzen.zenscript.javashared.compiling.JavaCompilingMethod;

import java.util.Arrays;

Expand Down Expand Up @@ -109,6 +110,11 @@ public String getMapping(JavaClass definition) {
return result.toString();
}

@Override
public JavaCompilingMethod asCompilingMethod(JavaClass compiled, String signature) {
return new JavaCompilingMethod(compiled, this, signature);
}

public boolean isAbstract() {
return (modifiers & JavaModifiers.ABSTRACT) > 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.openzen.zenscript.codemodel.expression.CallArguments;
import org.openzen.zenscript.codemodel.expression.Expression;
import org.openzen.zenscript.codemodel.type.TypeID;
import org.openzen.zenscript.javashared.compiling.JavaCompilingMethod;

public enum JavaSpecialMethod implements JavaMethod {
STRINGBUILDER_ISEMPTY,
Expand Down Expand Up @@ -42,4 +43,9 @@ public <T> T compileSpecial(JavaMethodCompiler<T> compiler, TypeID returnType, E
public String getMapping(JavaClass class_) {
return class_.internalName + "::special::" + name();
}

@Override
public JavaCompilingMethod asCompilingMethod(JavaClass compiled, String signature) {
return new JavaCompilingMethod(compiled, signature);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ public String visitBasic(BasicTypeID basic) {
return "Z";
case CHAR:
return "C";
case BYTE:
case SBYTE:
return "B";
case SHORT:
return "S";
case BYTE:
case USHORT:
case UINT:
case INT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public String visitBasic(BasicTypeID basic) {
return "Z";
case CHAR:
return "C";
case BYTE:
case SBYTE:
return "B";
case SHORT:
return "S";
case BYTE:
case USHORT:
case INT:
case UINT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ public void addMethod(MethodSymbol method, NativeTag native_) {
if (native_ != null && nativeClass != null) {
final String signature = getContext().getMethodSignature(method.getHeader());
JavaMethod method1 = nativeClass.getMethod(native_.value);
if(method1 instanceof JavaSpecialMethod) {
module.module.setMethodInfo(method, method1);
} else {
JavaNativeMethod javaMethod = (JavaNativeMethod) method1;
addMethod(method, new JavaCompilingMethod(compiled, javaMethod, signature));
}
addMethod(method, method1.asCompilingMethod(compiled, signature));
} else {
final JavaNativeMethod.Kind kind = getKind(method);
final String descriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ public JavaCompilingMethod(JavaClass class_, JavaNativeMethod compiled, String s
this.signature = signature;
this.compile = true;
}

public JavaCompilingMethod(JavaClass class_, String signature) {
this.class_ = class_;
this.compiled = null;
this.signature = signature;
this.compile = false;
}
}

0 comments on commit 9f602a5

Please sign in to comment.