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 {
|
||||
|
||||
final CompilationEnvironment environment;
|
||||
Boolean resultmodel = true;
|
||||
Boolean resultmodel = false;
|
||||
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?
|
||||
|
||||
@ -551,8 +551,8 @@ public class JavaTXCompiler {
|
||||
}
|
||||
/* UnifyResultModel End */
|
||||
else {
|
||||
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.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));
|
||||
System.out.println("RESULT: " + result);
|
||||
logFile.write("RES: " + result.toString()+"\n");
|
||||
logFile.flush();
|
||||
|
@ -115,7 +115,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
static int noBacktracking;
|
||||
|
||||
Integer noShortendElements = 0;
|
||||
static Integer noShortendElements = 0;
|
||||
|
||||
public TypeUnifyTask() {
|
||||
rules = new RuleSet();
|
||||
@ -615,25 +615,27 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
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 */
|
||||
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
|
||||
Set<UnifyPair> sameEqSet = null;
|
||||
if (variance != 2) {
|
||||
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.getBasePair().getRhsType() instanceof PlaceholderType
|
||||
&& x.getLhsType().equals(x.getBasePair().getRhsType())))
|
||||
*/
|
||||
&& x.getLhsType().equals(x.getBasePair().getRhsType()))
|
||||
)).findFirst();
|
||||
Set<UnifyPair> sameEqSet = null;
|
||||
if (optOrigPair.isPresent()) {
|
||||
UnifyPair origPair = optOrigPair.get();
|
||||
UnifyType tyVar;
|
||||
if (!((tyVar = origPair.getLhsType()) instanceof PlaceholderType)) {
|
||||
tyVar = origPair.getRhsType();
|
||||
}
|
||||
UnifyType tyVarEF = tyVar;
|
||||
sameEqSet = fstElems.stream().map(xx -> xx.iterator().next())
|
||||
.filter(x -> ((x.getLhsType().equals(tyVarEF) || x.getRhsType().equals(tyVarEF))))
|
||||
if (optOrigPair.isPresent()) {
|
||||
UnifyPair origPair = optOrigPair.get();
|
||||
UnifyType tyVar;
|
||||
if (!((tyVar = origPair.getLhsType()) instanceof PlaceholderType)) {
|
||||
tyVar = origPair.getRhsType();
|
||||
}
|
||||
UnifyType tyVarEF = tyVar;
|
||||
sameEqSet = fstElems.stream().map(xx -> xx.iterator().next())
|
||||
.filter(x -> (((x.getLhsType().equals(tyVarEF) && !(x.getRhsType() instanceof PlaceholderType))
|
||||
|| (x.getRhsType().equals(tyVarEF) && !(x.getLhsType() instanceof PlaceholderType)))))
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
}
|
||||
}
|
||||
/* sameEqSet-Bestimmung Ende */
|
||||
|
||||
@ -746,24 +748,24 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<Set<UnifyPair>> aParDef = new HashSet<>();
|
||||
|
||||
/* 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)
|
||||
&& (x.getPairOp().equals(PairOperator.EQUALSDOT))
|
||||
/*
|
||||
if (variance != 2) {
|
||||
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.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||
&& x.getLhsType().equals(x.getBasePair().getRhsType())))
|
||||
*/
|
||||
&& x.getLhsType().equals(x.getBasePair().getRhsType()))
|
||||
)).findFirst();
|
||||
|
||||
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
||||
UnifyPair aPair = optAPair.get();
|
||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
||||
if (variance != 2 && !sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
||||
a = null;
|
||||
noShortendElements++;
|
||||
continue;
|
||||
if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a
|
||||
UnifyPair aPair = optAPair.get();
|
||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||
writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet);
|
||||
if (variance != 2 && !sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) {
|
||||
a = null;
|
||||
noShortendElements++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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 */
|
||||
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.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||
|| (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 */
|
||||
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.getLhsType().equals(x.getBasePair().getLhsType()))
|
||||
|| (x.getBasePair().getRhsType() instanceof PlaceholderType
|
||||
@ -888,7 +890,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
UnifyPair aPair = optAPair.get();
|
||||
//writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair());
|
||||
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;
|
||||
noShortendElements++;
|
||||
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) {
|
||||
//if (aPair.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT))
|
||||
//{
|
||||
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;
|
||||
writeLog("checkA: " + aPair + "sameEqSet: " + sameEqSet);
|
||||
for (UnifyPair sameEq : sameEqSet) {
|
||||
//writeLog("x1 Original:\n" + x1.toString());
|
||||
if (sameEq.getLhsType() instanceof PlaceholderType) {
|
||||
//UnifyPair type = a.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
||||
Set<UnifyPair> localEq = new HashSet<>();
|
||||
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
||||
unitedSubst.addAll(sameEq.getSubstitution());
|
||||
@ -1356,11 +1349,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||
result.addAll(localRes);
|
||||
}
|
||||
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//UnifyPair type = y.stream().filter(z -> z.getLhsType().equals(lhsType)).findFirst().get();
|
||||
Set<UnifyPair> localEq = new HashSet<>();
|
||||
Set<UnifyPair> unitedSubst = new HashSet<>(aPair.getSubstitution());
|
||||
unitedSubst.addAll(sameEq.getSubstitution());
|
||||
@ -1370,12 +1363,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||
result.addAll(localRes);
|
||||
}
|
||||
//writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//writeLog("x1 nach Loeschung von " + sameEq.toString()+" :\n" + x1.toString());
|
||||
}
|
||||
//}
|
||||
//writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import java.lang.Float;
|
||||
//import java.lang.Byte;
|
||||
//import java.lang.Boolean;
|
||||
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
public class Matrix extends Vector<Vector<Integer>> {
|
||||
|
||||
Matrix () {
|
||||
}
|
||||
@ -16,7 +16,7 @@ public class Matrix extends Vector<Vector<Integer>> {
|
||||
// Boolean a = this.add(vv.elementAt(i));
|
||||
this.add(vv.elementAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mul(m) {
|
||||
|
Loading…
Reference in New Issue
Block a user