modified: src/de/dhbwstuttgart/typeinference/unify/RuleSet.java

FunType von Bedingung <. auf beliebig zu gelassen
	modified:   src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
bei childrenaufruf unifyCase1 gleiches Element hinzugefuegt
	modified:   test/typeinference/JavaTXCompilerTest.java
typeinference-Aufruf vor die Schleife gezogen
This commit is contained in:
Martin Plümicke 2017-10-03 21:58:39 +02:00
parent fa92fee98d
commit 7f888a1bf8
3 changed files with 16 additions and 8 deletions

View File

@ -689,8 +689,9 @@ public class RuleSet implements IRuleSet{
@Override
public Optional<Set<UnifyPair>> reduceFunN(UnifyPair pair) {
if(pair.getPairOp() != PairOperator.SMALLERDOT)
return Optional.empty();
//if(pair.getPairOp() != PairOperator.SMALLERDOT) //PL 2017-10-03 auskommentiert,
//da Regel auch fuer EQUALSDOT anwendbar
// return Optional.empty();
UnifyType lhsType = pair.getLhsType();
UnifyType rhsType = pair.getRhsType();

View File

@ -74,6 +74,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
* @return The set of all principal type unifiers
*/
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
System.out.println(eq);
/*
* Step 1: Repeated application of reduce, adapt, erase, swap
*/
@ -119,7 +120,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
// Sets of the "second level"
Set<UnifyPair> undefinedPairs = new HashSet<>();
Set<Set<Set<Set<UnifyPair>>>> secondLevelSets = calculatePairSets(eq2s, fc, undefinedPairs);
//PL 2017-09-20: Im calculatePairSets wird möglicherweise O .< java.lang.Integer nicht ausgewertet Faculty Beispiel im 1. Schritt
//PL 2017-09-20: Im calculatePairSets wird möglicherweise O .< java.lang.Integer
//nicht ausgewertet Faculty Beispiel im 1. Schritt
//PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren
//Typen getestet werden.
// If pairs occured that did not match one of the cartesian product cases,
// those pairs are contradictory and the unification is impossible.
if(!undefinedPairs.isEmpty())
@ -158,12 +162,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
// Flatten the cartesian product
Set<UnifyPair> eqPrime = new HashSet<>();
setToFlatten.stream().forEach(x -> eqPrime.addAll(x));
System.out.println(eqPrime);
/*
* Step 5: Substitution
*/
Optional<Set<UnifyPair>> eqPrimePrime = rules.subst(eqPrime);
System.out.println(eq);
System.out.println(eqPrimePrime);
/*
* Step 6 a) Restart (fork) for pairs where subst was applied
@ -446,7 +452,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
for(UnifyType c : cs) {
Set<UnifyType> thetaQs = fc.getChildren(c).stream().collect(Collectors.toCollection(HashSet::new));
//thetaQs.add(thetaPrime);
thetaQs.add(thetaPrime); //PL 2017-10-03: War auskommentiert habe ich wieder einkommentiert,
//da children offensichtlich ein echtes kleiner und kein kleinergleich ist
Set<UnifyType> thetaQPrimes = new HashSet<>();
TypeParams cParams = c.getTypeParams();
if(cParams.size() == 0)

View File

@ -44,12 +44,12 @@ public class JavaTXCompilerTest {
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
//filesToTest.add(new File(rootDirectory+"Import.jav"));
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
compiler.typeInference();
List<ResultSet> results = compiler.typeInference();
for(File f : compiler.sourceFiles.keySet()){
SourceFile sf = compiler.sourceFiles.get(f);
System.out.println(ASTTypePrinter.print(sf));
List<ResultSet> results = compiler.typeInference();
//List<ResultSet> results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen
assert results.size()>0;
for(ResultSet resultSet : results){
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);