forked from JavaTX/JavaCompilerCore
modified: src/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java modified: src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java modified: test/javFiles/Lambda.jav modified: test/javFiles/Lambda3.jav
This commit is contained in:
parent
51a2acdbaf
commit
bc2cab8c95
@ -155,31 +155,16 @@ public class JavaTXCompiler {
|
||||
}
|
||||
}
|
||||
return x;//HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS ANDERE SEITE
|
||||
})//.map( y -> {
|
||||
if ((y.getLhsType() instanceof PlaceholderType) && (x.getRhsType() instanceof PlaceholderType)) {
|
||||
|
||||
if (paraTypeVarNames.contains(x.getLhsType().getName())) {
|
||||
((PlaceholderType)x.getLhsType()).setVariance((byte)1);
|
||||
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
||||
}).map( y -> {
|
||||
if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType() instanceof PlaceholderType)) {
|
||||
if (((PlaceholderType)y.getLhsType()).getVariance() != 0 && ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||
((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType()).getVariance());
|
||||
}
|
||||
if (((PlaceholderType)y.getLhsType()).getVariance() == 0 && ((PlaceholderType)y.getRhsType()).getVariance() != 0) {
|
||||
((PlaceholderType)y.getLhsType()).setVariance(((PlaceholderType)y.getRhsType()).getVariance());
|
||||
}
|
||||
}
|
||||
if (returnTypeVarNames.contains(x.getLhsType().getName())) {
|
||||
((PlaceholderType)x.getLhsType()).setVariance((byte)-1);
|
||||
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
||||
}
|
||||
}
|
||||
if ((x.getRhsType() instanceof PlaceholderType)) {
|
||||
if (paraTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
((PlaceholderType)x.getRhsType()).setVariance((byte)1);
|
||||
((PlaceholderType)x.getRhsType()).disableWildcardtable();
|
||||
}
|
||||
if (returnTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
((PlaceholderType)x.getRhsType()).setVariance((byte)-1);
|
||||
((PlaceholderType)x.getRhsType()).disableWildcardtable();
|
||||
}
|
||||
}
|
||||
return x;
|
||||
|
||||
if (y.getLhsType().getVariance() != 0) { y.getRhsType().setVariance(y.getLhsType().getVariance()); } })
|
||||
return y; } )
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile);
|
||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
|
@ -26,6 +26,8 @@ import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||
|
||||
public class UnifyTypeFactory {
|
||||
|
||||
private static ArrayList<PlaceholderType> PLACEHOLDERS = new ArrayList<>();
|
||||
|
||||
public static FiniteClosure generateFC(List<ClassOrInterface> fromClasses) throws ClassNotFoundException {
|
||||
/*
|
||||
@ -113,7 +115,15 @@ public class UnifyTypeFactory {
|
||||
}
|
||||
|
||||
public static UnifyType convert(TypePlaceholder tph){
|
||||
return new PlaceholderType(tph.getName());
|
||||
PlaceholderType ntph = new PlaceholderType(tph.getName());
|
||||
int in = PLACEHOLDERS.indexOf(ntph);
|
||||
if (in == -1) {
|
||||
PLACEHOLDERS.add(ntph);
|
||||
return ntph;
|
||||
}
|
||||
else {
|
||||
return PLACEHOLDERS.get(in);
|
||||
}
|
||||
}
|
||||
|
||||
public static UnifyType convert(GenericRefType t){
|
||||
|
@ -89,6 +89,7 @@ public final class PlaceholderType extends UnifyType{
|
||||
return new PlaceholderType(name, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* True if this placeholder is auto-generated, false if it is user-generated.
|
||||
*/
|
||||
|
@ -1,8 +1,8 @@
|
||||
class Lambda{
|
||||
class Lambda {
|
||||
|
||||
methode(){
|
||||
method(){
|
||||
return ((f) -> f);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
interface Fun0<A>{
|
||||
@ -12,7 +12,7 @@ interface Fun0<A>{
|
||||
interface Fun1<A,B>{
|
||||
A apply(B b);
|
||||
}
|
||||
*/
|
||||
interface Fun2<A,B,C>{
|
||||
A apply(B b, C c);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,3 +1,4 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class Lambda2
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user