forked from JavaTX/JavaCompilerCore
Changes to be committed:
modified: src/de/dhbwstuttgart/core/JavaTXCompiler.java modified: src/de/dhbwstuttgart/typeinference/unify/RuleSet.java modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: test/javFiles/Matrix.jav Fehler in der Aufteilung von Unify korrigiert. Equalcheck in Schritt 6 wiedre eingefuegt.
This commit is contained in:
parent
87fe51767c
commit
5270cecec9
@ -101,8 +101,9 @@ public class JavaTXCompiler {
|
||||
}
|
||||
|
||||
System.out.println(xConsSet);
|
||||
Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result.size());
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
|
||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result);
|
||||
results.addAll(result);
|
||||
}
|
||||
return results.stream().map((unifyPairs ->
|
||||
|
@ -241,7 +241,7 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
UnifyType cFromFc = fc.getLeftHandedType(c.getName()).orElse(null);
|
||||
|
||||
NOCHMAL UEBERPRUEFEN
|
||||
//NOCHMAL UEBERPRUEFEN
|
||||
//PL 18-02-09 Eingfuegt Anfang
|
||||
//C und D koennen auch gleich sein.
|
||||
if (c.getName().equals(d.getName())) {
|
||||
|
@ -78,7 +78,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
/*
|
||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||
*/
|
||||
//System.out.println("Unifikation: " + eq);
|
||||
System.out.println("Unifikation: " + eq);
|
||||
Set<UnifyPair> eq0 = applyTypeUnificationRules(eq, fc);
|
||||
|
||||
/*
|
||||
@ -122,11 +122,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
// Sets that originate from pair pattern matching
|
||||
// Sets of the "second level"
|
||||
Set<UnifyPair> undefinedPairs = new HashSet<>();
|
||||
System.out.println("eq2s " + eq2s);
|
||||
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-10-03 geloest, muesste noch mit FCs mit kleineren
|
||||
//Typen getestet werden.
|
||||
System.out.println("secondLevelSets:" +secondLevelSets);
|
||||
// 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()) {
|
||||
@ -157,11 +159,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
topLevelSets.add(flat);
|
||||
}
|
||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets));
|
||||
//System.out.println(topLevelSets);
|
||||
System.out.println();
|
||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, fc, parallel);
|
||||
|
||||
}
|
||||
|
||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> sets) {
|
||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> sets, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||
ArrayList<Set<Set<UnifyPair>>> newSets = new ArrayList<>(sets);
|
||||
Set<Set<UnifyPair>> set = newSets.remove(0);
|
||||
ArrayList<Set<UnifyPair>> newSet = new ArrayList<>(set);
|
||||
@ -172,17 +176,17 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
||||
elems.add(a);
|
||||
if (newSets.isEmpty()) {
|
||||
result = unify2(elems);
|
||||
result = unify2(elems, eq, fc, parallel);
|
||||
}
|
||||
else {
|
||||
result = computeCartesianRecursive(elems,newSets);
|
||||
result = computeCartesianRecursive(elems,newSets, eq, fc, parallel);
|
||||
}
|
||||
if (!result.isEmpty()) break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten) {
|
||||
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||
//Set<Set<UnifyPair>> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
// Cartesian product over all (up to 10) top level sets
|
||||
@ -208,8 +212,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* Step 6 a) Restart (fork) for pairs where subst was applied
|
||||
*/
|
||||
if(parallel) {
|
||||
if //(eqPrime.equals(eq)) //PL 2017-09-29 auskommentiert und durch
|
||||
(!eqPrimePrime.isPresent()) //PL 2071-09-29 dies ersetzt
|
||||
if (eqPrime.equals(eq)) //PL 2017-09-29 auskommentiert und durch
|
||||
//(!eqPrimePrime.isPresent()) //PL 2071-09-29 dies ersetzt
|
||||
//Begruendung: Wenn in der Substitution keine Veraenderung
|
||||
//(!eqPrimePrime.isPresent()) erfolgt ist, ist das Ergebnis erzielt.
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
@ -227,8 +231,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
}
|
||||
else { // sequentiell (Step 6b is included)
|
||||
if //(eqPrime.equals(eq)) //PL 2017-09-29 auskommentiert und durch
|
||||
(!eqPrimePrime.isPresent()) //PL 2071-09-29 dies ersetzt
|
||||
System.out.println("nextStep: " + eqPrime);
|
||||
if (eqPrime.equals(eq)) //PL 2017-09-29 auskommentiert und durch
|
||||
//(!eqPrimePrime.isPresent()) //PL 2071-09-29 dies ersetzt
|
||||
//Begruendung: Wenn in der Substitution keine Veraenderung
|
||||
//(!eqPrimePrime.isPresent()) erfolgt ist, ist das Ergebnis erzielt.
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
@ -423,7 +428,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
// Case 1: (a <. Theta')
|
||||
if(pairOp == PairOperator.SMALLERDOT && lhsType instanceof PlaceholderType) {
|
||||
//System.out.println(pair);
|
||||
if (first) {
|
||||
if (first) {System.out.println(pair);
|
||||
Set<Set<UnifyPair>> x1 = unifyCase1((PlaceholderType) pair.getLhsType(), pair.getRhsType(), fc);
|
||||
//System.out.println(x1);
|
||||
result.get(0).add(x1);
|
||||
@ -439,7 +444,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
// Case 2: (a <.? ? ext Theta')
|
||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof ExtendsType)
|
||||
if (first) {
|
||||
if (first) {System.out.println(pair);
|
||||
result.get(1).add(unifyCase2((PlaceholderType) pair.getLhsType(), (ExtendsType) pair.getRhsType(), fc));
|
||||
}
|
||||
else {
|
||||
@ -452,7 +457,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
// Case 3: (a <.? ? sup Theta')
|
||||
else if(pairOp == PairOperator.SMALLERDOTWC && lhsType instanceof PlaceholderType && rhsType instanceof SuperType)
|
||||
if (first) {
|
||||
if (first) {System.out.println(pair);
|
||||
result.get(2).add(unifyCase3((PlaceholderType) lhsType, (SuperType) rhsType, fc));
|
||||
}
|
||||
else {
|
||||
@ -470,7 +475,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
// Case 5: (Theta <. a)
|
||||
else if(pairOp == PairOperator.SMALLERDOT && rhsType instanceof PlaceholderType)
|
||||
if (first) {
|
||||
if (first) {System.out.println(pair);
|
||||
result.get(4).add(unifyCase5(lhsType, (PlaceholderType) rhsType, fc));
|
||||
}
|
||||
else {
|
||||
@ -493,7 +498,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
// Case 8: (Theta <.? a)
|
||||
else if(pairOp == PairOperator.SMALLERDOTWC && rhsType instanceof PlaceholderType)
|
||||
if (first) {
|
||||
if (first) {System.out.println(pair);
|
||||
result.get(7).add(unifyCase8(lhsType, (PlaceholderType) rhsType, fc));
|
||||
}
|
||||
else {
|
||||
|
@ -11,8 +11,8 @@ class Matrix extends Vector<Vector<Integer>> {
|
||||
var v2 = new Vector<Integer>();
|
||||
var j = 0;
|
||||
while(j < v1.size()) {
|
||||
//var erg = 0;
|
||||
//var k = 0;
|
||||
var erg = 0;
|
||||
var k = 0;
|
||||
//while(k < v1.size()) {
|
||||
//erg = erg + v1.elementAt(k)
|
||||
// * m.elementAt(k).elementAt(j);
|
||||
|
Loading…
Reference in New Issue
Block a user