forked from JavaTX/JavaCompilerCore
Merge branch 'plugin' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into plugin
This commit is contained in:
commit
ac49f26df3
@ -41,11 +41,17 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
final CompilationEnvironment environment;
|
final CompilationEnvironment environment;
|
||||||
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")+"/test/logFiles/log" geschrieben werden soll?
|
||||||
|
|
||||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||||
this(Arrays.asList(sourceFile));
|
this(Arrays.asList(sourceFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException {
|
||||||
|
this(sourceFile);
|
||||||
|
this.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
public JavaTXCompiler(List<File> sources) throws IOException, ClassNotFoundException {
|
public JavaTXCompiler(List<File> sources) throws IOException, ClassNotFoundException {
|
||||||
environment = new CompilationEnvironment(sources);
|
environment = new CompilationEnvironment(sources);
|
||||||
for (File s : sources) {
|
for (File s : sources) {
|
||||||
@ -169,7 +175,7 @@ public class JavaTXCompiler {
|
|||||||
return y; } )
|
return y; } )
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
varianceInheritance(xConsSet);
|
varianceInheritance(xConsSet);
|
||||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile);
|
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||||
System.out.println("RESULT: " + result);
|
System.out.println("RESULT: " + result);
|
||||||
logFile.write("RES: " + result.toString()+"\n");
|
logFile.write("RES: " + result.toString()+"\n");
|
||||||
|
@ -8,16 +8,16 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
|
|
||||||
public class TypeUnify {
|
public class TypeUnify {
|
||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile) {
|
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static int i = 0;
|
private static int i = 0;
|
||||||
private boolean printtag = false;
|
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/";
|
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||||
FileWriter logFile;
|
FileWriter logFile;
|
||||||
@ -86,12 +87,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
rules = new RuleSet();
|
rules = new RuleSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel, FileWriter logFile) {
|
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log) {
|
||||||
this.eq = eq;
|
this.eq = eq;
|
||||||
this.fc = fc;
|
this.fc = fc;
|
||||||
this.oup = new OrderingUnifyPair(fc);
|
this.oup = new OrderingUnifyPair(fc);
|
||||||
this.parallel = parallel;
|
this.parallel = parallel;
|
||||||
this.logFile = logFile;
|
this.logFile = logFile;
|
||||||
|
this.log = log;
|
||||||
rules = new RuleSet(logFile);
|
rules = new RuleSet(logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,13 +322,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
eqPrimePrimeSet.add(eqPrime);
|
eqPrimePrimeSet.add(eqPrime);
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
//System.out.println("nextStep: " + eqPrimePrime.get());
|
//System.out.println("nextStep: " + eqPrimePrime.get());
|
||||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true, logFile);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true, logFile, log);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//System.out.println("nextStep: " + eqPrime);
|
//System.out.println("nextStep: " + eqPrime);
|
||||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true, logFile);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true, logFile, log);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -799,10 +801,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
|
||||||
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
||||||
Set<UnifyType> remElem = new HashSet<>();
|
Set<UnifyPair> remElem = new HashSet<>();
|
||||||
remElem.add(pair.getRhsType());
|
remElem.add(new UnifyPair(pair.getLhsType(), pair.getRhsType(), PairOperator.EQUALSDOT));
|
||||||
remElem.add(new ExtendsType(pair.getRhsType()));
|
x1.remove(remElem);
|
||||||
remElem.add(new SuperType(pair.getRhsType()));
|
remElem = new HashSet<>();
|
||||||
|
remElem.add(new UnifyPair(pair.getLhsType(), new ExtendsType(pair.getRhsType()), PairOperator.EQUALSDOT));
|
||||||
|
x1.remove(remElem);
|
||||||
|
remElem = new HashSet<>();
|
||||||
|
remElem.add(new UnifyPair(pair.getLhsType(), new SuperType(pair.getRhsType()), PairOperator.EQUALSDOT));
|
||||||
x1.remove(remElem);
|
x1.remove(remElem);
|
||||||
}
|
}
|
||||||
//System.out.println(x1);
|
//System.out.println(x1);
|
||||||
@ -860,17 +866,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// result.get(3).add(unifyCase4((PlaceholderType) lhsType, rhsType, fc));
|
// result.get(3).add(unifyCase4((PlaceholderType) lhsType, rhsType, fc));
|
||||||
|
|
||||||
// Case 5: (Theta <. a)
|
// Case 5: (Theta <. a)
|
||||||
else if (((pairOp == PairOperator.SMALLERDOT) || (pairOp == PairOperator.SMALLERNEQDOT)) && rhsType instanceof PlaceholderType)
|
else if ((pairOp == PairOperator.SMALLERDOT) && rhsType instanceof PlaceholderType)
|
||||||
if (first) { //writeLog(pair.toString()+"\n");
|
if (first) { //writeLog(pair.toString()+"\n");
|
||||||
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
|
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
|
||||||
result.get(4).add(x1);
|
result.get(4).add(x1);
|
||||||
if (pairOp == PairOperator.SMALLERNEQDOT) {
|
|
||||||
Set<UnifyType> remElem = new HashSet<>();
|
|
||||||
remElem.add(pair.getLhsType());
|
|
||||||
remElem.add(new ExtendsType(pair.getLhsType()));
|
|
||||||
remElem.add(new SuperType(pair.getLhsType()));
|
|
||||||
x1.remove(remElem);
|
|
||||||
}
|
|
||||||
if (x1.isEmpty()) {
|
if (x1.isEmpty()) {
|
||||||
undefined.add(pair); //Theta ist nicht im FC
|
undefined.add(pair); //Theta ist nicht im FC
|
||||||
}
|
}
|
||||||
@ -1215,11 +1214,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void writeLog(String str) {
|
void writeLog(String str) {
|
||||||
try {
|
if (log) {
|
||||||
logFile.write(str+"\n");
|
try {
|
||||||
logFile.flush();
|
logFile.write(str+"\n");
|
||||||
|
logFile.flush();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e) { }
|
catch (IOException e) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -1,9 +1,23 @@
|
|||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
|
import java.lang.Double;
|
||||||
import java.lang.Boolean;
|
import java.lang.Boolean;
|
||||||
|
|
||||||
class OL {
|
class OL {
|
||||||
|
|
||||||
m(Integer x) { return x + x; }
|
m(x) { return x + x; }
|
||||||
|
|
||||||
m(Boolean x) {return x || x; }
|
//m(x) { return x || x; }
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Main {
|
||||||
|
|
||||||
|
main(x) {
|
||||||
|
var ol;
|
||||||
|
ol = new OL();
|
||||||
|
return ol.m(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@ import java.lang.Integer;
|
|||||||
// wenn nur ein Import da steht,wird die Type von
|
// wenn nur ein Import da steht,wird die Type von
|
||||||
// dem Literal 2 Number berechnet => Deswegen kann
|
// dem Literal 2 Number berechnet => Deswegen kann
|
||||||
// nicht auf den Stack geladen.
|
// nicht auf den Stack geladen.
|
||||||
//import java.lang.Long;
|
import java.lang.Long;
|
||||||
|
|
||||||
public class While {
|
public class While {
|
||||||
m(x) {
|
m(x) {
|
||||||
while(x < 2) {
|
while(x < 2) {
|
||||||
x = x+1;
|
x = x+1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user