forked from JavaTX/JavaCompilerCore
modified: ../../../main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../../resources/bytecode/javFiles/Matrix.jav
This commit is contained in:
parent
a01779d6df
commit
82f330eab5
@ -52,7 +52,7 @@ import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
|||||||
public class JavaTXCompiler {
|
public class JavaTXCompiler {
|
||||||
|
|
||||||
final CompilationEnvironment environment;
|
final CompilationEnvironment environment;
|
||||||
Boolean resultmodel = true;
|
Boolean resultmodel = false;
|
||||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
|
||||||
|
|
||||||
@ -551,8 +551,8 @@ public class JavaTXCompiler {
|
|||||||
}
|
}
|
||||||
/* UnifyResultModel End */
|
/* UnifyResultModel End */
|
||||||
else {
|
else {
|
||||||
Set<Set<UnifyPair>> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
//Set<Set<UnifyPair>> result = unify.unify(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
||||||
//Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
||||||
System.out.println("RESULT: " + result);
|
System.out.println("RESULT: " + result);
|
||||||
logFile.write("RES: " + result.toString()+"\n");
|
logFile.write("RES: " + result.toString()+"\n");
|
||||||
logFile.flush();
|
logFile.flush();
|
||||||
|
@ -115,7 +115,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
static int noBacktracking;
|
static int noBacktracking;
|
||||||
|
|
||||||
Integer noShortendElements = 0;
|
static Integer noShortendElements = 0;
|
||||||
|
|
||||||
public TypeUnifyTask() {
|
public TypeUnifyTask() {
|
||||||
rules = new RuleSet();
|
rules = new RuleSet();
|
||||||
@ -615,25 +615,27 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
||||||
|
|
||||||
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet alle Paare a < ty1 oder ty2 < a aus fstElems */
|
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet alle Paare a < ty1 oder ty2 < a aus fstElems */
|
||||||
Optional<UnifyPair> optOrigPair = nextSetElem.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
Set<UnifyPair> sameEqSet = null;
|
||||||
&& (x.getPairOp().equals(PairOperator.EQUALSDOT))
|
if (variance != 2) {
|
||||||
/* (x.getBasePair().getLhsType() instanceof PlaceholderType
|
Optional<UnifyPair> optOrigPair = nextSetElem.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
|
&& //(x.getPairOp().equals(PairOperator.EQUALSDOT))
|
||||||
|
(x.getBasePair().getLhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getRhsType())))
|
&& x.getLhsType().equals(x.getBasePair().getRhsType()))
|
||||||
*/
|
|
||||||
)).findFirst();
|
)).findFirst();
|
||||||
Set<UnifyPair> sameEqSet = null;
|
if (optOrigPair.isPresent()) {
|
||||||
if (optOrigPair.isPresent()) {
|
UnifyPair origPair = optOrigPair.get();
|
||||||
UnifyPair origPair = optOrigPair.get();
|
UnifyType tyVar;
|
||||||
UnifyType tyVar;
|
if (!((tyVar = origPair.getLhsType()) instanceof PlaceholderType)) {
|
||||||
if (!((tyVar = origPair.getLhsType()) instanceof PlaceholderType)) {
|
tyVar = origPair.getRhsType();
|
||||||
tyVar = origPair.getRhsType();
|
}
|
||||||
}
|
UnifyType tyVarEF = tyVar;
|
||||||
UnifyType tyVarEF = tyVar;
|
sameEqSet = fstElems.stream().map(xx -> xx.iterator().next())
|
||||||
sameEqSet = fstElems.stream().map(xx -> xx.iterator().next())
|
.filter(x -> (((x.getLhsType().equals(tyVarEF) && !(x.getRhsType() instanceof PlaceholderType))
|
||||||
.filter(x -> ((x.getLhsType().equals(tyVarEF) || x.getRhsType().equals(tyVarEF))))
|
|| (x.getRhsType().equals(tyVarEF) && !(x.getLhsType() instanceof PlaceholderType)))))
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* sameEqSet-Bestimmung Ende */
|
/* sameEqSet-Bestimmung Ende */
|
||||||
|
|
||||||
@ -746,24 +748,24 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
||||||
|
|
||||||
/* PL 2019-03-11 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
/* PL 2019-03-11 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||||
Optional<UnifyPair> optAPair = a.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
if (variance != 2) {
|
||||||
&& (x.getPairOp().equals(PairOperator.EQUALSDOT))
|
Optional<UnifyPair> optAPair = a.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
/*
|
&& //(x.getPairOp().equals(PairOperator.EQUALSDOT))
|
||||||
(x.getBasePair().getLhsType() instanceof PlaceholderType
|
(x.getBasePair().getLhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getRhsType())))
|
&& x.getLhsType().equals(x.getBasePair().getRhsType()))
|
||||||
*/
|
|
||||||
)).findFirst();
|
)).findFirst();
|
||||||
|
|
||||||
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
||||||
UnifyPair aPair = optAPair.get();
|
UnifyPair aPair = optAPair.get();
|
||||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||||
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
||||||
if (variance != 2 && !sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
if (variance != 2 && !sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
||||||
a = null;
|
a = null;
|
||||||
noShortendElements++;
|
noShortendElements++;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* PL 2019-03-11 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
/* PL 2019-03-11 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||||
@ -792,7 +794,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
/* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||||
optAPair = nSaL.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
Optional<UnifyPair> optAPair = nSaL.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
&& ((x.getBasePair().getLhsType() instanceof PlaceholderType
|
&& ((x.getBasePair().getLhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||||
@ -877,7 +879,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
/* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||||
optAPair = nSaL.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
Optional<UnifyPair> optAPair = nSaL.stream().filter(x -> (x.getBasePair() != null && x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
&& ((x.getBasePair().getLhsType() instanceof PlaceholderType
|
&& ((x.getBasePair().getLhsType() instanceof PlaceholderType
|
||||||
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
&& x.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||||
@ -888,7 +890,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
UnifyPair aPair = optAPair.get();
|
UnifyPair aPair = optAPair.get();
|
||||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||||
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
||||||
if (variance != 2 && !sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
if (!sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
||||||
nSaL = null;
|
nSaL = null;
|
||||||
noShortendElements++;
|
noShortendElements++;
|
||||||
continue;
|
continue;
|
||||||
@ -1335,18 +1337,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Boolean checkA (UnifyPair aPair, Set<UnifyPair> sameEqSet, Set<Set<UnifyPair>> elems, Set<Set<UnifyPair>> result) {
|
protected Boolean checkA (UnifyPair aPair, Set<UnifyPair> sameEqSet, Set<Set<UnifyPair>> elems, Set<Set<UnifyPair>> result) {
|
||||||
//if (aPair.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT))
|
writeLog("checkA: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
//{
|
|
||||||
writeLog("checkA: " + aPair);
|
|
||||||
//Set<UnifyPair> sameEqSet = elems.stream().map(xx -> xx.iterator().next())
|
|
||||||
// .filter(x -> ((x.getLhsType().equals(aPair.getLhsType()) || x.getRhsType().equals(aPair.getLhsType()))))
|
|
||||||
// .collect(Collectors.toCollection(HashSet::new));
|
|
||||||
//consideredElements.addAll(sameEqSet);
|
|
||||||
Boolean wrong = false;
|
|
||||||
for (UnifyPair sameEq : sameEqSet) {
|
for (UnifyPair sameEq : sameEqSet) {
|
||||||
//writeLog("x1 Original:\n" + x1.toString());
|
|
||||||
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
||||||
//UnifyPair type = a.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
|
||||||
Set<UnifyPair> localEq = new HashSet<>();
|
Set<UnifyPair> localEq = new HashSet<>();
|
||||||
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
||||||
unitedSubst.addAll(sameEq.getSubstitution());
|
unitedSubst.addAll(sameEq.getSubstitution());
|
||||||
@ -1356,11 +1349,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
|
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
|
||||||
Set<UnifyPair> localEq = new HashSet<>();
|
Set<UnifyPair> localEq = new HashSet<>();
|
||||||
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
||||||
unitedSubst.addAll(sameEq.getSubstitution());
|
unitedSubst.addAll(sameEq.getSubstitution());
|
||||||
@ -1370,12 +1363,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
result.addAll(localRes);
|
result.addAll(localRes);
|
||||||
}
|
}
|
||||||
|
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//writeLog("x1 nach Loeschung von " + sameEq.toString()+" :\n" + x1.toString());
|
|
||||||
}
|
}
|
||||||
//}
|
//writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import java.lang.Float;
|
|||||||
//import java.lang.Byte;
|
//import java.lang.Byte;
|
||||||
//import java.lang.Boolean;
|
//import java.lang.Boolean;
|
||||||
|
|
||||||
public class Matrix extends Vector<Vector<Integer>> {
|
public class Matrix extends Vector<Vector<Integer>> {
|
||||||
|
|
||||||
Matrix () {
|
Matrix () {
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ public class Matrix extends Vector<Vector<Integer>> {
|
|||||||
// Boolean a = this.add(vv.elementAt(i));
|
// Boolean a = this.add(vv.elementAt(i));
|
||||||
this.add(vv.elementAt(i));
|
this.add(vv.elementAt(i));
|
||||||
i=i+1;
|
i=i+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mul(m) {
|
mul(m) {
|
||||||
|
Loading…
Reference in New Issue
Block a user