forked from JavaTX/JavaCompilerCore
Runnable gefixt
This commit is contained in:
parent
c1532ece13
commit
99a7510810
@ -51,7 +51,7 @@ public class ClassGenerator extends ClassGen{
|
||||
* @param toTPH
|
||||
* @return Es gilt dann "toTPH extends Type"
|
||||
*/
|
||||
public org.apache.commons.bcel6.generic.Type getNearestType(TypePlaceholder toTPH){
|
||||
public org.apache.commons.bcel6.generic.Type getNearestNonTPHType(TypePlaceholder toTPH){
|
||||
Type t = resolveTPH(toTPH);
|
||||
if(t == null){
|
||||
return this.getInstructionFactory().createObjectType();
|
||||
|
@ -65,7 +65,7 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
||||
*/
|
||||
|
||||
String lambdaTypeParameterList = "()";
|
||||
ConstantMethodType lambdaMethodType1 = new ConstantMethodType(this.cp.addUtf8("()Ljava/lang/Object;")); //TODO: Hier den Grund finden, warum Object stehen muss.
|
||||
ConstantMethodType lambdaMethodType1 = new ConstantMethodType(this.cp.addUtf8(interfaceMethodType.getBytecodeInvokeDynamicSignatureUpperBound(cg))); //TODO: Hier den Grund finden, warum Object stehen muss.
|
||||
ConstantMethodType lambdaMethodType = new ConstantMethodType(this.cp.addUtf8(interfaceMethodType.getBytecodeInvokeDynamicSignature(cg)));
|
||||
int implMethodKind = 7; // 7 = InvokeSpecial @see https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-5.html#jvms-5.4.3.5
|
||||
ConstantMethodHandle implMethod = new ConstantMethodHandle(implMethodKind,cg.getConstantPool().addMethodref(lambdaMethod)); //Das zweite Argument ist der MethodRef zur LambdaMethode
|
||||
|
@ -247,7 +247,7 @@ public class LambdaExpression extends Expr{
|
||||
for(int i = 0; i < paramTypes.length ; i++) {
|
||||
if(paramTypes[i] instanceof TypePlaceholderType){
|
||||
//TODO: Das kann auch ein spezifischer Typ als Object sein
|
||||
paramTypesTemp[i] = cg.getNearestType(((TypePlaceholderType)paramTypes[i]).getTPH());
|
||||
paramTypesTemp[i] = cg.getNearestNonTPHType(((TypePlaceholderType)paramTypes[i]).getTPH());
|
||||
}else{
|
||||
paramTypesTemp[i] = paramTypes[i];
|
||||
}
|
||||
@ -256,7 +256,7 @@ public class LambdaExpression extends Expr{
|
||||
org.apache.commons.bcel6.generic.Type retType = method_body.getType().getBytecodeType(cg);
|
||||
if(retType instanceof TypePlaceholderType){
|
||||
//Die TypePlaceholderTypen aussortieren. Sie werden nur in der Signatur erwähnt. Kommen im Bytecode sonst eigentlich nicht vor
|
||||
retType = cg.getNearestType(((TypePlaceholderType) retType).getTPH());
|
||||
retType = cg.getNearestNonTPHType(((TypePlaceholderType) retType).getTPH());
|
||||
}
|
||||
MethodGenerator lambdaMethod = new MethodGenerator(0, retType,
|
||||
paramTypes, params.getParameterNameArray(), cg.createLambdaMethodName(),
|
||||
|
@ -126,6 +126,16 @@ public class FunN extends RefType {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getBytecodeInvokeDynamicSignatureUpperBound(ClassGenerator cg) {
|
||||
String ret = "(";
|
||||
for(Type t : T){
|
||||
ret+=cg.getInstructionFactory().createObjectType().getSignature();
|
||||
}
|
||||
ret +=")";
|
||||
ret += cg.getInstructionFactory().createObjectType().getSignature();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public CMethodTypeAssumption toCMethodTypeAssumption() {
|
||||
|
@ -454,7 +454,7 @@ public class TypePlaceholder extends ObjectType
|
||||
//Die Signaturen in der Klasse bauen sich für Generische Variabeln (also TPHs) folgendermaßen auf: "GVAR:SuperClass"
|
||||
String ret = this.getBytecodeMethodSignature(cg);
|
||||
ret = ret.substring(0, ret.length()-1) + ":"; //";" mit ":" ersetzen
|
||||
org.apache.commons.bcel6.generic.Type nearestType = cg.getNearestType(this);
|
||||
org.apache.commons.bcel6.generic.Type nearestType = cg.getNearestNonTPHType(this);
|
||||
if(nearestType instanceof TypePlaceholderType){ //Handelt es sich um einen weiteren TPH als nächsten Typ, so ist es ein allgemeiner Typ und wir nehmen Object als Superklasse
|
||||
ret += cg.getInstructionFactory().createObjectType().getSignature();
|
||||
}else{
|
||||
|
@ -10,6 +10,6 @@ public static void main(String[] args){
|
||||
System.out.println(new FieldDeclaration().field);
|
||||
System.out.println(new Runnable().method().apply());
|
||||
Runnable r = new Runnable().method().apply();
|
||||
//Test t = new Identity().op.apply(this);
|
||||
Test t = new Identity<Test,Test>().op.apply(this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user