Verbesserung der Konvertierung und der Bytecodegenerierung für FunN Typen.
Beinhaltet noch Fehler!
This commit is contained in:
parent
dc9a54be3b
commit
15c05e5cba
@ -820,16 +820,26 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
mDesc = helper.getDescriptorOfApplyMethod(methCallType);
|
mDesc = helper.getDescriptorOfApplyMethod(methCallType);
|
||||||
//ToDo Etienne: check if it works
|
//ToDo Etienne: check if it works
|
||||||
//helper.generateBCForFunN(mDesc);
|
//helper.generateBCForFunN(mDesc);
|
||||||
|
FunN f;
|
||||||
ASTToIntermediate converter = new ASTToIntermediate();
|
ASTToIntermediate converter = new ASTToIntermediate();
|
||||||
IntermediateInnerType returnType = converter.convert(methodCall.receiver.getType());
|
IntermediateInnerType returnType = (IntermediateInnerType) converter.convert(methodCall.receiver.getType());
|
||||||
|
if(methodCall
|
||||||
|
.arglist
|
||||||
|
.getArguments().size() > 0){
|
||||||
List<IntermediateInnerType> arguments = methodCall
|
List<IntermediateInnerType> arguments = methodCall
|
||||||
.arglist
|
.arglist
|
||||||
.getArguments()
|
.getArguments()
|
||||||
.stream()
|
.stream()
|
||||||
.map(TypableStatement::getType)
|
.map(TypableStatement::getType)
|
||||||
.map(converter::convert)
|
.map(converter::convert)
|
||||||
|
.filter(t -> t instanceof IntermediateInnerType)
|
||||||
|
.map(t -> (IntermediateInnerType) t)
|
||||||
.collect(Collectors.toList());//ToDo
|
.collect(Collectors.toList());//ToDo
|
||||||
FunN f = new FunN(arguments, returnType);
|
f = new FunN(arguments, returnType);
|
||||||
|
} else {
|
||||||
|
f = new FunN(returnType);
|
||||||
|
}
|
||||||
|
|
||||||
FunN.writeClassFile(f.getSuperClassName(), f.getSuperBytecode(), path);
|
FunN.writeClassFile(f.getSuperClassName(), f.getSuperBytecode(), path);
|
||||||
FunN.writeClassFile(f.getClassName(), f.getBytecode(), path);
|
FunN.writeClassFile(f.getClassName(), f.getBytecode(), path);
|
||||||
//ToDo Etienne End
|
//ToDo Etienne End
|
||||||
|
@ -3,7 +3,9 @@ package de.dhbwstuttgart.intermediate.convert;
|
|||||||
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.*;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -12,14 +14,19 @@ public class ASTToIntermediate {
|
|||||||
|
|
||||||
public IntermediateRefType convert(RefType originalType){
|
public IntermediateRefType convert(RefType originalType){
|
||||||
//ToDo Etienne: check if it works
|
//ToDo Etienne: check if it works
|
||||||
|
System.out.println(originalType.getName());
|
||||||
|
System.out.println(originalType.getParaList().size());
|
||||||
|
|
||||||
if (originalType.getName().toString().matches("Fun\\d+\\$\\$")){
|
if (originalType.getName().toString().matches("Fun\\d+\\$\\$")){
|
||||||
ASTToIntermediate converter = new ASTToIntermediate();
|
ASTToIntermediate converter = new ASTToIntermediate();
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> parameters = originalType.getParaList();
|
List<RefTypeOrTPHOrWildcardOrGeneric> parameters = originalType.getParaList();
|
||||||
IntermediateInnerType returnType = convert(parameters.get(parameters.size() - 1));
|
IntermediateInnerType returnType = (IntermediateInnerType) convert(parameters.get(parameters.size() - 1));
|
||||||
parameters.remove(parameters.size() - 1);
|
parameters.remove(parameters.size() - 1);
|
||||||
return new FunN(parameters
|
return new FunN(parameters
|
||||||
.stream()
|
.stream()
|
||||||
.map(this::convert)
|
.map(this::convert)
|
||||||
|
.filter(t -> t instanceof IntermediateInnerType)
|
||||||
|
.map(t -> (IntermediateInnerType) t)
|
||||||
.collect(Collectors.toList()), returnType);
|
.collect(Collectors.toList()), returnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,13 +59,24 @@ public class ASTToIntermediate {
|
|||||||
return new IntermediateExtendsWildcard((IntermediateInnerType) innerType);
|
return new IntermediateExtendsWildcard((IntermediateInnerType) innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public IntermediateWildcard convert(){
|
public IntermediateWildcard convert(){
|
||||||
//thows RuntimeException because in the AST is no typ defined which represents a normal wildcard
|
//thows RuntimeException because in the AST is no typ defined which represents a normal wildcard
|
||||||
throw new NotImplementedException("There is no conversion defined for this type.");
|
throw new NotImplementedException("There is no conversion defined for this type.");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public IntermediateRefType convert(RefTypeOrTPHOrWildcardOrGeneric originalType){
|
//ToDo Etienne: check if it works
|
||||||
//default implementation which shouldn't be called because of polymorphism
|
public IntermediateRefType convert(TypePlaceholder originalType){
|
||||||
throw new NotImplementedException("There is no conversion defined for this type.");
|
return new IntermediateRefType(new JavaClassName(Type.getInternalName(Object.class)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntermediateType convert(RefTypeOrTPHOrWildcardOrGeneric originalType){
|
||||||
|
if (originalType instanceof RefType) return convert((RefType) originalType);
|
||||||
|
if (originalType instanceof GenericRefType) return convert((GenericRefType) originalType);
|
||||||
|
if (originalType instanceof SuperWildcardType) return convert((SuperWildcardType) originalType);
|
||||||
|
if (originalType instanceof ExtendsWildcardType) return convert((ExtendsWildcardType) originalType);
|
||||||
|
if (originalType instanceof TypePlaceholder) return convert((TypePlaceholder) originalType);
|
||||||
|
throw new NotImplementedException("There is no conversion defined for this type." + originalType.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user