forked from JavaTX/JavaCompilerCore
Verbesserung der Methode generateSuperFunNInterface in ByteCodeForFunNGenerator und Kommentare.
This commit is contained in:
parent
59d50bd2c6
commit
ac6980b5e0
@ -99,22 +99,22 @@ public class ByteCodeForFunNGenerator {
|
|||||||
*/
|
*/
|
||||||
public static boolean generateSuperFunNInterface(int numberOfParameters, File path){
|
public static boolean generateSuperFunNInterface(int numberOfParameters, File path){
|
||||||
if(alreadyGeneratedFunN.contains(numberOfParameters)) return true;
|
if(alreadyGeneratedFunN.contains(numberOfParameters)) return true;
|
||||||
//ToDo Etienne: Generierung der Signaturen/Deskriptoren vielleicht auslagern?
|
//ToDo Etienne: Generierung der Signaturen/Deskriptoren vielleicht auslagern? Bzw. schauen ob nicht schon vorhanden und anpassen!
|
||||||
String className = String.format("Fun%d$$", numberOfParameters);
|
String className = String.format("Fun%d$$", numberOfParameters);
|
||||||
String classSignature = "<";
|
String classSignature = "<";
|
||||||
String methodSignature = "(";
|
String methodSignature = "(";
|
||||||
String methodDescriptor = "(";
|
String methodDescriptor = "(";
|
||||||
for (int parameter = 1; parameter <= numberOfParameters; parameter++) {
|
for (int parameter = 1; parameter <= numberOfParameters; parameter++) {
|
||||||
classSignature += String.format("T%d:Ljava/lang/Object;", parameter);
|
classSignature += String.format("T%d:L%s;", parameter, Type.getInternalName(Object.class));
|
||||||
methodSignature += String.format("TT%d;", parameter);
|
methodSignature += String.format("TT%d;", parameter);
|
||||||
methodDescriptor += "Ljava/lang/Object;";
|
methodDescriptor += String.format("L%s;", Type.getInternalName(Object.class));
|
||||||
}
|
}
|
||||||
classSignature += "R:Ljava/lang/Object;>Ljava/lang/Object;";
|
classSignature += String.format("R:L%s;>L%s;",Type.getInternalName(Object.class),Type.getInternalName(Object.class));
|
||||||
methodSignature += ")TR;";
|
methodSignature += ")TR;";
|
||||||
methodDescriptor += ")Ljava/lang/Object;";
|
methodDescriptor += String.format(")L%s;",Type.getInternalName(Object.class));
|
||||||
|
|
||||||
ClassWriter classWriter = new ClassWriter(0);
|
ClassWriter classWriter = new ClassWriter(0);
|
||||||
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, className, classSignature, "java/lang/Object", null);
|
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, className, classSignature, Type.getInternalName(Object.class), null);
|
||||||
|
|
||||||
MethodVisitor methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "apply", methodDescriptor, methodSignature, null);
|
MethodVisitor methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_ABSTRACT, "apply", methodDescriptor, methodSignature, null);
|
||||||
methodVisitor.visitEnd();
|
methodVisitor.visitEnd();
|
||||||
|
@ -225,6 +225,7 @@ public class MethodCallHelper {
|
|||||||
ByteCodeForFunNGenerator.generateBCForFunN(methCall.arglist,methodDescriptor,path);
|
ByteCodeForFunNGenerator.generateBCForFunN(methCall.arglist,methodDescriptor,path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ToDo Etienne: Für Type Erasure wichtig
|
||||||
public String getDescriptorOfApplyMethod(String methodCallType) {
|
public String getDescriptorOfApplyMethod(String methodCallType) {
|
||||||
return new DescriptorToString().createDescForFunN(methCall.arglist, methodCallType);
|
return new DescriptorToString().createDescForFunN(methCall.arglist, methodCallType);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user