Merge branch 'targetBytecode' into unif23

This commit is contained in:
pl@gohorb.ba-horb.de 2023-03-21 16:29:14 +01:00
commit 29b05b56cc
3 changed files with 15 additions and 6 deletions

7
Test.java Normal file
View File

@ -0,0 +1,7 @@
public interface Test<A, B> extends Base<A, B> {
}
interface Base<A, B> {
}

View File

@ -1025,6 +1025,8 @@ public class Codegen {
if (!method.txGenerics().isEmpty())
mv.visitAttribute(new JavaTXSignatureAttribute(method.getTXSignature()));
System.out.println(method.getDescriptor());
System.out.println(method.getSignature());
mv.visitCode();
var state = new State(method.returnType(), mv, method.isStatic() ? 0 : 1);
for (var param: method.parameters())

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.target.tree.TargetGeneric;
import de.dhbwstuttgart.target.tree.type.TargetGenericType;
import de.dhbwstuttgart.target.tree.type.TargetRefType;
import de.dhbwstuttgart.target.tree.type.TargetType;
@ -39,12 +40,12 @@ public class FunNGenerator {
StringBuilder superFunNMethodDescriptor = new StringBuilder("(");
for (int currentParameter = 1; currentParameter <= numberArguments; currentParameter++){
superFunNClassSignature.append(String.format("%s%d:%s",argumentGenericBase, currentParameter, objectSignature));
superFunNMethodSignature.append(String.format("%s", applySignature(new TargetRefType(argumentGenericBase + currentParameter))));
superFunNClassSignature.append(String.format("%s%d:%s", argumentGenericBase, currentParameter, objectSignature));
superFunNMethodSignature.append(String.format("T%s;", argumentGenericBase + currentParameter));
superFunNMethodDescriptor.append(objectSignature);
}
superFunNClassSignature.append(String.format("%s:%s>%s", returnGeneric, objectSignature, objectSignature));
superFunNMethodSignature.append(String.format(")%s", applySignature(new TargetRefType(returnGeneric))));
superFunNMethodSignature.append(String.format(")T%s;", returnGeneric));
superFunNMethodDescriptor.append(String.format(")%s", objectSignature));
System.out.println(superFunNMethodSignature);
@ -66,7 +67,7 @@ public class FunNGenerator {
List<TargetType> parameters = Stream
.concat(argumentTypes.stream(), Stream.of(returnType))
.collect(Collectors.toList());
StringBuilder funNClassSignature = new StringBuilder(objectSignature + applySignature(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters)));
StringBuilder funNClassSignature = new StringBuilder(objectSignature + applyDescriptor(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters)));
boolean containsGeneric = false;
String genericSignature = "<";
@ -74,13 +75,12 @@ public class FunNGenerator {
//ToDo Etienne: Refactor
if (typeArgument instanceof TargetGenericType generic){
//if(genericSignature.contains(generic.name())) continue;
genericSignature += String.format("%s:%s", generic.name(), applyDescriptor(generic));
genericSignature += String.format("%s:%s", generic.name(), objectSignature);
containsGeneric = true;
}
}
genericSignature += ">";
if (containsGeneric) funNClassSignature.insert(0, genericSignature);
System.out.println(funNClassSignature.toString());
ClassWriter classWriter = new ClassWriter(0);
classWriter.visit(bytecodeVersion, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, getSpecializedClassName(argumentTypes, returnType), funNClassSignature.toString(), objectSuperType, new String[]{getSuperClassName(argumentTypes.size())});