ToDos an wichtigen Stellen zu Betrachtung angebracht.

This commit is contained in:
Etienne Zink 2022-01-15 20:01:41 +01:00
parent 0aab2d9f53
commit 7eaddd67a3
8 changed files with 16 additions and 1 deletions

View File

@ -584,6 +584,7 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
//ToDo Etienne: Für Type Erasure relevant?!
@Override
public void visit(LambdaExpression lambdaExpression) {
this.lamCounter++;
@ -653,6 +654,7 @@ public class BytecodeGenMethod implements StatementVisitor {
// generateBCForFunN(lambdaExpression, typeErasure);
}
//ToDo Etienne: Relevant?!
private String addUsedVarsToDesugaredMethodDescriptor(String lamDesc) {
String newDesc = "(";
int pos = 0;
@ -674,6 +676,7 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
//ToDo Etienne: Relevant?!
private String createDescriptorWithTypeErasure(LambdaExpression lambdaExpression) {
String typeErasure = "(";
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
@ -811,6 +814,7 @@ public class BytecodeGenMethod implements StatementVisitor {
} catch (NotInCurrentPackageException | NotFoundException e) {
e.printStackTrace();
}
//ToDo Etienne: Für Type Erasure wichtig?!
} else if(!helper.isInCurrPkg(clazz)){
if(clazz.contains(CONSTANTS.$$)) {
mDesc = helper.getDescriptorOfApplyMethod(methCallType);
@ -899,6 +903,7 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
//ToDo Etienne: Für Type Erasure wichtig?!
private void visitInvokeInsn(MethodCall methodCall, String receiverName, java.lang.reflect.Method methodRefl, String clazz, String mDesc, String receiverRefl) {
// is methodCall.receiver functional Interface)?
if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface")) ||

View File

@ -207,7 +207,7 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
String desc = "(";
for(Expression e : methodFromMethodCall.getArgList().getArguments()) {
String d = resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor());
//ToDo Etienne: Ändern von $$ nötig für TypeErasure?
if(d.contains(CONSTANTS.TPH) ||d.contains(CONSTANTS.ANGLEBRACKET) || methodFromMethodCall.getReceiverName().contains("$$")) {
desc += "L"+Type.getInternalName(Object.class)+ ";";
}else {
@ -225,6 +225,7 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
System.out.println("DescriptorToString retType = " + retType);
if(retType.equals(CONSTANTS.VOID)) {
desc += ")V";
//ToDo Etienne: Ändern von $$ nötig für TypeErasure?
}else if(retType.contains(CONSTANTS.TPH)|| retType.contains(CONSTANTS.ANGLEBRACKET) || methodFromMethodCall.getReceiverName().contains("$$")){
desc += ")L"+Type.getInternalName(Object.class)+ ";";
}else {
@ -240,6 +241,7 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
return desc;
}
//ToDo Etienne: Ändern für TypeErasure
@Override
public String createDescForFunN(ArgumentList argumentList, String returnType) {
Iterator<Expression> itr1 = argumentList.getArguments().iterator();

View File

@ -11,7 +11,9 @@ public interface DescriptorVisitor {
String visit(NormalMethod method);
String visit(NormalConstructor constructor);
String visit(Lambda lambdaExpression);
//ToDo Etienne: Was ist SamMethod?
String visit(SamMethod samMethod);
//ToDo Etienne: Was ist MethodFromMethodCall?
String visit(MethodFromMethodCall methodFromMethodCall);
String createDescForFunN(ArgumentList argumentList, String returnType);
}

View File

@ -136,6 +136,7 @@ public class Signature {
defineGenericsFromConstraints(constraints,genericsAndBoundsMethod);
}
//ToDo Etienne: für TypeErasure anschauen
private void createSignatureForFunN(int numberOfParams, String to, String[] paramTypes) {
defineTypeVariablesForParametersOfFunN(numberOfParams);
@ -147,6 +148,7 @@ public class Signature {
}
//ToDo Etienne: für TypeErasure anschauen
private void createSignatureForFunN(int numberOfParams) {
defineTypeVariablesForParametersOfFunN(numberOfParams);

View File

@ -18,6 +18,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
//ToDo Etienne: Anpassung für TypeErasure
public class ByteCodeForFunNGenerator {
public static void generateBCForFunN(LambdaExpression lambdaExpression, String methDesc, File path) {

View File

@ -220,6 +220,7 @@ public class MethodCallHelper {
}
}
//ToDo Etienne: Für Type Erasure wichtig?!
public void generateBCForFunN(String methodDescriptor) {
ByteCodeForFunNGenerator.generateBCForFunN(methCall.arglist,methodDescriptor,path);
}

View File

@ -884,6 +884,7 @@ public class JavaTXCompiler {
return result;
}
//ToDo Etienne: Für Type Erasure wichtig?! (alle generatedBytecode-Methoden?)
public void generateBytecode() throws ClassNotFoundException, IOException, BytecodeGeneratorError {
generateBytecode((File) null);
}

View File

@ -9,6 +9,7 @@ import org.antlr.v4.runtime.Token;
*
*/
//ToDo Etienne: Wieso abstrakte Klasse? -> Dadurch keine Inferenz mit ? möglich!
public abstract class WildcardType extends RefTypeOrTPHOrWildcardOrGeneric {
protected RefTypeOrTPHOrWildcardOrGeneric innerType = null;