forked from JavaTX/JavaCompilerCore
Merge branch 'plugin' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into strucTypesNew
This commit is contained in:
commit
4919dd34b2
@ -269,13 +269,6 @@ public class JavaTXCompiler {
|
||||
|
||||
TypeUnify unify = new TypeUnify();
|
||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||
try {
|
||||
FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/test/logFiles/"+"log"));
|
||||
logFile.write("FC:\\" + finiteClosure.toString()+"\n");
|
||||
for(SourceFile sf : this.sourceFiles.values()) {
|
||||
logFile.write(ASTTypePrinter.print(sf));
|
||||
}
|
||||
logFile.flush();
|
||||
Set<List<Constraint<UnifyPair>>> cardProd = unifyCons.cartesianProduct();
|
||||
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
||||
Set<UnifyPair> xConsSet = new HashSet<>();
|
||||
@ -334,15 +327,11 @@ public class JavaTXCompiler {
|
||||
return y; } )
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
varianceInheritance(xConsSet);
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
|
||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result);
|
||||
logFile.write("RES: " + result.toString()+"\n");
|
||||
logFile.flush();
|
||||
results.addAll(result);
|
||||
}
|
||||
}
|
||||
catch (IOException e) { }
|
||||
|
||||
|
||||
return results.stream().map((unifyPairs ->
|
||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
||||
|
@ -201,7 +201,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT){
|
||||
//@see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.14.2
|
||||
//Expression muss zu Numeric Convertierbar sein. also von Numeric erben
|
||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), number, PairOperator.SMALLERDOT));
|
||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), number, PairOperator.SMALLERNEQDOT));
|
||||
//The type of the postfix increment expression is the type of the variable
|
||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT));
|
||||
}else{
|
||||
|
@ -36,15 +36,10 @@ import java.io.IOException;
|
||||
*/
|
||||
public class RuleSet implements IRuleSet{
|
||||
|
||||
FileWriter logFile;
|
||||
|
||||
RuleSet() {
|
||||
super();
|
||||
}
|
||||
|
||||
RuleSet(FileWriter logFile) {
|
||||
this.logFile = logFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<UnifyPair> reduceUp(UnifyPair pair) {
|
||||
|
@ -8,16 +8,16 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class TypeUnify {
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||
return res;
|
||||
}
|
||||
|
||||
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log);
|
||||
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false);
|
||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||
return res;
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
private boolean printtag = false;
|
||||
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll?
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||
FileWriter logFile;
|
||||
//public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||
|
||||
/**
|
||||
* The implementation of setOps that will be used during the unification
|
||||
@ -87,14 +86,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
rules = new RuleSet();
|
||||
}
|
||||
|
||||
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log) {
|
||||
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||
this.eq = eq;
|
||||
this.fc = fc;
|
||||
this.oup = new OrderingUnifyPair(fc);
|
||||
this.parallel = parallel;
|
||||
this.logFile = logFile;
|
||||
this.log = log;
|
||||
rules = new RuleSet(logFile);
|
||||
rules = new RuleSet();
|
||||
}
|
||||
|
||||
|
||||
@ -146,7 +143,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
protected Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||
Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
||||
).collect(Collectors.toCollection(HashSet::new));
|
||||
writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
||||
if (aas.isEmpty()) {
|
||||
System.out.println("");
|
||||
}
|
||||
@ -154,7 +150,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||
*/
|
||||
nOfUnify++;
|
||||
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
||||
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
/*
|
||||
@ -230,10 +225,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
// those pairs are contradictory and the unification is impossible.
|
||||
if(!undefinedPairs.isEmpty()) {
|
||||
noUndefPair++;
|
||||
for (UnifyPair up : undefinedPairs) {
|
||||
writeLog(noUndefPair.toString() + " UndefinedPairs; " + up);
|
||||
writeLog("BasePair; " + up.getBasePair());
|
||||
}
|
||||
Set<Set<UnifyPair>> error = new HashSet<>();
|
||||
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||
error.add(undefinedPairs);
|
||||
@ -322,13 +313,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
else if(eqPrimePrime.isPresent()) {
|
||||
//System.out.println("nextStep: " + eqPrimePrime.get());
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true, logFile, log);
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true);
|
||||
forks.add(fork);
|
||||
fork.fork();
|
||||
}
|
||||
else {
|
||||
//System.out.println("nextStep: " + eqPrime);
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true, logFile, log);
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true);
|
||||
forks.add(fork);
|
||||
fork.fork();
|
||||
}
|
||||
@ -339,13 +330,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
//PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent())
|
||||
//PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst
|
||||
//eqPrimePrime Veraenderungen in subst repraesentieren.
|
||||
try {
|
||||
if (isSolvedForm(eqPrime)) {
|
||||
logFile.write(eqPrime.toString()+"\n");
|
||||
logFile.flush();
|
||||
}
|
||||
}
|
||||
catch (IOException e) { }
|
||||
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
}
|
||||
else if(eqPrimePrime.isPresent()) {
|
||||
@ -376,8 +361,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* Step 7: Filter empty sets;
|
||||
*/
|
||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
||||
if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet))
|
||||
writeLog("Result1 " + eqPrimePrimeSet.toString());
|
||||
return eqPrimePrimeSet;
|
||||
}
|
||||
|
||||
@ -397,7 +380,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
return result;
|
||||
}
|
||||
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||
writeLog("nextSet: " + nextSet.toString());
|
||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||
try {
|
||||
//List<Set<UnifyPair>>
|
||||
@ -563,16 +545,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
//}
|
||||
return (!x.containsAll(durchschnitt));
|
||||
}).collect(Collectors.toCollection(ArrayList::new));
|
||||
writeLog("abhSubst: " + abhSubst.toString());
|
||||
writeLog("a: " + a.toString());
|
||||
writeLog("Durchschnitt: " + durchschnitt.toString());
|
||||
writeLog("nextSet: " + nextSet.toString());
|
||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||
writeLog("Number erased Elements (undef): " + (len - nextSetasList.size()));
|
||||
noAllErasedElements = noAllErasedElements + (len - nextSetasList.size());
|
||||
writeLog("Number erased Elements (undef): " + noAllErasedElements.toString());
|
||||
noBacktracking++;
|
||||
writeLog("Number of Backtracking: " + noBacktracking);
|
||||
System.out.println("");
|
||||
}
|
||||
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
||||
@ -1212,7 +1186,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
permuteParams(candidates, idx+1, result, current);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void writeLog(String str) {
|
||||
if (log) {
|
||||
try {
|
||||
@ -1223,4 +1197,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
catch (IOException e) { }
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
Binary file not shown.
@ -4,7 +4,7 @@ import java.lang.Double;
|
||||
|
||||
public class Fac {
|
||||
|
||||
java.lang.Long getFac(n){
|
||||
getFac(n){
|
||||
var res = 1;
|
||||
var i = 1;
|
||||
while(i<=n) {
|
||||
|
Loading…
Reference in New Issue
Block a user