forked from JavaTX/JavaCompilerCore
modified: ../../src/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../../src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java im Max den Fall a <.? ? extends a beruecksichtigt modified: ../../src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java modified: ../../src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java ; in der Schleife generate fresh Type Var entfernt
This commit is contained in:
parent
dab0dc180c
commit
2f9d44d0b0
@ -225,6 +225,8 @@ public class JavaTXCompiler {
|
||||
System.out.println("RESULT Final: " + results);
|
||||
logFile.write("RES_FINAL: " + results.toString()+"\n");
|
||||
logFile.flush();
|
||||
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
|
||||
logFile.flush();
|
||||
}
|
||||
catch (IOException e) { }
|
||||
return results.stream().map((unifyPairs ->
|
||||
|
@ -1144,7 +1144,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||
|
||||
for(int i = 0; !allGen && i < theta.getTypeParams().size(); i++) {
|
||||
if(freshTphs.size()-1 < i)
|
||||
//if(freshTphs.size()-1 < i)
|
||||
freshTphs.add(PlaceholderType.freshPlaceholder());
|
||||
resultPrime.add(new UnifyPair(freshTphs.get(i), theta.getTypeParams().get(i), PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair));
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||
* The finite closure for the type unification
|
||||
* @author Florian Steurer
|
||||
*/
|
||||
public class FiniteClosure extends Ordering<UnifyType> implements IFiniteClosure {
|
||||
public class FiniteClosure //extends Ordering<UnifyType> //entfernt PL 2018-12-11
|
||||
implements IFiniteClosure {
|
||||
|
||||
/**
|
||||
* A map that maps every type to the node in the inheritance graph that contains that type.
|
||||
@ -561,14 +562,31 @@ public class FiniteClosure extends Ordering<UnifyType> implements IFiniteClosure
|
||||
return this.inheritanceGraph.toString();
|
||||
}
|
||||
|
||||
/* entfernt PL 2018-12-11
|
||||
public int compare (UnifyType left, UnifyType right) {
|
||||
return compare(left, right, PairOperator.SMALLERDOT);
|
||||
}
|
||||
*/
|
||||
|
||||
public int compare (UnifyType left, UnifyType right, PairOperator pairop) {
|
||||
if ((left instanceof ExtendsType && right instanceof ReferenceType)
|
||||
|| (right instanceof ExtendsType && left instanceof ReferenceType))
|
||||
System.out.println("");
|
||||
//Die Faelle abfangen, bei den Variablen verglichen werden PL 2018-12-11
|
||||
UnifyType ex;
|
||||
if (left instanceof PlaceholderType) {
|
||||
if ((right instanceof WildcardType)
|
||||
&& ((ex = ((WildcardType)right).wildcardedType) instanceof PlaceholderType)
|
||||
&& ((PlaceholderType)left).getName().equals(((PlaceholderType)ex).getName())) {// a <.? ? extends a oder a <.? ? super a
|
||||
return -1;
|
||||
}
|
||||
else {// a <. a
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((right instanceof PlaceholderType) && (left instanceof WildcardType)) {
|
||||
return 0;
|
||||
}
|
||||
UnifyPair up = new UnifyPair(left, right, pairop);
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
||||
HashSet<UnifyPair> hs = new HashSet<>();
|
||||
|
@ -151,7 +151,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
System.out.print("");
|
||||
//Set<PlaceholderType> varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
||||
//Set<PlaceholderType> varsright = righteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
||||
//filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant)
|
||||
//filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant) andere Substitutioen werden rausgefiltert
|
||||
lefteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));//removeIf(x -> !varsright.contains(x.getLhsType()));
|
||||
righteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -21,7 +23,7 @@ public final class PlaceholderType extends UnifyType{
|
||||
* Static list containing the names of all existing placeholders.
|
||||
* Used for generating fresh placeholders.
|
||||
*/
|
||||
protected static final HashSet<String> EXISTING_PLACEHOLDERS = new HashSet<String>();
|
||||
public static final ArrayList<String> EXISTING_PLACEHOLDERS = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Prefix of auto-generated placeholder names.
|
||||
@ -81,11 +83,12 @@ public final class PlaceholderType extends UnifyType{
|
||||
* A user could later instantiate a type using the same name that is equivalent to this type.
|
||||
* @return A fresh placeholder type.
|
||||
*/
|
||||
public static PlaceholderType freshPlaceholder() {
|
||||
public synchronized static PlaceholderType freshPlaceholder() {
|
||||
String name = nextName + (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
||||
// Add random chars while the name is in use.
|
||||
while(EXISTING_PLACEHOLDERS.contains(name));
|
||||
while(EXISTING_PLACEHOLDERS.contains(name)) {
|
||||
name += (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
||||
}
|
||||
return new PlaceholderType(name, true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user