Merge branch 'plugin' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bytecode2
test/bytecode/javFiles/Lambda.jav test/bytecode/javFiles/OL.jav
19
README.md
@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
# plugin site erstellen
|
|
||||||
* die JAvaTXCOmpiler DAtei in ein plugin umwandeln und deployen.
|
|
||||||
* siehe: http://www.vogella.com/tutorials/EclipseJarToPlugin/article.html#convert-jar-files-to-osgi-bundles-with-the-p2-maven-plugin
|
|
||||||
* AUsführung:
|
|
||||||
* mvn deploy #erstellt die JAR-Datei und steckt sie in ein lokales Repo (maven-repository)
|
|
||||||
* mvn p2:site
|
|
||||||
* mvn package # hier wird die ZIP-Filf zum Einbinden in Eclipse erstellt
|
|
||||||
|
|
||||||
# Einbinden in Eclipse
|
|
||||||
* In Eclipse kann die Zip-FIle wie ein Plugin installiert werden
|
|
||||||
* Hier tritt FEhler auf. Reflections-Library kann nicht installiert werden. Möglicherweise wird sie auch nicht gebraucht
|
|
||||||
* Nach dem installieren de.dhbwstuttagrt.JavaTXcompiler zu den DEpendencies des plugins hinzufügen
|
|
||||||
* Anschließend unter "Overview" auf "Updata Classpath" klicken
|
|
||||||
|
|
||||||
# Windows
|
|
||||||
* JAVA_HOME setzen:
|
|
||||||
* export JAVA_HOME=/c/Program\ Files/Java/jdk1.8.0_102/
|
|
BIN
Website/JavaTXExamples.zip
Normal file
88
Website/index.html
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<html> <head>
|
||||||
|
<title>Java-TX Plugin</title></head>
|
||||||
|
<center>
|
||||||
|
<h1>Java-TX Plugin</h1>
|
||||||
|
</center>
|
||||||
|
<h2>Content</h2>
|
||||||
|
<ul>
|
||||||
|
<li><h4><a href="#introduction">Introduction</a></h4></li>
|
||||||
|
<li><h4><a href="newJavaTXProject/newJavaTXProject.html" >New Java-TX project</a></h4></li>
|
||||||
|
<li><h4><a href=" JavaTXExamples.zip" >Example project</a></h4></li>
|
||||||
|
<li><a href="usePlugin/usePlugin.html" >Using the plugin</a></li>
|
||||||
|
<li><h4><a href="install/install.html" >Installation</a></h4>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<h2 id="introduction">Introduction</h2>
|
||||||
|
Java-TX (Java Type eXtended) is an extension of Java in which a global type inference algorithm and real function types are added. Since the end of the nineties features from functional program- ming languages have been transferred to Java. Parametric polymorphism extended by wildcards, called generics, were transfered to Java 5.0. Higher-order functions and lambda expression were introduced in Java 8. Java 8 uses functional interfaces as target types of lambda expressions in contrast to real function types as in functional programming languages.
|
||||||
|
The powerful feature type inference from functional programming languages is incorporated into Java, as into other object-oriented
|
||||||
|
languages, i.e. only in a restricted way called local type inference. Local type inference allows certain type annotations to be omitted. For instance, it is often not necessary to specify the type of a variable. Type parameters of classes in the new-statement can be left out. Return types of methods can often also be omitted. Local type inference is at its most pronounced in Scala. In Java 10 an extention of local type inference is introduced, where types of local variables can be replaced by the keyword var and inferred automatically during the compilation. In contrast to global type inference, local type inference allows types of recursive methods and lambda expressions not to be omitted.<br>
|
||||||
|
The Java-TX project contributes to the design of object-oriented languages by developing global type inference algorithms for Java-like languages.
|
||||||
|
|
||||||
|
<h3>First Example</h3>
|
||||||
|
The class <tt>Id</tt> has the method <tt>id</tt>. The type annotations are omitted.
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<pre> <code class="language-java">
|
||||||
|
class Id {
|
||||||
|
id(x) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code> </pre>
|
||||||
|
The type inference algorithm inferrs the types, such that <tt>Id</tt> can be applied:
|
||||||
|
<pre>
|
||||||
|
new Id().id(1);
|
||||||
|
|
||||||
|
new Id().id("hallo");
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h3>More complex example</h3>
|
||||||
|
<pre>
|
||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Double;
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
|
||||||
|
class OL {
|
||||||
|
m(x) { return x + x; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class OLMain {
|
||||||
|
main(x) {
|
||||||
|
var ol;
|
||||||
|
ol = new OL();
|
||||||
|
return ol.m(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
The type inference mechanism considers only imported types. Therefore <tt>Integer</tt> <tt>Double</tt>, and <tt>String</tt> are imported.
|
||||||
|
<br/>
|
||||||
|
As the operator <tt>+</tt> is overloaded by all numeric types and String the methods <tt>m</tt> in the class <tt>OL</tt> and <tt>main</tt> in the class <tt>OLMain</tt>, respectively, gets all these types. The generated classfile demonstrates this:
|
||||||
|
<pre>
|
||||||
|
> javap OL.class
|
||||||
|
Compiled from "OL.jav"
|
||||||
|
class OL {
|
||||||
|
public OL();
|
||||||
|
public java.lang.Integer m(java.lang.Integer);
|
||||||
|
public java.lang.Double m(java.lang.Double);
|
||||||
|
}
|
||||||
|
|
||||||
|
> javap OLMain.class
|
||||||
|
Compiled from "OLMain.jav"
|
||||||
|
class OLMain {
|
||||||
|
public OLMain();
|
||||||
|
public java.lang.Integer main(java.lang.Integer);
|
||||||
|
public java.lang.Double main(java.lang.Double);
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<address></address>
|
||||||
|
<!-- hhmts start -->Last modified: Fri Jun 1 16:43:55 CEST 2018 <!-- hhmts end -->
|
||||||
|
</body> </html>
|
BIN
Website/install/Restart.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
Website/install/availableSoftware1.png
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
Website/install/availableSoftware2.png
Normal file
After Width: | Height: | Size: 109 KiB |
40
Website/install/instal.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<html> <head>
|
||||||
|
<title>Install Java-TX Plugin</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Install Java-TX Plugin</h1>
|
||||||
|
<ol>
|
||||||
|
<li>Select "Install New Software ..."<br>
|
||||||
|
<img width= 400 src="newsoftware.png" >
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>Add ...<br>
|
||||||
|
<img width=550 src="availableSoftware1.png" >
|
||||||
|
</li>
|
||||||
|
<li>Insert address<br>
|
||||||
|
<img width=550 src="availableSoftware2.png" >
|
||||||
|
</li>
|
||||||
|
<li>Select installation<br>
|
||||||
|
<img width=550 src="selectInstallation.png" >
|
||||||
|
</li>
|
||||||
|
<li>Installation details<br>
|
||||||
|
<img width=550 src="installationDetails.png" >
|
||||||
|
</li>
|
||||||
|
<li>Accept license agreement<br>
|
||||||
|
<img width=550 src="licenseAgreement.png" >
|
||||||
|
</li>
|
||||||
|
<li>Install anyway<br>
|
||||||
|
<img width=450 src="installAnyway.png">
|
||||||
|
</li>
|
||||||
|
<li>Restart<br>
|
||||||
|
<img width=450 src="Restart.png">
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<address></address>
|
||||||
|
<!-- hhmts start -->Last modified: Fri Jun 1 11:57:15 CEST 2018 <!-- hhmts end -->
|
||||||
|
</body> </html>
|
40
Website/install/install.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<html> <head>
|
||||||
|
<title>Install Java-TX Plugin</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>Install Java-TX Plugin</h2>
|
||||||
|
<ol>
|
||||||
|
<li>Select "Install New Software ..."<br>
|
||||||
|
<img width= 400 src="newsoftware.png" >
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>Add ...<br>
|
||||||
|
<img width=550 src="availableSoftware1.png" >
|
||||||
|
</li>
|
||||||
|
<li>Insert address<br>
|
||||||
|
<img width=550 src="availableSoftware2.png" >
|
||||||
|
</li>
|
||||||
|
<li>Select installation<br>
|
||||||
|
<img width=550 src="selectInstallation.png" >
|
||||||
|
</li>
|
||||||
|
<li>Installation details<br>
|
||||||
|
<img width=550 src="installationDetails.png" >
|
||||||
|
</li>
|
||||||
|
<li>Accept license agreement<br>
|
||||||
|
<img width=550 src="licenseAgreement.png" >
|
||||||
|
</li>
|
||||||
|
<li>Install anyway<br>
|
||||||
|
<img width=450 src="installAnyway.png">
|
||||||
|
</li>
|
||||||
|
<li>Restart<br>
|
||||||
|
<img width=450 src="Restart.png">
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<address></address>
|
||||||
|
<!-- hhmts start -->Last modified: Fri Jun 1 12:05:43 CEST 2018 <!-- hhmts end -->
|
||||||
|
</body> </html>
|
BIN
Website/install/installAnyway.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
Website/install/installationDetails.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
Website/install/licenseAgreement.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
Website/install/newsoftware.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
Website/install/selectInstallation.png
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
Website/newJavaTXProject/addLibrary2.png
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
Website/newJavaTXProject/buildPath1.png
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
Website/newJavaTXProject/buildPath2.png
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
Website/newJavaTXProject/buildPath3.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
Website/newJavaTXProject/buildPath4.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
Website/newJavaTXProject/newJavFile.png
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
Website/newJavaTXProject/newJavFolder1.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
Website/newJavaTXProject/newJavFolder2.png
Normal file
After Width: | Height: | Size: 76 KiB |
34
Website/newJavaTXProject/newJavaTXProject.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<html> <head>
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<h2>New Java-TX project in eclipse</h2>
|
||||||
|
<ol>
|
||||||
|
<li>New -> Java Project<br/>
|
||||||
|
<img width= 400 src="newJavaTXProject.png" >
|
||||||
|
</li>
|
||||||
|
<br/>
|
||||||
|
<li>Generate a jav-File folder<br/>
|
||||||
|
<img width= 550 src="newJavFolder1.png" ><br/><br/>
|
||||||
|
<img width= 550 src="newJavFolder2.png" >
|
||||||
|
</li>
|
||||||
|
<br/>
|
||||||
|
<li>Add jav-File folder as library<br/>
|
||||||
|
At the moment no package system is implemented, Therefore the compiled class files are in the jav-File folder. This has to be added as library:<br/>
|
||||||
|
<img width= 550 src="buildPath1.png" ><br/><br/>
|
||||||
|
<img width= 550 src="buildPath2.png" ><br/><br/>
|
||||||
|
<img width= 400 src="buildPath3.png" ><br/><br/>
|
||||||
|
<img width= 550 src="buildPath4.png" ><br/>
|
||||||
|
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<body>
|
||||||
|
<h1></h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<address></address>
|
||||||
|
<!-- hhmts start -->Last modified: Fri Jun 1 16:50:02 CEST 2018 <!-- hhmts end -->
|
||||||
|
</body> </html>
|
BIN
Website/newJavaTXProject/newJavaTXProject.png
Normal file
After Width: | Height: | Size: 150 KiB |
24
Website/usePlugin/usePlugin.html
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<html> <head>
|
||||||
|
<title>Using the plugin</title>
|
||||||
|
</head>
|
||||||
|
<h2>Using the plugin</h2>
|
||||||
|
<ol>
|
||||||
|
<li>Overview<br/>
|
||||||
|
<img width=800 src="usePlugin1.png" >
|
||||||
|
</li>
|
||||||
|
<br/>
|
||||||
|
<li>Select types<br/>
|
||||||
|
If the method is overloaded the user can select types in the outline the right mouse button:<br/><br/>
|
||||||
|
<img src="usePlugin2.png" ><br/>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<body>
|
||||||
|
<h1></h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<address></address>
|
||||||
|
<!-- hhmts start -->Last modified: Fri Jun 1 16:51:28 CEST 2018 <!-- hhmts end -->
|
||||||
|
</body> </html>
|
BIN
Website/usePlugin/usePlugin1.png
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
Website/usePlugin/usePlugin2.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
doc/PluginBau.pdf
Normal file
@ -110,13 +110,6 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
TypeUnify unify = new TypeUnify();
|
TypeUnify unify = new TypeUnify();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
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();
|
Set<List<Constraint<UnifyPair>>> cardProd = unifyCons.cartesianProduct();
|
||||||
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
||||||
Set<UnifyPair> xConsSet = new HashSet<>();
|
Set<UnifyPair> xConsSet = new HashSet<>();
|
||||||
@ -175,15 +168,11 @@ 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, log);
|
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
|
||||||
//Set<Set<UnifyPair>> result = unify.unify(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);
|
results.addAll(result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (IOException e) { }
|
|
||||||
|
|
||||||
return results.stream().map((unifyPairs ->
|
return results.stream().map((unifyPairs ->
|
||||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
||||||
|
@ -33,4 +33,22 @@ public class TypeInsert {
|
|||||||
public String getInsertString(){
|
public String getInsertString(){
|
||||||
return point.getInsertString();
|
return point.getInsertString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PL 2018-06-18
|
||||||
|
* Zwei TypeInsert's sind gleich, wenn ihre point's und ihre inserts' gleich sind
|
||||||
|
* eingefuegt damit man TypeReplaceMarker vergleichen kann
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(!(obj instanceof TypeInsert)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ((TypeInsert)obj).point.equals(this.point);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
return point.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package de.dhbwstuttgart.typedeployment;
|
|||||||
|
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -25,4 +27,23 @@ public class TypeInsertPoint {
|
|||||||
public String getInsertString() {
|
public String getInsertString() {
|
||||||
return insertString;
|
return insertString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PL 2018-06-19
|
||||||
|
* Zwei TypeInsertPoint's sind gleich, wenn ihre point's gleich sind
|
||||||
|
* eingefuegt damit man TypeReplaceMarker vergleichen kann
|
||||||
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if(!(obj instanceof TypeInsertPoint)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ((TypeInsertPoint)obj).point.equals(this.point) &&
|
||||||
|
((TypeInsertPoint)obj).insertString.equals(this.insertString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return point.toString() + " " + insertString.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT){
|
unaryExpr.operation == UnaryExpr.Operation.PREINCREMENT){
|
||||||
//@see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.14.2
|
//@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
|
//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
|
//The type of the postfix increment expression is the type of the variable
|
||||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT));
|
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT));
|
||||||
}else{
|
}else{
|
||||||
|
@ -36,15 +36,10 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class RuleSet implements IRuleSet{
|
public class RuleSet implements IRuleSet{
|
||||||
|
|
||||||
FileWriter logFile;
|
|
||||||
|
|
||||||
RuleSet() {
|
RuleSet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleSet(FileWriter logFile) {
|
|
||||||
this.logFile = logFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<UnifyPair> reduceUp(UnifyPair pair) {
|
public Optional<UnifyPair> reduceUp(UnifyPair pair) {
|
||||||
|
@ -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, Boolean log) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true);
|
||||||
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, Boolean log) {
|
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
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?
|
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of setOps that will be used during the unification
|
* The implementation of setOps that will be used during the unification
|
||||||
@ -88,14 +87,12 @@ 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, Boolean log) {
|
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
||||||
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;
|
rules = new RuleSet();
|
||||||
this.log = log;
|
|
||||||
rules = new RuleSet(logFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -155,7 +152,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||||
*/
|
*/
|
||||||
nOfUnify++;
|
nOfUnify++;
|
||||||
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
|
||||||
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
|
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -231,10 +227,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// those pairs are contradictory and the unification is impossible.
|
// those pairs are contradictory and the unification is impossible.
|
||||||
if(!undefinedPairs.isEmpty()) {
|
if(!undefinedPairs.isEmpty()) {
|
||||||
noUndefPair++;
|
noUndefPair++;
|
||||||
for (UnifyPair up : undefinedPairs) {
|
|
||||||
writeLog(noUndefPair.toString() + " UndefinedPairs; " + up);
|
|
||||||
writeLog("BasePair; " + up.getBasePair());
|
|
||||||
}
|
|
||||||
Set<Set<UnifyPair>> error = new HashSet<>();
|
Set<Set<UnifyPair>> error = new HashSet<>();
|
||||||
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||||
error.add(undefinedPairs);
|
error.add(undefinedPairs);
|
||||||
@ -323,13 +315,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, log);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true);
|
||||||
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, log);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -340,13 +332,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent())
|
//PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent())
|
||||||
//PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst
|
//PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst
|
||||||
//eqPrimePrime Veraenderungen in subst repraesentieren.
|
//eqPrimePrime Veraenderungen in subst repraesentieren.
|
||||||
try {
|
|
||||||
if (isSolvedForm(eqPrime)) {
|
|
||||||
logFile.write(eqPrime.toString()+"\n");
|
|
||||||
logFile.flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e) { }
|
|
||||||
eqPrimePrimeSet.add(eqPrime);
|
eqPrimePrimeSet.add(eqPrime);
|
||||||
}
|
}
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
@ -377,8 +363,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* Step 7: Filter empty sets;
|
* Step 7: Filter empty sets;
|
||||||
*/
|
*/
|
||||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
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;
|
return eqPrimePrimeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +382,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||||
writeLog("nextSet: " + nextSet.toString());
|
|
||||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||||
try {
|
try {
|
||||||
//List<Set<UnifyPair>>
|
//List<Set<UnifyPair>>
|
||||||
@ -448,7 +431,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
System.out.print("");
|
System.out.print("");
|
||||||
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||||
System.out.print("");
|
System.out.print("");
|
||||||
writeLog("nextSetasList: " + nextSetasList.toString());
|
|
||||||
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
||||||
Set<UnifyPair> a = null;
|
Set<UnifyPair> a = null;
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
@ -569,16 +551,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//}
|
//}
|
||||||
return (!x.containsAll(durchschnitt));
|
return (!x.containsAll(durchschnitt));
|
||||||
}).collect(Collectors.toCollection(ArrayList::new));
|
}).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());
|
noAllErasedElements = noAllErasedElements + (len - nextSetasList.size());
|
||||||
writeLog("Number erased Elements (undef): " + noAllErasedElements.toString());
|
|
||||||
noBacktracking++;
|
noBacktracking++;
|
||||||
writeLog("Number of Backtracking: " + noBacktracking);
|
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
||||||
@ -1238,7 +1212,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
permuteParams(candidates, idx+1, result, current);
|
permuteParams(candidates, idx+1, result, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void writeLog(String str) {
|
void writeLog(String str) {
|
||||||
if (log) {
|
if (log) {
|
||||||
try {
|
try {
|
||||||
@ -1249,4 +1223,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
catch (IOException e) { }
|
catch (IOException e) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@ class Faculty {
|
|||||||
m () {
|
m () {
|
||||||
|
|
||||||
var fact = (Integer x) -> {
|
var fact = (Integer x) -> {
|
||||||
if (x == 1) {
|
//if (x == 1) {
|
||||||
return x;
|
return x;
|
||||||
}
|
//}
|
||||||
else {
|
//else {
|
||||||
return x * fact.apply(x-1);
|
//return x * (fact.apply(x-1));
|
||||||
}
|
//}
|
||||||
};
|
};
|
||||||
return fact;
|
return fact;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,13 @@ public class Lambda {
|
|||||||
var lam1 = (x) -> {
|
var lam1 = (x) -> {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
<<<<<<< HEAD
|
||||||
return lam1;
|
return lam1;
|
||||||
|
=======
|
||||||
|
|
||||||
|
return lam1.apply(new Apply());
|
||||||
|
//return lam1;
|
||||||
|
//return new Vector();
|
||||||
|
>>>>>>> 3fedbcc4a0e015ec8f5f6ccb77081f888135c850
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
import java.lang.String;
|
import java.lang.String;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.lang.Double;
|
import java.lang.Double;
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public class OL {
|
public class OL {
|
||||||
|
|
||||||
m(x) { return x + x; }
|
m(x) { return x + x; }
|
||||||
|
=======
|
||||||
|
class OL {
|
||||||
|
|
||||||
|
m(x) { return x + x; }
|
||||||
|
>>>>>>> 3fedbcc4a0e015ec8f5f6ccb77081f888135c850
|
||||||
|
|
||||||
//m(x) { return x || x; }
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public class OLMain {
|
public class OLMain {
|
||||||
|
=======
|
||||||
|
class OLMain {
|
||||||
|
>>>>>>> 3fedbcc4a0e015ec8f5f6ccb77081f888135c850
|
||||||
|
|
||||||
main(java.lang.Integer x) {
|
main(java.lang.Integer x) {
|
||||||
var ol;
|
var ol;
|
||||||
|
@ -3,7 +3,7 @@ class Apply { }
|
|||||||
public class Lambda {
|
public class Lambda {
|
||||||
|
|
||||||
m () {
|
m () {
|
||||||
var lam1 = (x) -> {
|
var lam1 = (Integer x) -> {
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
return lam1.apply(new Apply());
|
return lam1.apply(new Apply());
|
||||||
|
@ -81,16 +81,14 @@ public class UnifyTest {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void matrix() throws IOException, ClassNotFoundException {
|
public void matrix() throws IOException, ClassNotFoundException {
|
||||||
execute(new File(rootDirectory+"Matrix.jav"));
|
execute(new File(rootDirectory+"Matrix.jav"));
|
||||||
//JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"Matrix.jav"));
|
//JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"Matrix.jav"));
|
||||||
//compiler.generateBytecode();
|
//compiler.generateBytecode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void vector() throws IOException, ClassNotFoundException {
|
public void vector() throws IOException, ClassNotFoundException {
|
||||||
|