Verbesserung der Generierung von FunN-Typen.

Lambda Expressions noch fehlerhaft.
This commit is contained in:
Etienne Zink 2022-03-24 10:38:12 +01:00
parent 15c05e5cba
commit bcf56e6bdd
4 changed files with 13 additions and 3 deletions

View File

@ -592,11 +592,12 @@ public class BytecodeGenMethod implements StatementVisitor {
public void visit(LambdaExpression lambdaExpression) { public void visit(LambdaExpression lambdaExpression) {
this.lamCounter++; this.lamCounter++;
//ToDo Etienne: umbauen
String typeErasure = createDescriptorWithTypeErasure(lambdaExpression); String typeErasure = createDescriptorWithTypeErasure(lambdaExpression);
ByteCodeForFunNGenerator.generateBCForFunN(lambdaExpression, typeErasure,path); ByteCodeForFunNGenerator.generateBCForFunN(lambdaExpression, typeErasure,path);
//ToDo Etienne: umbauen
Lambda lam = new Lambda(lambdaExpression); Lambda lam = new Lambda(lambdaExpression);
String lamDesc = lam.accept(new DescriptorToString(resultSet)); String lamDesc = lam.accept(new DescriptorToString(resultSet));
// Call site, which, when invoked, returns an instance of the functional // Call site, which, when invoked, returns an instance of the functional
@ -822,7 +823,7 @@ public class BytecodeGenMethod implements StatementVisitor {
//helper.generateBCForFunN(mDesc); //helper.generateBCForFunN(mDesc);
FunN f; FunN f;
ASTToIntermediate converter = new ASTToIntermediate(); ASTToIntermediate converter = new ASTToIntermediate();
IntermediateInnerType returnType = (IntermediateInnerType) converter.convert(methodCall.receiver.getType()); IntermediateInnerType returnType = (IntermediateInnerType) converter.convert(resolver.resolve(methodCall.receiver.getType()));
if(methodCall if(methodCall
.arglist .arglist
.getArguments().size() > 0){ .getArguments().size() > 0){
@ -831,6 +832,7 @@ public class BytecodeGenMethod implements StatementVisitor {
.getArguments() .getArguments()
.stream() .stream()
.map(TypableStatement::getType) .map(TypableStatement::getType)
.map(resolver::resolve)
.map(converter::convert) .map(converter::convert)
.filter(t -> t instanceof IntermediateInnerType) .filter(t -> t instanceof IntermediateInnerType)
.map(t -> (IntermediateInnerType) t) .map(t -> (IntermediateInnerType) t)

View File

@ -153,6 +153,7 @@ public class DescriptorToString implements DescriptorVisitor, CONSTANTS {
return desc; return desc;
} }
//ToDo Etienne: ändern
@Override @Override
public String visit(Lambda lambdaExpression) { public String visit(Lambda lambdaExpression) {
String desc = "("; String desc = "(";

View File

@ -25,4 +25,9 @@ public class Resolver {
public String getResolvedType(RefTypeOrTPHOrWildcardOrGeneric type) { public String getResolvedType(RefTypeOrTPHOrWildcardOrGeneric type) {
return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor()); return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor());
} }
//ToDo Etienne: Check ob benötigt
public RefTypeOrTPHOrWildcardOrGeneric resolve(RefTypeOrTPHOrWildcardOrGeneric type) {
return resultSet.resolveType(type).resolvedType;
}
} }

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.intermediate.convert; package de.dhbwstuttgart.intermediate.convert;
import de.dhbwstuttgart.bytecode.utilities.Resolver;
import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.intermediate.generation.FunN; import de.dhbwstuttgart.intermediate.generation.FunN;
import de.dhbwstuttgart.intermediate.types.*; import de.dhbwstuttgart.intermediate.types.*;
@ -18,6 +19,7 @@ public class ASTToIntermediate {
System.out.println(originalType.getParaList().size()); System.out.println(originalType.getParaList().size());
if (originalType.getName().toString().matches("Fun\\d+\\$\\$")){ if (originalType.getName().toString().matches("Fun\\d+\\$\\$")){
if(originalType.getParaList().size() == 0) throw new RuntimeException("Incorrect FunN Type: No params are defined!");
ASTToIntermediate converter = new ASTToIntermediate(); ASTToIntermediate converter = new ASTToIntermediate();
List<RefTypeOrTPHOrWildcardOrGeneric> parameters = originalType.getParaList(); List<RefTypeOrTPHOrWildcardOrGeneric> parameters = originalType.getParaList();
IntermediateInnerType returnType = (IntermediateInnerType) convert(parameters.get(parameters.size() - 1)); IntermediateInnerType returnType = (IntermediateInnerType) convert(parameters.get(parameters.size() - 1));