Compare commits
76 Commits
addPackage
...
refactorin
Author | SHA1 | Date | |
---|---|---|---|
c0c1cbd4b1 | |||
fc4d3abfe9 | |||
d3eb9f1e1c | |||
5ed6a4617a | |||
7139a1709e | |||
e9bcea4b9e | |||
1c9bc90201 | |||
5bfe2c906e | |||
d671e74fcf | |||
c2f0368d2e | |||
d06c6abb5a | |||
f7101da621 | |||
c0c24eed3b | |||
af36b43786 | |||
997d3b9bea | |||
ed7cc55139 | |||
29a7f2e7fb | |||
4ac67120a4 | |||
f0db6cb901 | |||
2e5581ab6e | |||
e8ac8e3c5a | |||
a4bc49f5c4 | |||
9cf7cec37b | |||
531b1ccd22 | |||
7ced6338cb | |||
0550f73ef7 | |||
b91aadf24a | |||
70b6c35731 | |||
e617a0911a | |||
7cf46b02b7 | |||
8cf57ba35b | |||
486d7d9011 | |||
8402d18f83 | |||
8d25920a87 | |||
ab9e9e16bd | |||
b45964ed5f | |||
0ecd3916f8 | |||
c86fe95da5 | |||
d677d053d6 | |||
5060cca6db | |||
7900449897 | |||
f6154b8f2c | |||
1d7c894f39 | |||
61f35f8f8b | |||
1e7c25805e | |||
5a00b70ea8 | |||
6e91e5c683 | |||
e4908557f4 | |||
ed550b1097 | |||
5fa1cf11ef | |||
723eca8658 | |||
071f4cd9ca | |||
cdc6a3f2dd | |||
cc6156695d | |||
1b6af9ab7e | |||
0861f74ce7 | |||
a11dc1ab22 | |||
df0d02cdea | |||
6afee86066 | |||
900a487d8a | |||
e07df035ea | |||
47ec1dca5a | |||
084b54d295 | |||
e305c3cb55 | |||
835f0755da | |||
14b127390e | |||
0c1337f84b | |||
5c1015b51e | |||
c52da7951a | |||
6dc15acba4 | |||
6cbabee65a | |||
c18daad047 | |||
1eaeca1db5 | |||
c0f5fd1e0a | |||
52b3498dfb | |||
7343ea1701 |
@ -1,22 +0,0 @@
|
||||
Repositories: Branches: JavaCompilerCore: simplyRes
|
||||
JavaCompilerPlugin: copy_libs
|
||||
JavaCompilerCore > mvn install -Dskip.test=true
|
||||
|
||||
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/target/JavaTXcompiler-0.2.jar to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2.jar
|
||||
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/pom.xml to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2.pom
|
||||
[INFO] Installing /Users/pl/workspace_oxygen/JavaCompilerCore/target/JavaTXcompiler-0.2-jar-with-dependencies.jar to /Users/pl/.m2/repository/de/dhbwstuttgart/JavaTXcompiler/0.2/JavaTXcompiler-0.2-jar-with-dependencies.jar
|
||||
[INFO] ------------------------------------------------------------------------
|
||||
[INFO] BUILD SUCCESS
|
||||
[INFO] ------------------------------------------------------------------------
|
||||
[INFO] Total time: 23.279 s
|
||||
[INFO] Finished at: 2019-09-17T09:31:30+02:00
|
||||
[INFO] -------------------------------------
|
||||
|
||||
JavaCompilerCore > cd target
|
||||
|
||||
JavaCompilerCore/target > cp JavaTXcompiler-0.2.jar ../../Plugin_JCC/JavaCompilerPlugin/bundles/JavaCompilerPlugin.Plugin/lib/JavaTXcompiler.jar
|
||||
|
||||
Im Eclipse: Plugin_JCC/JavaCompilerPlugin> mvn install
|
||||
|
||||
Plugin_JCC/JavaCompilerPlugin/releng/JavaCompilerPlugin.Update/target > cp JavaCompilerPlugin.Update-0.1.0-SNAPSHOT.zip ~/webdav/public_html/javatx/javatx_XXXXXX.zip
|
||||
|
@ -1,88 +0,0 @@
|
||||
<!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>
|
Before ![]() (image error) Size: 25 KiB |
Before ![]() (image error) Size: 80 KiB |
Before ![]() (image error) Size: 109 KiB |
@ -1,40 +0,0 @@
|
||||
<!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>
|
@ -1,40 +0,0 @@
|
||||
<!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>
|
Before ![]() (image error) Size: 32 KiB |
Before ![]() (image error) Size: 52 KiB |
Before ![]() (image error) Size: 61 KiB |
Before ![]() (image error) Size: 96 KiB |
Before ![]() (image error) Size: 93 KiB |
Before ![]() (image error) Size: 163 KiB |
Before ![]() (image error) Size: 163 KiB |
Before ![]() (image error) Size: 88 KiB |
Before ![]() (image error) Size: 50 KiB |
Before ![]() (image error) Size: 96 KiB |
Before ![]() (image error) Size: 102 KiB |
Before ![]() (image error) Size: 100 KiB |
Before ![]() (image error) Size: 76 KiB |
@ -1,34 +0,0 @@
|
||||
<!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>
|
Before ![]() (image error) Size: 150 KiB |
@ -1,24 +0,0 @@
|
||||
<!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>
|
Before ![]() (image error) Size: 112 KiB |
Before ![]() (image error) Size: 33 KiB |
@ -1,19 +0,0 @@
|
||||
# JavaTXCompiler Klasse
|
||||
* Konstruktor hat einen weiteren Parameter
|
||||
* contextPath
|
||||
* Arrays aus URLs (file-urls)
|
||||
* Parameter ist Optional
|
||||
* wird er gesetzt, so werden Classfiles aus den übergebenen Pfaden geladen
|
||||
* die übergebenen Pfade müssen dabei die Source-Roots sein
|
||||
* Beispiel:
|
||||
`import de.test.Klasse;`
|
||||
* `Klasse.class` liegt in `output/de/test/Klasse.class`
|
||||
* dann muss contextpath auf `output` gesetzt werden
|
||||
* wird der Parameter nicht übergeben, so wird der Sourceroot auf das Verzeichnis gesetzt, in dem der Compiler ausgeführt wird
|
||||
* dies ist das Verhalten vom javac Compiler
|
||||
|
||||
* generateBytecode - Methode hat neuen Parameter: path
|
||||
* wird hier null übergeben, so wird die class-File in den gleichen Ordner wie die übergebene .jav File geschrieben
|
||||
* wird hier ein Pfad übergeben, so gilt dieser als output root.
|
||||
* Klassen werden in outputRoot/package/name/KlassenName.class geschrieben
|
||||
|
73
pom.xml
@ -7,7 +7,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<artifactId>JavaTXcompiler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<version>0.2</version>
|
||||
<version>0.1</version>
|
||||
<name>JavaTXcompiler</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencies>
|
||||
@ -20,7 +20,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.8-1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
@ -63,10 +63,23 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<verbose>true</verbose>
|
||||
<fork>true</fork>
|
||||
<executable>/home/michael/programs/jdk/jdk8u232-b09/bin/javac</executable>
|
||||
<compilerVersion>1.8</compilerVersion>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin -->
|
||||
<plugin>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-maven-plugin</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.8-1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>antlr</id>
|
||||
@ -82,21 +95,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>aspParser</id>
|
||||
<goals>
|
||||
<goal>antlr4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/main/antlr4/sat</sourceDirectory>
|
||||
<outputDirectory>${project.basedir}/src/main/java/de/dhbwstuttgart/sat/asp/parser/antlr</outputDirectory>
|
||||
<arguments>
|
||||
<argument>-package</argument>
|
||||
<argument>de.dhbwstuttgart.sat.asp.parser.antlr</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -120,45 +118,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.reficio</groupId>
|
||||
<artifactId>p2-maven-plugin</artifactId>
|
||||
<version>1.1.2-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<artifacts>
|
||||
<!-- specify your depencies here -->
|
||||
<!-- groupId:artifactId:version -->
|
||||
<artifact>
|
||||
<id>de.dhbwstuttgart:JavaTXcompiler:0.2</id>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<id>org.reflections:reflections:0.9.11</id>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<id>com.google.guava:guava:22.0</id>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<id>javax.annotation:javax.annotation-api:1.3.1</id>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<id>org.glassfish:javax.annotation:3.1.1</id>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>reficio</id>
|
||||
<url>http://repo.reficio.org/maven/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-repository</id>
|
||||
@ -166,6 +127,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<tycho.version>0.23.0</tycho.version>
|
||||
|
@ -196,7 +196,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
cons.getParameterList().accept(this);
|
||||
if(cons.block != null)
|
||||
cons.block.accept(this);
|
||||
inMethod = true;
|
||||
inMethod = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints;
|
||||
@ -71,9 +72,10 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
||||
private Collection<ResultSet> listOfResultSets;
|
||||
private SourceFile sf;
|
||||
private List<String> tphsClass;
|
||||
private GenericGenratorResultForSourceFile generatedGenericsForSF;
|
||||
private GenericGenratorResultForSourceFile generatedGenericsForSF;//Ergebnis des GGenerics
|
||||
private ResultSet resultSet;
|
||||
private final List<String> methodNameAndParamsT = new ArrayList<>();
|
||||
private FamilyOfGeneratedGenerics fogg;
|
||||
|
||||
private String pkgName;
|
||||
private JavaClassName className;
|
||||
@ -131,6 +133,10 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
||||
tphExtractor.setResultSet(resultSet);
|
||||
resolver = new Resolver(resultSet);
|
||||
classOrInterface.accept(tphExtractor);
|
||||
//PL 2020-10-16: Ab hier GGenerics implementieren durch Ali
|
||||
//Rueckgabe an generatedGenericsForSF
|
||||
fogg = new FamilyOfGeneratedGenerics(tphExtractor);
|
||||
|
||||
tphsClass = tphExtractor.tphsClass;
|
||||
simplifiedConstraints = GenericsGenerator.simplifyConstraints(tphExtractor, tphsClass);
|
||||
if(!isVisited) {
|
||||
@ -145,8 +151,8 @@ public class GeneratedGenericsFinder implements ASTVisitor {
|
||||
|
||||
if(ggResult != null)
|
||||
generatedGenericsForSF.addGenericGeneratorResultClass(ggResult);
|
||||
|
||||
|
||||
System.out.println("ddd");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,9 +45,8 @@ public class GenericGenratorResultForSourceFile {
|
||||
return genericGeneratorResultForAllClasses.stream()
|
||||
.filter(sr -> sr.getClassName().equals(name))
|
||||
.findAny()
|
||||
.orElseThrow(() -> new NoSuchElementException(
|
||||
"Simplify results for the class " + pkgName + "." + name + " are not found"));
|
||||
.orElse(new GenericsGeneratorResultForClass(name));
|
||||
}
|
||||
throw new NoSuchElementException("Simplify results for the class " + pkgName + "." + name + " are not found");
|
||||
return new GenericsGeneratorResultForClass(name);
|
||||
}
|
||||
}
|
||||
|
19
src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResultForClass.java
@ -7,6 +7,9 @@ import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* @author fayez
|
||||
@ -58,12 +61,16 @@ public class GenericsGeneratorResultForClass {
|
||||
.anyMatch(i -> i.equals(id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<GenericsGeneratorResult> getMethodConstraintsByID(String id) {
|
||||
return methodsAndTheirConstraints.getMethodsAndConstraints().stream().filter(mc -> mc.getMethodID().equals(id))
|
||||
.findFirst().get().getConstraints();
|
||||
Optional<MethodAndConstraints> methodConstraints = methodsAndTheirConstraints.getMethodsAndConstraints()
|
||||
.stream()
|
||||
.filter(mc -> mc.getMethodID().equals(id))
|
||||
.findFirst();
|
||||
|
||||
if (methodConstraints.isPresent()) {
|
||||
return methodConstraints.get().getConstraints();
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
|
||||
public class ClassConstraint extends TPHConstraint {
|
||||
//private TPHConstraint constraint;
|
||||
|
||||
public ClassConstraint(String left, String right, Relation rel) {
|
||||
super(left, right, rel);
|
||||
}
|
||||
//besser?
|
||||
/*public ClassConstraint(TPHConstraint constraint) {
|
||||
this.constraint = constraint;
|
||||
}*/
|
||||
}
|
303
src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
Normal file
@ -0,0 +1,303 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FamilyOfGeneratedGenerics {
|
||||
public List<TPHConstraint> allConstraints = new ArrayList<>();
|
||||
// HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode
|
||||
public HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTPHs = new HashMap<>();
|
||||
public List<ClassConstraint> classConstraints = new ArrayList<>();
|
||||
public List<MethodConstraint> methodConstraints = new ArrayList<>();
|
||||
|
||||
public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) {
|
||||
this.allConstraints = tphExtractor.allCons;
|
||||
this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph);
|
||||
this.classConstraints = getClassConstraints(allConstraints,posOfTPHs);
|
||||
// this.methodConstraints =
|
||||
}
|
||||
|
||||
public static List<ClassConstraint> getClassConstraints(List<TPHConstraint> cs, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { //Inputparameter List<TPHConstraint> constraintsSet weg
|
||||
List<ClassConstraint> cs_cl = new ArrayList<>();
|
||||
List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(cs, posOfTphs);
|
||||
for (ClassConstraint cons: classConstraints1) {
|
||||
if (!checkForDuplicates(cons, cs_cl)) {
|
||||
cs_cl.add(cons);
|
||||
}
|
||||
}
|
||||
List<ClassConstraint> classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher
|
||||
for (ClassConstraint cons: classConstraints2) {
|
||||
if (!checkForDuplicates(cons, cs_cl)) {
|
||||
cs_cl.add(cons);
|
||||
}
|
||||
}
|
||||
List<ClassConstraint> classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs);
|
||||
for (ClassConstraint cons: classConstraints3) {
|
||||
if (!checkForDuplicates(cons, cs_cl)) {
|
||||
cs_cl.add(cons);
|
||||
}
|
||||
}
|
||||
return cs_cl;
|
||||
}
|
||||
|
||||
public static List<MethodConstraint> getMethodConstraints(List<TPHConstraint> cs, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) {
|
||||
//TODO: Regeln
|
||||
List<MethodConstraint> cs_m = new ArrayList<>();
|
||||
List<MethodConstraint> methodConstraints1 = typeOfTheMethodInClSigma(cs, cs_m, posOfTphs);
|
||||
for (MethodConstraint cons: methodConstraints1) {
|
||||
if (!checkForDuplicates(cons, cs_m)) {
|
||||
cs_m.add(cons);
|
||||
}
|
||||
}
|
||||
//List<MethodConstraint> methodConstraints2 = firstTransitiveSubtypeForMethodTypes();
|
||||
return cs_m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: erste Zeile von cs_cl
|
||||
* {T < .T' | T is a type variable in a type of a node of a field}
|
||||
*/
|
||||
public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) {
|
||||
//RuntimeException re = new RuntimeException("enthält EQUALS-Relation");
|
||||
List<ClassConstraint> tempCC= new ArrayList<>();
|
||||
for(TPHConstraint allCons: allConstraints){
|
||||
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
|
||||
for(String tph: posOfTphs.keySet()) {
|
||||
if(tph == allCons.getLeft() && posOfTphs.get(tph).fst == PositionFinder.Position.FIELD) {
|
||||
ClassConstraint consToAdd = new ClassConstraint(tph, allCons.getRight(), allCons.getRel());
|
||||
if (!checkForDuplicates(consToAdd, tempCC)) {
|
||||
tempCC.add(consToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*else if (allCons.getRel() != Relation.EXTENDS) {
|
||||
throw re;
|
||||
}*/
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: zweite Zeile von cs_cl
|
||||
* {T' <. T'' | \exists T: (T <. T') \in cs_cl, (T' <. T'') \in cs }
|
||||
*/
|
||||
public static List<ClassConstraint> transitiveSubtypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl) {
|
||||
List<ClassConstraint> tempCC= new ArrayList<>();
|
||||
for(ClassConstraint cCons: cs_cl) {
|
||||
if(cCons.getLeft() != null && cCons.getRel()==Relation.EXTENDS) {
|
||||
for(TPHConstraint allCons: allConstraints) {
|
||||
if(cCons.getRight() == allCons.getLeft() && allCons.getRight() != null && allCons.getRel()==Relation.EXTENDS){
|
||||
ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
|
||||
if (!checkForDuplicates(consToAdd, tempCC)) {
|
||||
tempCC.add(consToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: dritte Zeile von cs_cl
|
||||
* {T <. Object | ((T is a type variable in a type of a node of a field
|
||||
* or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
|
||||
*/
|
||||
public static List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) {
|
||||
List<ClassConstraint> tempCC= new ArrayList<>();
|
||||
for(TPHConstraint allCons: allConstraints) {
|
||||
for(ClassConstraint cCons: cs_cl) {
|
||||
for(String tph: posOfTphs.keySet()) {
|
||||
boolean tvInField = posOfTphs.get(tph).fst == PositionFinder.Position.FIELD;
|
||||
boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null);
|
||||
if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) &&
|
||||
checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) {
|
||||
ClassConstraint consToAdd = new ClassConstraint(tph, "Object", Relation.EXTENDS);
|
||||
if (!checkForDuplicates(consToAdd, tempCC)){
|
||||
tempCC.add(consToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
public static boolean checkUpperBound(List<TPHConstraint> cs, String tph) {
|
||||
for(int i=0; i<cs.size(); i++) {
|
||||
if(cs.get(i).getLeft() == tph) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: erste Zeile von cs_m
|
||||
* {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
|
||||
*/
|
||||
|
||||
public static List<MethodConstraint> typeOfTheMethodInClSigma(List<TPHConstraint> allConstraints, List<MethodConstraint> cs_m, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { // cl_\sigma??
|
||||
//TODO:
|
||||
List<MethodConstraint> tempCC= new ArrayList<>();
|
||||
for(TPHConstraint allCons: allConstraints){
|
||||
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
|
||||
for(String tph: posOfTphs.keySet()) {
|
||||
if(tph == allCons.getLeft() && (posOfTphs.get(tph).fst == PositionFinder.Position.METHOD || posOfTphs.get(tph).fst == PositionFinder.Position.CONSTRUCTOR)) {
|
||||
MethodConstraint consToAdd = new MethodConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
|
||||
if (!checkForDuplicates(consToAdd, tempCC)) {
|
||||
tempCC.add(consToAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Def. FGG: zweite Zeile von cs_m
|
||||
* {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs}
|
||||
*/
|
||||
|
||||
public static List<MethodConstraint> firstTransitiveSubtypeForMethodTypes(List<TPHConstraint> allConstraints, List<MethodConstraint> cs_m, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { //transitive closure of cs
|
||||
//TODO:
|
||||
List<MethodConstraint> tempCC= new ArrayList<>();
|
||||
List<TPHConstraint> tcOfCs = buildTransitiveClosure(allConstraints);
|
||||
for(MethodConstraint mC1 : cs_m) {
|
||||
for(MethodConstraint mC2 : cs_m) {
|
||||
String rightSide = mC1.getRight();
|
||||
String leftSide = mC2.getLeft();
|
||||
for(TPHConstraint tphC : tcOfCs) {
|
||||
if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) {
|
||||
tempCC.add((MethodConstraint) tphC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: dritte Zeile von cs_m
|
||||
* {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs}
|
||||
*/
|
||||
|
||||
public static List<MethodConstraint> secondTransitiveSubtypeForMethodTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, List<MethodConstraint> cs_m, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) {
|
||||
//TODO:
|
||||
List<MethodConstraint> tempCC= new ArrayList<>();
|
||||
List<TPHConstraint> tcOfCs = buildTransitiveClosure(allConstraints);
|
||||
for(ClassConstraint cC : cs_cl) {
|
||||
for(MethodConstraint mC : cs_m) {
|
||||
String rightSide = mC.getRight();
|
||||
String leftSide = cC.getLeft();
|
||||
for(TPHConstraint tphC : tcOfCs) {
|
||||
if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) {
|
||||
tempCC.add((MethodConstraint) tphC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempCC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Def. FGG: vierte Zeile von cs_m
|
||||
* {T <. Object | (T is a type variable in a type of a node of the method/constructor m in cl_\sigma),
|
||||
* (\existsnot T': T <. T') \in cs)}
|
||||
*/
|
||||
|
||||
public static List<MethodConstraint> hasNoSupertypeForMethodTypes() {
|
||||
//TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* nimm die Menge cs_cl aus cs_m raus
|
||||
*/
|
||||
public static List<MethodConstraint> methodTypesWithoutClassTypes() {
|
||||
//TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkForDuplicates(TPHConstraint constraint, List list) {
|
||||
List<TPHConstraint> tempList = list;
|
||||
boolean hasSame = false;
|
||||
for (TPHConstraint tphC: tempList) {
|
||||
hasSame = constraint.getLeft() == tphC.getLeft() &&
|
||||
constraint.getRight() == tphC.getRight() &&
|
||||
constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if true
|
||||
if (hasSame)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<TPHConstraint> buildTransitiveClosure(List list) {
|
||||
List<TPHConstraint> iterList = new ArrayList<>(list);
|
||||
List<TPHConstraint> runList = new ArrayList<>(list);
|
||||
List<TPHConstraint> tcList = new ArrayList<>(list);
|
||||
boolean addedConToList = false;
|
||||
for (TPHConstraint cons: iterList) {
|
||||
for (TPHConstraint cons2: runList) {
|
||||
if(cons.getRight() == cons2.getLeft()) {
|
||||
TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS);
|
||||
if (!checkForDuplicates(consToAdd,tcList)) {
|
||||
tcList.add(consToAdd);
|
||||
addedConToList = true;
|
||||
if (addedConToList) {
|
||||
return buildTransitiveClosure(tcList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tcList;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, PairTphMethod<PositionFinder.Position, String>> positionConverter(HashMap<String, Boolean> allTphs, List<MethodAndTPH> listOfMethodsAndTphs) {
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> convertedPositions = new HashMap<>();
|
||||
for(String tph: allTphs.keySet()) {
|
||||
if(allTphs.get(tph)) { //if true, then tph is a method-TPH
|
||||
for(MethodAndTPH methTph: listOfMethodsAndTphs) {
|
||||
if (methTph.getTphs().contains(tph)) {
|
||||
convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.METHOD, methTph.getId()));
|
||||
}
|
||||
}
|
||||
} else { // else it is in the class-TPH
|
||||
convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.FIELD, null));
|
||||
}
|
||||
}
|
||||
return convertedPositions;
|
||||
}
|
||||
|
||||
/* public PositionFinder.Position positionConverter(TPHExtractor tphExtractor) {
|
||||
if(tphExtractor.allTPHS.keySet())
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* GeneratedGenericsFinder genGenFinder;
|
||||
ConstraintsSimplierResult simplifiedConstraints = null;
|
||||
GenericsGeneratorResultForClass ggResult = null;
|
||||
Method m;
|
||||
|
||||
public void addMethodConstraints(List<MethodConstraint> cs_m) {
|
||||
genGenFinder.addMethodConstraints(simplifiedConstraints, ggResult, m);
|
||||
cs_m.add();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
package de.dhbwstuttgart.bytecode.gGenericsAli;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
*/
|
||||
/**
|
||||
* gets set of typed variable constraints with substitutions and the set of typed classes
|
||||
* and returns the set of families of generated generics and the set of families of type variable mappings
|
||||
*//*
|
||||
|
||||
public class GGenerics implements preGGenerics {
|
||||
private TVarConstraints tVarCons;
|
||||
private Substitutions subst;
|
||||
private TClass typedClass;
|
||||
|
||||
|
||||
public GGenerics(TVarConstraints tVarCons, Substitutions subst, TClass typedClass) throws IOException, ClassNotFoundException {
|
||||
this.tVarCons = tVarCons;
|
||||
this.subst = subst;
|
||||
this.typedClass = typedClass;
|
||||
}
|
||||
|
||||
List<File> input = new ArrayList<>();
|
||||
List<File> classpath = new ArrayList<>();
|
||||
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(input, classpath);
|
||||
compiler.typeInference();
|
||||
|
||||
public List<ResultSet> getResultOfTypeInference() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
@ -0,0 +1,9 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
|
||||
public class MethodConstraint extends TPHConstraint {
|
||||
public MethodConstraint(String left, String right, Relation rel) {
|
||||
super(left, right, rel);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/** A generic class for pairs.
|
||||
*
|
||||
* <p><b>This is NOT part of any supported API.
|
||||
* If you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
|
||||
|
||||
public class PairTphMethod<A, B> {
|
||||
public final A fst;
|
||||
public final B snd;
|
||||
|
||||
public PairTphMethod(A fst, B snd) {
|
||||
this.fst = fst;
|
||||
this.snd = snd;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "PairTphMethod[" + fst + "," + snd + "]";
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
return
|
||||
other instanceof PairTphMethod<?,?> &&
|
||||
Objects.equals(fst, ((PairTphMethod<?,?>)other).fst) &&
|
||||
Objects.equals(snd, ((PairTphMethod<?,?>)other).snd);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1;
|
||||
else if (snd == null) return fst.hashCode() + 2;
|
||||
else return fst.hashCode() * 17 + snd.hashCode();
|
||||
}
|
||||
|
||||
public static <A,B> PairTphMethod<A,B> of(A a, B b) {
|
||||
return new PairTphMethod<>(a,b);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class PositionFinder{
|
||||
static HashMap<String, PairTphMethod<Position, String>> posOfTphs = new HashMap<String, PairTphMethod<Position, String>>();
|
||||
|
||||
static PairTphMethod<Position, String> whichMethod; // gibt an, in welcher Methode sich TPH befindet (Position.METHOD, id_of_method)
|
||||
|
||||
public enum Position{
|
||||
METHOD,
|
||||
CONSTRUCTOR,
|
||||
FIELD
|
||||
}
|
||||
|
||||
public static HashMap<String, PairTphMethod<Position, String>> getPositionOfTPH(SourceFile sf, Set<String> tphs) {
|
||||
|
||||
new Walker().visit(sf);
|
||||
for (String tph: posOfTphs.keySet()) {
|
||||
System.out.println(tph + " " + posOfTphs.get(tph));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static void putPositionInMethod(String tph, String methodId) {
|
||||
posOfTphs.put(tph, new PairTphMethod<>(Position.METHOD, methodId));
|
||||
}
|
||||
|
||||
public static void putPositionInField(String tph) {
|
||||
posOfTphs.put(tph, new PairTphMethod<>(Position.FIELD, null));
|
||||
}
|
||||
|
||||
public static void putPositionInConstructor(String tph, String id) {
|
||||
posOfTphs.put(tph, new PairTphMethod<>(Position.CONSTRUCTOR, id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static class Walker extends AbstractASTWalker{
|
||||
Boolean inMethod = false;
|
||||
Boolean inConstructor = false;
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder tph) {
|
||||
if (inMethod) {
|
||||
if (inConstructor) {
|
||||
// System.out.println(tph);
|
||||
// putPositionInConstructor(tph.getName(),);
|
||||
}
|
||||
// System.out.println(tph);
|
||||
// putPositionInMethod(tph.getName(),);
|
||||
} else {
|
||||
putPositionInField(tph.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
super.visit(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
inMethod = true;
|
||||
super.visit(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor cons) {
|
||||
inConstructor = true;
|
||||
super.visit(cons);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package de.dhbwstuttgart.bytecode.insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
interface preGGenerics {
|
||||
public List<ResultSet> getResultOfTypeInference();
|
||||
}
|
@ -20,12 +20,10 @@ import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.TypeScope;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
@ -48,51 +46,35 @@ import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListener;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||
import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.apache.commons.io.output.NullOutputStream;
|
||||
|
||||
|
||||
public class JavaTXCompiler {
|
||||
|
||||
public static JavaTXCompiler INSTANCE;
|
||||
//public static JavaTXCompiler INSTANCE;
|
||||
final CompilationEnvironment environment;
|
||||
Boolean resultmodel = true;
|
||||
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?
|
||||
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||
this(Arrays.asList(sourceFile), null);
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException {
|
||||
this(sourceFile);
|
||||
this.log = log;
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
public JavaTXCompiler(List<File> sourceFiles) throws IOException, ClassNotFoundException {
|
||||
this(sourceFiles, null);
|
||||
INSTANCE = this;
|
||||
}
|
||||
public JavaTXCompiler(List<File> sources, List<File> contextPath) throws IOException, ClassNotFoundException {
|
||||
if(contextPath == null || contextPath.isEmpty()){
|
||||
@ -104,7 +86,7 @@ public class JavaTXCompiler {
|
||||
for (File s : sources) {
|
||||
sourceFiles.put(s, parse(s));
|
||||
}
|
||||
INSTANCE = this;
|
||||
//INSTANCE = this;
|
||||
}
|
||||
|
||||
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException, IOException {
|
||||
@ -199,7 +181,7 @@ public class JavaTXCompiler {
|
||||
|
||||
|
||||
public List<ClassOrInterface> getAvailableClasses(SourceFile forSourceFile) throws ClassNotFoundException {
|
||||
//PL 2018-09-18: List durch Set ersetzt, damit die Klassen nur einmal hinzugefuegt werden
|
||||
//PL 2018-09-18: List durch Set ersetzt, damit die Klassen nur einmal hinzugefuegt werden
|
||||
//List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||
Set<ClassOrInterface> allClasses = new HashSet<>();
|
||||
|
||||
@ -234,321 +216,6 @@ public class JavaTXCompiler {
|
||||
return new ArrayList<>(allClasses);
|
||||
}
|
||||
|
||||
/*
|
||||
* public List<ResultSet> typeInferenceOld() throws ClassNotFoundException {
|
||||
* List<ClassOrInterface> allClasses = new
|
||||
* ArrayList<>();//environment.getAllAvailableClasses(); //Alle Importierten
|
||||
* Klassen in allen geparsten Sourcefiles kommen ins FC for(SourceFile sf :
|
||||
* this.sourceFiles.values()) { allClasses.addAll(getAvailableClasses(sf));
|
||||
* allClasses.addAll(sf.getClasses()); }
|
||||
*
|
||||
* final ConstraintSet<Pair> cons = getConstraints();
|
||||
*
|
||||
* FiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses);
|
||||
* System.out.println(finiteClosure); ConstraintSet<UnifyPair> unifyCons =
|
||||
* UnifyTypeFactory.convert(cons);
|
||||
*
|
||||
* TypeUnify unify = new TypeUnify(); Set<Set<UnifyPair>> results = new
|
||||
* HashSet<>(); try { File logPath = new
|
||||
* File(System.getProperty("user.dir")+"/target/logFiles/"); logPath.mkdirs();
|
||||
* FileWriter logFile = new FileWriter(new File(logPath, "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<>(); for
|
||||
* (Constraint<UnifyPair> constraint : xCons) { xConsSet.addAll(constraint); }
|
||||
* //.collect(Collectors.toCollection(ArrayList::new))))
|
||||
* System.out.println(xConsSet); Set<String> methodParaTypeVarNames =
|
||||
* allClasses.stream().map(x -> x.getMethods().stream().map(y ->
|
||||
* y.getParameterList().getFormalparalist() .stream().filter(z -> z.getType()
|
||||
* instanceof TypePlaceholder) .map(z ->
|
||||
* ((TypePlaceholder)z.getType()).getName()).collect(Collectors.toCollection(
|
||||
* HashSet::new))) .reduce(new HashSet<String>(), (a,b) -> { a.addAll(b); return
|
||||
* a;}, (a,b) -> { a.addAll(b); return a;} ) ) .reduce(new HashSet<String>(),
|
||||
* (a,b) -> { a.addAll(b); return a;} );
|
||||
*
|
||||
* Set<String> constructorParaTypeVarNames = allClasses.stream().map(x ->
|
||||
* x.getConstructors().stream().map(y ->
|
||||
* y.getParameterList().getFormalparalist() .stream().filter(z -> z.getType()
|
||||
* instanceof TypePlaceholder) .map(z ->
|
||||
* ((TypePlaceholder)z.getType()).getName()).collect(Collectors.toCollection(
|
||||
* HashSet::new))) .reduce(new HashSet<String>(), (a,b) -> { a.addAll(b); return
|
||||
* a;}, (a,b) -> { a.addAll(b); return a;} ) ) .reduce(new HashSet<String>(),
|
||||
* (a,b) -> { a.addAll(b); return a;} );
|
||||
*
|
||||
* Set<String> paraTypeVarNames = methodParaTypeVarNames;
|
||||
* paraTypeVarNames.addAll(constructorParaTypeVarNames);
|
||||
*
|
||||
* Set<String> returnTypeVarNames = allClasses.stream().map(x ->
|
||||
* x.getMethods().stream().filter(y -> y.getReturnType() instanceof
|
||||
* TypePlaceholder) .map(z ->
|
||||
* ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.
|
||||
* toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;}
|
||||
* ).get();
|
||||
*
|
||||
* Set<String> fieldTypeVarNames = allClasses.stream().map(x ->
|
||||
* x.getFieldDecl().stream().filter(y -> y.getReturnType() instanceof
|
||||
* TypePlaceholder) .map(z ->
|
||||
* ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.
|
||||
* toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;}
|
||||
* ).get();
|
||||
*
|
||||
* returnTypeVarNames.addAll(fieldTypeVarNames);
|
||||
*
|
||||
* xConsSet = xConsSet.stream().map(x -> { //Hier muss ueberlegt werden, ob //1.
|
||||
* alle Argument- und Retuntyp-Variablen in allen UnifyPairs // mit
|
||||
* disableWildcardtable() werden. //2. alle Typvariablen mit Argument- oder
|
||||
* Retuntyp-Variablen //in Beziehung auch auf disableWildcardtable() gesetzt
|
||||
* werden muessen //PL 2018-04-23 if ((x.getLhsType() instanceof
|
||||
* PlaceholderType)) { if (paraTypeVarNames.contains(x.getLhsType().getName()))
|
||||
* { ((PlaceholderType)x.getLhsType()).setVariance((byte)1);
|
||||
* ((PlaceholderType)x.getLhsType()).disableWildcardtable(); } if
|
||||
* (returnTypeVarNames.contains(x.getLhsType().getName())) {
|
||||
* ((PlaceholderType)x.getLhsType()).setVariance((byte)-1);
|
||||
* ((PlaceholderType)x.getLhsType()).disableWildcardtable(); } } if
|
||||
* ((x.getRhsType() instanceof PlaceholderType)) { if
|
||||
* (paraTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
* ((PlaceholderType)x.getRhsType()).setVariance((byte)1);
|
||||
* ((PlaceholderType)x.getRhsType()).disableWildcardtable(); } if
|
||||
* (returnTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
* ((PlaceholderType)x.getRhsType()).setVariance((byte)-1);
|
||||
* ((PlaceholderType)x.getRhsType()).disableWildcardtable(); } } return x;//HIER
|
||||
* DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS
|
||||
* ANDERE SEITE }).map( y -> { if ((y.getLhsType() instanceof PlaceholderType)
|
||||
* && (y.getRhsType() instanceof PlaceholderType)) { if
|
||||
* (((PlaceholderType)y.getLhsType()).getVariance() != 0 &&
|
||||
* ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||
* ((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType(
|
||||
* )).getVariance()); } if (((PlaceholderType)y.getLhsType()).getVariance() == 0
|
||||
* && ((PlaceholderType)y.getRhsType()).getVariance() != 0) {
|
||||
* ((PlaceholderType)y.getLhsType()).setVariance(((PlaceholderType)y.getRhsType(
|
||||
* )).getVariance()); } } return y; } )
|
||||
* .collect(Collectors.toCollection(HashSet::new));
|
||||
* varianceInheritance(xConsSet); Set<Set<UnifyPair>> result =
|
||||
* unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||
* //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 = results.stream().map(x -> { Optional<Set<UnifyPair>> res = new
|
||||
* RuleSet().subst(x.stream().map(y -> { if (y.getPairOp() ==
|
||||
* PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); return y;
|
||||
* //alle Paare a <.? b erden durch a =. b ersetzt
|
||||
* }).collect(Collectors.toCollection(HashSet::new))); if (res.isPresent())
|
||||
* {//wenn subst ein Erg liefert wurde was veraendert return new
|
||||
* TypeUnifyTask().applyTypeUnificationRules(res.get(), finiteClosure); } else
|
||||
* return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
||||
* }).collect(Collectors.toCollection(HashSet::new));
|
||||
* System.out.println("RESULT Final: " + results); logFile.write("RES_FINAL: " +
|
||||
* results.toString()+"\n"); logFile.flush(); logFile.write("PLACEHOLDERS: " +
|
||||
* PlaceholderType.EXISTING_PLACEHOLDERS); logFile.flush(); } catch (IOException
|
||||
* e) { e.printStackTrace(); } return results.stream().map((unifyPairs -> new
|
||||
* ResultSet(UnifyTypeFactory.convert(unifyPairs,
|
||||
* generateTPHMap(cons))))).collect(Collectors.toList()); }
|
||||
*/
|
||||
/**
|
||||
* Vererbt alle Variancen bei Paaren (a <. theta) oder (Theta <. a) wenn a eine
|
||||
* Variance !=0 hat auf alle Typvariablen in Theta.
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* private void varianceInheritance(Set<UnifyPair> eq) { Set<PlaceholderType>
|
||||
* usedTPH = new HashSet<>(); Set<PlaceholderType> phSet = eq.stream().map(x ->
|
||||
* { Set<PlaceholderType> pair = new HashSet<>(); if (x.getLhsType() instanceof
|
||||
* PlaceholderType) pair.add((PlaceholderType)x.getLhsType()); if
|
||||
* (x.getRhsType() instanceof PlaceholderType)
|
||||
* pair.add((PlaceholderType)x.getRhsType()); return pair; }).reduce(new
|
||||
* HashSet<>(), (a,b) -> { a.addAll(b); return a;} , (c,d) -> { c.addAll(d);
|
||||
* return c;});
|
||||
*
|
||||
* ArrayList<PlaceholderType> phSetVariance = new ArrayList<>(phSet);
|
||||
* phSetVariance.removeIf(x -> (x.getVariance() == 0));
|
||||
* while(!phSetVariance.isEmpty()) { PlaceholderType a =
|
||||
* phSetVariance.remove(0); usedTPH.add(a); //HashMap<PlaceholderType,Integer>
|
||||
* ht = new HashMap<>(); //ht.put(a, a.getVariance()); Set<UnifyPair> eq1 = new
|
||||
* HashSet<>(eq); eq1.removeIf(x -> !(x.getLhsType() instanceof PlaceholderType
|
||||
* && ((PlaceholderType)x.getLhsType()).equals(a))); eq1.stream().forEach(x -> {
|
||||
* x.getRhsType().accept(new distributeVariance(), a.getVariance());}); eq1 =
|
||||
* new HashSet<>(eq); eq1.removeIf(x -> !(x.getRhsType() instanceof
|
||||
* PlaceholderType && ((PlaceholderType)x.getRhsType()).equals(a)));
|
||||
* eq1.stream().forEach(x -> { x.getLhsType().accept(new distributeVariance(),
|
||||
* a.getVariance());}); phSetVariance = new ArrayList<>(phSet);
|
||||
* phSetVariance.removeIf(x -> (x.getVariance() == 0 || usedTPH.contains(x))); }
|
||||
* }
|
||||
*/
|
||||
|
||||
public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener, Writer logFile)
|
||||
throws ClassNotFoundException, IOException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
||||
for (File f : this.sourceFiles.keySet()) {
|
||||
SourceFile sf = sourceFiles.get(f);
|
||||
allClasses.addAll(getAvailableClasses(sf));
|
||||
allClasses.addAll(sf.getClasses());
|
||||
allClasses.addAll(CompilationEnvironment.loadDefaultPackageClasses(f,classLoader).stream().map(ASTFactory::createClass).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
final ConstraintSet<Pair> cons = getConstraints();
|
||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||
UnifyResultModel urm = null;
|
||||
// urm.addUnifyResultListener(resultListener);
|
||||
try {
|
||||
logFile = logFile == null
|
||||
? new FileWriter(new File("log_" + sourceFiles.keySet().iterator().next().getName()))
|
||||
: logFile;
|
||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
||||
System.out.println(finiteClosure);
|
||||
urm = new UnifyResultModel(cons, finiteClosure);
|
||||
urm.addUnifyResultListener(resultListener);
|
||||
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
||||
|
||||
Function<UnifyPair, UnifyPair> distributeInnerVars = x -> {
|
||||
UnifyType lhs, rhs;
|
||||
if (((lhs = x.getLhsType()) instanceof PlaceholderType)
|
||||
&& ((rhs = x.getRhsType()) instanceof PlaceholderType)
|
||||
&& (((PlaceholderType) lhs).isInnerType() || ((PlaceholderType) rhs).isInnerType())) {
|
||||
((PlaceholderType) lhs).setInnerType(true);
|
||||
((PlaceholderType) rhs).setInnerType(true);
|
||||
}
|
||||
return x;
|
||||
|
||||
};
|
||||
logFile.write(unifyCons.toString());
|
||||
unifyCons = unifyCons.map(distributeInnerVars);
|
||||
logFile.write(unifyCons.toString());
|
||||
TypeUnify unify = new TypeUnify();
|
||||
// Set<Set<UnifyPair>> results = new HashSet<>(); Nach vorne gezogen
|
||||
logFile.write("FC:\\" + finiteClosure.toString() + "\n");
|
||||
for (SourceFile sf : this.sourceFiles.values()) {
|
||||
logFile.write(ASTTypePrinter.print(sf));
|
||||
}
|
||||
logFile.flush();
|
||||
|
||||
Set<String> methodParaTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream()
|
||||
.map(y -> y.getParameterList().getFormalparalist().stream()
|
||||
.filter(z -> z.getType() instanceof TypePlaceholder)
|
||||
.map(z -> ((TypePlaceholder) z.getType()).getName())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.reduce(new HashSet<String>(), (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}, (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
})).reduce(new HashSet<String>(), (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
});
|
||||
|
||||
Set<String> constructorParaTypeVarNames = allClasses.stream().map(x -> x.getConstructors().stream()
|
||||
.map(y -> y.getParameterList().getFormalparalist().stream()
|
||||
.filter(z -> z.getType() instanceof TypePlaceholder)
|
||||
.map(z -> ((TypePlaceholder) z.getType()).getName())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.reduce(new HashSet<String>(), (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}, (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
})).reduce(new HashSet<String>(), (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
});
|
||||
|
||||
Set<String> paraTypeVarNames = methodParaTypeVarNames;
|
||||
paraTypeVarNames.addAll(constructorParaTypeVarNames);
|
||||
|
||||
Set<String> returnTypeVarNames = allClasses.stream()
|
||||
.map(x -> x.getMethods().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
||||
.map(z -> ((TypePlaceholder) z.getReturnType()).getName())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.reduce((a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}).get();
|
||||
|
||||
Set<String> fieldTypeVarNames = allClasses.stream()
|
||||
.map(x -> x.getFieldDecl().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
||||
.map(z -> ((TypePlaceholder) z.getReturnType()).getName())
|
||||
.collect(Collectors.toCollection(HashSet::new)))
|
||||
.reduce((a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}).get();
|
||||
|
||||
returnTypeVarNames.addAll(fieldTypeVarNames);
|
||||
|
||||
unifyCons = unifyCons.map(x -> {
|
||||
// Hier muss ueberlegt werden, ob
|
||||
// 1. alle Argument- und Retuntyp-Variablen in allen UnifyPairs
|
||||
// mit disableWildcardtable() werden.
|
||||
// 2. alle Typvariablen mit Argument- oder Retuntyp-Variablen
|
||||
// in Beziehung auch auf disableWildcardtable() gesetzt werden muessen
|
||||
// PL 2018-04-23
|
||||
if ((x.getLhsType() instanceof PlaceholderType)) {
|
||||
if (paraTypeVarNames.contains(x.getLhsType().getName())) {
|
||||
((PlaceholderType) x.getLhsType()).setVariance((byte) 1);
|
||||
((PlaceholderType) x.getLhsType()).disableWildcardtable();
|
||||
}
|
||||
if (returnTypeVarNames.contains(x.getLhsType().getName())) {
|
||||
((PlaceholderType) x.getLhsType()).setVariance((byte) -1);
|
||||
((PlaceholderType) x.getLhsType()).disableWildcardtable();
|
||||
}
|
||||
}
|
||||
if ((x.getRhsType() instanceof PlaceholderType)) {
|
||||
if (paraTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
((PlaceholderType) x.getRhsType()).setVariance((byte) 1);
|
||||
((PlaceholderType) x.getRhsType()).disableWildcardtable();
|
||||
}
|
||||
if (returnTypeVarNames.contains(x.getRhsType().getName())) {
|
||||
((PlaceholderType) x.getRhsType()).setVariance((byte) -1);
|
||||
((PlaceholderType) x.getRhsType()).disableWildcardtable();
|
||||
}
|
||||
}
|
||||
return x;// HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE
|
||||
// JEWEILS ANDERE SEITE
|
||||
});
|
||||
Set<PlaceholderType> varianceTPHold;
|
||||
Set<PlaceholderType> varianceTPH = new HashSet<>();
|
||||
varianceTPH = varianceInheritanceConstraintSet(unifyCons);
|
||||
|
||||
/*
|
||||
* PL 2018-11-07 wird in varianceInheritanceConstraintSet erledigt do { //PL
|
||||
* 2018-11-05 Huellenbildung Variance auf alle TPHs der Terme auf der jeweiligen
|
||||
* //anderen Seite übertragen varianceTPHold = new HashSet<>(varianceTPH);
|
||||
* varianceTPH = varianceInheritanceConstraintSet(unifyCons); unifyCons.map( y
|
||||
* -> { if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType()
|
||||
* instanceof PlaceholderType)) { if
|
||||
* (((PlaceholderType)y.getLhsType()).getVariance() != 0 &&
|
||||
* ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||
* ((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType(
|
||||
* )).getVariance()); } if (((PlaceholderType)y.getLhsType()).getVariance() == 0
|
||||
* && ((PlaceholderType)y.getRhsType()).getVariance() != 0) {
|
||||
* ((PlaceholderType)y.getLhsType()).setVariance(((PlaceholderType)y.getRhsType(
|
||||
* )).getVariance()); } } return y; } ); } while
|
||||
* (!varianceTPHold.equals(varianceTPH));
|
||||
*/
|
||||
|
||||
// Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure,
|
||||
// logFile, log);
|
||||
// Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
List<Set<Constraint<UnifyPair>>> oderConstraints = unifyCons.getOderConstraints()/*.stream().map(x -> {
|
||||
Set<Set<UnifyPair>> ret = new HashSet<>();
|
||||
for (Constraint<UnifyPair> y : x) {
|
||||
ret.add(new HashSet<>(y));
|
||||
}
|
||||
return ret;
|
||||
}).collect(Collectors.toCollection(ArrayList::new))*/;
|
||||
unify.unifyAsync(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||
usedTasks);
|
||||
} catch (IOException e) {
|
||||
System.err.println("kein LogFile");
|
||||
}
|
||||
return urm;
|
||||
}
|
||||
|
||||
public List<ResultSet> typeInference() throws ClassNotFoundException, IOException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||
@ -697,46 +364,12 @@ public class JavaTXCompiler {
|
||||
}
|
||||
})));
|
||||
*/
|
||||
|
||||
System.out.println("Unify nach Oder-Constraints-Anpassung:" + unifyCons.toString());
|
||||
Set<PlaceholderType> varianceTPHold;
|
||||
Set<PlaceholderType> varianceTPH = new HashSet<>();
|
||||
varianceTPH = varianceInheritanceConstraintSet(unifyCons);
|
||||
|
||||
/*
|
||||
* PL 2018-11-07 wird in varianceInheritanceConstraintSet erledigt do { //PL
|
||||
* 2018-11-05 Huellenbildung Variance auf alle TPHs der Terme auf der jeweiligen
|
||||
* //anderen Seite übertragen varianceTPHold = new HashSet<>(varianceTPH);
|
||||
* varianceTPH = varianceInheritanceConstraintSet(unifyCons); unifyCons.map( y
|
||||
* -> { if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType()
|
||||
* instanceof PlaceholderType)) { if
|
||||
* (((PlaceholderType)y.getLhsType()).getVariance() != 0 &&
|
||||
* ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||
* ((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType(
|
||||
* )).getVariance()); } if (((PlaceholderType)y.getLhsType()).getVariance() == 0
|
||||
* && ((PlaceholderType)y.getRhsType()).getVariance() != 0) {
|
||||
* ((PlaceholderType)y.getLhsType()).setVariance(((PlaceholderType)y.getRhsType(
|
||||
* )).getVariance()); } } return y; } ); } while
|
||||
* (!varianceTPHold.equals(varianceTPH));
|
||||
*/
|
||||
|
||||
// Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure,
|
||||
// logFile, log);
|
||||
// Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
List<Set<Constraint<UnifyPair>>> oderConstraints = unifyCons.getOderConstraints()//.stream().map(x -> {
|
||||
/*Set<Set<UnifyPair>> ret = new HashSet<>();
|
||||
for (Constraint<UnifyPair> y : x) {
|
||||
ret.add(new HashSet<>(y));
|
||||
}
|
||||
return ret;
|
||||
}).collect(Collectors.toCollection(ArrayList::new))*/;
|
||||
List<Set<Constraint<UnifyPair>>> oderConstraints = unifyCons.getOderConstraints();
|
||||
if (resultmodel) {
|
||||
/* UnifyResultModel Anfang */
|
||||
UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure);
|
||||
UnifyResultListenerImpl li = new UnifyResultListenerImpl();
|
||||
urm.addUnifyResultListener(li);
|
||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm,
|
||||
usedTasks);
|
||||
unify.unifyParallel(unifyCons.getUndConstraints(), oderConstraints, finiteClosure, logFile, log, urm);
|
||||
System.out.println("RESULT Final: " + li.getResults());
|
||||
logFile.write("RES_FINAL: " + li.getResults().toString() + "\n");
|
||||
logFile.flush();
|
||||
@ -748,7 +381,7 @@ public class JavaTXCompiler {
|
||||
// oderConstraints, finiteClosure, logFile, log, new UnifyResultModel(cons,
|
||||
// finiteClosure));
|
||||
Set<Set<UnifyPair>> result = unify.unifyOderConstraints(unifyCons.getUndConstraints(), oderConstraints,
|
||||
finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure), usedTasks);
|
||||
finiteClosure, logFile, log, new UnifyResultModel(cons, finiteClosure));
|
||||
System.out.println("RESULT: " + result);
|
||||
logFile.write("RES: " + result.toString() + "\n");
|
||||
logFile.flush();
|
||||
@ -899,6 +532,10 @@ public class JavaTXCompiler {
|
||||
/**
|
||||
* @param path - can be null, then class file output is in the same directory as the parsed source files
|
||||
*/
|
||||
List<ResultSet> typeinferenceResult = this.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = getGeneratedGenericResultsForAllSourceFiles(
|
||||
typeinferenceResult);
|
||||
generateBytecode(path, typeinferenceResult, simplifyResultsForAllSourceFiles);
|
||||
public void generateBytecode(File path) throws ClassNotFoundException, IOException, BytecodeGeneratorError {
|
||||
List<ResultSet> typeinferenceResult = this.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = getGeneratedGenericResultsForAllSourceFiles(
|
||||
|
@ -360,7 +360,7 @@ public class SyntaxTreeGenerator{
|
||||
&& fieldDeclarationContext.unannTypeOrAuto().unannType() != null){
|
||||
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannTypeOrAuto().unannType(), reg, generics);
|
||||
}else{
|
||||
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.getStart());
|
||||
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.variableDeclaratorList().getStart()); //PL 2019-12-06: variableDeclaratorList() eingefuegt, um als Token nicht die Modifier zu bekommen
|
||||
}
|
||||
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
|
||||
String fieldName = convert(varCtx.variableDeclaratorId());
|
||||
|
207
src/main/java/de/dhbwstuttgart/parser/antlr/Java8.tokens
Normal file
@ -0,0 +1,207 @@
|
||||
T__0=1
|
||||
ABSTRACT=2
|
||||
ASSERT=3
|
||||
BOOLEAN=4
|
||||
BREAK=5
|
||||
BYTE=6
|
||||
CASE=7
|
||||
CATCH=8
|
||||
CHAR=9
|
||||
CLASS=10
|
||||
CONST=11
|
||||
CONTINUE=12
|
||||
DEFAULT=13
|
||||
DO=14
|
||||
DOUBLE=15
|
||||
ELSE=16
|
||||
ENUM=17
|
||||
EXTENDS=18
|
||||
FINAL=19
|
||||
FINALLY=20
|
||||
FLOAT=21
|
||||
FOR=22
|
||||
IF=23
|
||||
GOTO=24
|
||||
IMPLEMENTS=25
|
||||
IMPORT=26
|
||||
INSTANCEOF=27
|
||||
INT=28
|
||||
INTERFACE=29
|
||||
LONG=30
|
||||
NATIVE=31
|
||||
NEW=32
|
||||
PACKAGE=33
|
||||
PRIVATE=34
|
||||
PROTECTED=35
|
||||
PUBLIC=36
|
||||
RETURN=37
|
||||
SHORT=38
|
||||
STATIC=39
|
||||
STRICTFP=40
|
||||
SUPER=41
|
||||
SWITCH=42
|
||||
SYNCHRONIZED=43
|
||||
THIS=44
|
||||
THROW=45
|
||||
THROWS=46
|
||||
TRANSIENT=47
|
||||
TRY=48
|
||||
VOID=49
|
||||
VOLATILE=50
|
||||
WHILE=51
|
||||
IntegerLiteral=52
|
||||
FloatingPointLiteral=53
|
||||
BooleanLiteral=54
|
||||
CharacterLiteral=55
|
||||
StringLiteral=56
|
||||
NullLiteral=57
|
||||
LPAREN=58
|
||||
RPAREN=59
|
||||
LBRACE=60
|
||||
RBRACE=61
|
||||
LBRACK=62
|
||||
RBRACK=63
|
||||
SEMI=64
|
||||
COMMA=65
|
||||
DOT=66
|
||||
ASSIGN=67
|
||||
GT=68
|
||||
LT=69
|
||||
BANG=70
|
||||
TILDE=71
|
||||
QUESTION=72
|
||||
COLON=73
|
||||
EQUAL=74
|
||||
LE=75
|
||||
GE=76
|
||||
NOTEQUAL=77
|
||||
AND=78
|
||||
OR=79
|
||||
INC=80
|
||||
DEC=81
|
||||
ADD=82
|
||||
SUB=83
|
||||
MUL=84
|
||||
DIV=85
|
||||
BITAND=86
|
||||
BITOR=87
|
||||
CARET=88
|
||||
MOD=89
|
||||
ARROW=90
|
||||
COLONCOLON=91
|
||||
ADD_ASSIGN=92
|
||||
SUB_ASSIGN=93
|
||||
MUL_ASSIGN=94
|
||||
DIV_ASSIGN=95
|
||||
AND_ASSIGN=96
|
||||
OR_ASSIGN=97
|
||||
XOR_ASSIGN=98
|
||||
MOD_ASSIGN=99
|
||||
LSHIFT_ASSIGN=100
|
||||
RSHIFT_ASSIGN=101
|
||||
URSHIFT_ASSIGN=102
|
||||
Identifier=103
|
||||
AT=104
|
||||
ELLIPSIS=105
|
||||
WS=106
|
||||
COMMENT=107
|
||||
LINE_COMMENT=108
|
||||
'var'=1
|
||||
'abstract'=2
|
||||
'assert'=3
|
||||
'boolean'=4
|
||||
'break'=5
|
||||
'byte'=6
|
||||
'case'=7
|
||||
'catch'=8
|
||||
'char'=9
|
||||
'class'=10
|
||||
'const'=11
|
||||
'continue'=12
|
||||
'default'=13
|
||||
'do'=14
|
||||
'double'=15
|
||||
'else'=16
|
||||
'enum'=17
|
||||
'extends'=18
|
||||
'final'=19
|
||||
'finally'=20
|
||||
'float'=21
|
||||
'for'=22
|
||||
'if'=23
|
||||
'goto'=24
|
||||
'implements'=25
|
||||
'import'=26
|
||||
'instanceof'=27
|
||||
'int'=28
|
||||
'interface'=29
|
||||
'long'=30
|
||||
'native'=31
|
||||
'new'=32
|
||||
'package'=33
|
||||
'private'=34
|
||||
'protected'=35
|
||||
'public'=36
|
||||
'return'=37
|
||||
'short'=38
|
||||
'static'=39
|
||||
'strictfp'=40
|
||||
'super'=41
|
||||
'switch'=42
|
||||
'synchronized'=43
|
||||
'this'=44
|
||||
'throw'=45
|
||||
'throws'=46
|
||||
'transient'=47
|
||||
'try'=48
|
||||
'void'=49
|
||||
'volatile'=50
|
||||
'while'=51
|
||||
'null'=57
|
||||
'('=58
|
||||
')'=59
|
||||
'{'=60
|
||||
'}'=61
|
||||
'['=62
|
||||
']'=63
|
||||
';'=64
|
||||
','=65
|
||||
'.'=66
|
||||
'='=67
|
||||
'>'=68
|
||||
'<'=69
|
||||
'!'=70
|
||||
'~'=71
|
||||
'?'=72
|
||||
':'=73
|
||||
'=='=74
|
||||
'<='=75
|
||||
'>='=76
|
||||
'!='=77
|
||||
'&&'=78
|
||||
'||'=79
|
||||
'++'=80
|
||||
'--'=81
|
||||
'+'=82
|
||||
'-'=83
|
||||
'*'=84
|
||||
'/'=85
|
||||
'&'=86
|
||||
'|'=87
|
||||
'^'=88
|
||||
'%'=89
|
||||
'->'=90
|
||||
'::'=91
|
||||
'+='=92
|
||||
'-='=93
|
||||
'*='=94
|
||||
'/='=95
|
||||
'&='=96
|
||||
'|='=97
|
||||
'^='=98
|
||||
'%='=99
|
||||
'<<='=100
|
||||
'>>='=101
|
||||
'>>>='=102
|
||||
'@'=104
|
||||
'...'=105
|
2895
src/main/java/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java
Normal file
593
src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.java
Normal file
@ -0,0 +1,593 @@
|
||||
// Generated from Java8.g4 by ANTLR 4.7
|
||||
package de.dhbwstuttgart.parser.antlr;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.antlr.v4.runtime.TokenStream;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class Java8Lexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, ABSTRACT=2, ASSERT=3, BOOLEAN=4, BREAK=5, BYTE=6, CASE=7, CATCH=8,
|
||||
CHAR=9, CLASS=10, CONST=11, CONTINUE=12, DEFAULT=13, DO=14, DOUBLE=15,
|
||||
ELSE=16, ENUM=17, EXTENDS=18, FINAL=19, FINALLY=20, FLOAT=21, FOR=22,
|
||||
IF=23, GOTO=24, IMPLEMENTS=25, IMPORT=26, INSTANCEOF=27, INT=28, INTERFACE=29,
|
||||
LONG=30, NATIVE=31, NEW=32, PACKAGE=33, PRIVATE=34, PROTECTED=35, PUBLIC=36,
|
||||
RETURN=37, SHORT=38, STATIC=39, STRICTFP=40, SUPER=41, SWITCH=42, SYNCHRONIZED=43,
|
||||
THIS=44, THROW=45, THROWS=46, TRANSIENT=47, TRY=48, VOID=49, VOLATILE=50,
|
||||
WHILE=51, IntegerLiteral=52, FloatingPointLiteral=53, BooleanLiteral=54,
|
||||
CharacterLiteral=55, StringLiteral=56, NullLiteral=57, LPAREN=58, RPAREN=59,
|
||||
LBRACE=60, RBRACE=61, LBRACK=62, RBRACK=63, SEMI=64, COMMA=65, DOT=66,
|
||||
ASSIGN=67, GT=68, LT=69, BANG=70, TILDE=71, QUESTION=72, COLON=73, EQUAL=74,
|
||||
LE=75, GE=76, NOTEQUAL=77, AND=78, OR=79, INC=80, DEC=81, ADD=82, SUB=83,
|
||||
MUL=84, DIV=85, BITAND=86, BITOR=87, CARET=88, MOD=89, ARROW=90, COLONCOLON=91,
|
||||
ADD_ASSIGN=92, SUB_ASSIGN=93, MUL_ASSIGN=94, DIV_ASSIGN=95, AND_ASSIGN=96,
|
||||
OR_ASSIGN=97, XOR_ASSIGN=98, MOD_ASSIGN=99, LSHIFT_ASSIGN=100, RSHIFT_ASSIGN=101,
|
||||
URSHIFT_ASSIGN=102, Identifier=103, AT=104, ELLIPSIS=105, WS=106, COMMENT=107,
|
||||
LINE_COMMENT=108;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
public static final String[] ruleNames = {
|
||||
"T__0", "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", "CATCH",
|
||||
"CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", "ELSE",
|
||||
"ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO", "IMPLEMENTS",
|
||||
"IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE", "NEW", "PACKAGE",
|
||||
"PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT", "STATIC", "STRICTFP",
|
||||
"SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW", "THROWS", "TRANSIENT",
|
||||
"TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", "DecimalIntegerLiteral",
|
||||
"HexIntegerLiteral", "OctalIntegerLiteral", "BinaryIntegerLiteral", "IntegerTypeSuffix",
|
||||
"DecimalNumeral", "Digits", "Digit", "NonZeroDigit", "DigitsAndUnderscores",
|
||||
"DigitOrUnderscore", "Underscores", "HexNumeral", "HexDigits", "HexDigit",
|
||||
"HexDigitsAndUnderscores", "HexDigitOrUnderscore", "OctalNumeral", "OctalDigits",
|
||||
"OctalDigit", "OctalDigitsAndUnderscores", "OctalDigitOrUnderscore", "BinaryNumeral",
|
||||
"BinaryDigits", "BinaryDigit", "BinaryDigitsAndUnderscores", "BinaryDigitOrUnderscore",
|
||||
"FloatingPointLiteral", "DecimalFloatingPointLiteral", "ExponentPart",
|
||||
"ExponentIndicator", "SignedInteger", "Sign", "FloatTypeSuffix", "HexadecimalFloatingPointLiteral",
|
||||
"HexSignificand", "BinaryExponent", "BinaryExponentIndicator", "BooleanLiteral",
|
||||
"CharacterLiteral", "SingleCharacter", "StringLiteral", "StringCharacters",
|
||||
"StringCharacter", "EscapeSequence", "OctalEscape", "ZeroToThree", "UnicodeEscape",
|
||||
"NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK",
|
||||
"SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION",
|
||||
"COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", "ADD",
|
||||
"SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", "COLONCOLON",
|
||||
"ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "AND_ASSIGN",
|
||||
"OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", "RSHIFT_ASSIGN",
|
||||
"URSHIFT_ASSIGN", "Identifier", "JavaLetter", "JavaLetterOrDigit", "AT",
|
||||
"ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT"
|
||||
};
|
||||
|
||||
private static final String[] _LITERAL_NAMES = {
|
||||
null, "'var'", "'abstract'", "'assert'", "'boolean'", "'break'", "'byte'",
|
||||
"'case'", "'catch'", "'char'", "'class'", "'const'", "'continue'", "'default'",
|
||||
"'do'", "'double'", "'else'", "'enum'", "'extends'", "'final'", "'finally'",
|
||||
"'float'", "'for'", "'if'", "'goto'", "'implements'", "'import'", "'instanceof'",
|
||||
"'int'", "'interface'", "'long'", "'native'", "'new'", "'package'", "'private'",
|
||||
"'protected'", "'public'", "'return'", "'short'", "'static'", "'strictfp'",
|
||||
"'super'", "'switch'", "'synchronized'", "'this'", "'throw'", "'throws'",
|
||||
"'transient'", "'try'", "'void'", "'volatile'", "'while'", null, null,
|
||||
null, null, null, "'null'", "'('", "')'", "'{'", "'}'", "'['", "']'",
|
||||
"';'", "','", "'.'", "'='", "'>'", "'<'", "'!'", "'~'", "'?'", "':'",
|
||||
"'=='", "'<='", "'>='", "'!='", "'&&'", "'||'", "'++'", "'--'", "'+'",
|
||||
"'-'", "'*'", "'/'", "'&'", "'|'", "'^'", "'%'", "'->'", "'::'", "'+='",
|
||||
"'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'%='", "'<<='", "'>>='",
|
||||
"'>>>='", null, "'@'", "'...'"
|
||||
};
|
||||
private static final String[] _SYMBOLIC_NAMES = {
|
||||
null, null, "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE",
|
||||
"CATCH", "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE",
|
||||
"ELSE", "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO",
|
||||
"IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE",
|
||||
"NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT",
|
||||
"STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW",
|
||||
"THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral",
|
||||
"FloatingPointLiteral", "BooleanLiteral", "CharacterLiteral", "StringLiteral",
|
||||
"NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK",
|
||||
"SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION",
|
||||
"COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", "ADD",
|
||||
"SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", "COLONCOLON",
|
||||
"ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "AND_ASSIGN",
|
||||
"OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", "RSHIFT_ASSIGN",
|
||||
"URSHIFT_ASSIGN", "Identifier", "AT", "ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT"
|
||||
};
|
||||
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #VOCABULARY} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String[] tokenNames;
|
||||
static {
|
||||
tokenNames = new String[_SYMBOLIC_NAMES.length];
|
||||
for (int i = 0; i < tokenNames.length; i++) {
|
||||
tokenNames[i] = VOCABULARY.getLiteralName(i);
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = VOCABULARY.getSymbolicName(i);
|
||||
}
|
||||
|
||||
if (tokenNames[i] == null) {
|
||||
tokenNames[i] = "<INVALID>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String[] getTokenNames() {
|
||||
return tokenNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public Vocabulary getVocabulary() {
|
||||
return VOCABULARY;
|
||||
}
|
||||
|
||||
|
||||
public Java8Lexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "Java8.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public String[] getChannelNames() { return channelNames; }
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() { return modeNames; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
@Override
|
||||
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
|
||||
switch (ruleIndex) {
|
||||
case 147:
|
||||
return JavaLetter_sempred((RuleContext)_localctx, predIndex);
|
||||
case 148:
|
||||
return JavaLetterOrDigit_sempred((RuleContext)_localctx, predIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean JavaLetter_sempred(RuleContext _localctx, int predIndex) {
|
||||
switch (predIndex) {
|
||||
case 0:
|
||||
return Character.isJavaIdentifierStart(_input.LA(-1));
|
||||
case 1:
|
||||
return Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean JavaLetterOrDigit_sempred(RuleContext _localctx, int predIndex) {
|
||||
switch (predIndex) {
|
||||
case 2:
|
||||
return Character.isJavaIdentifierPart(_input.LA(-1));
|
||||
case 3:
|
||||
return Character.isJavaIdentifierPart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2n\u044e\b\1\4\2\t"+
|
||||
"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
|
||||
"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
|
||||
"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
|
||||
"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
|
||||
"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
|
||||
",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
|
||||
"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
|
||||
"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
|
||||
"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT"+
|
||||
"\4U\tU\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4^\t^\4_\t_\4"+
|
||||
"`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\4g\tg\4h\th\4i\ti\4j\tj\4k\t"+
|
||||
"k\4l\tl\4m\tm\4n\tn\4o\to\4p\tp\4q\tq\4r\tr\4s\ts\4t\tt\4u\tu\4v\tv\4"+
|
||||
"w\tw\4x\tx\4y\ty\4z\tz\4{\t{\4|\t|\4}\t}\4~\t~\4\177\t\177\4\u0080\t\u0080"+
|
||||
"\4\u0081\t\u0081\4\u0082\t\u0082\4\u0083\t\u0083\4\u0084\t\u0084\4\u0085"+
|
||||
"\t\u0085\4\u0086\t\u0086\4\u0087\t\u0087\4\u0088\t\u0088\4\u0089\t\u0089"+
|
||||
"\4\u008a\t\u008a\4\u008b\t\u008b\4\u008c\t\u008c\4\u008d\t\u008d\4\u008e"+
|
||||
"\t\u008e\4\u008f\t\u008f\4\u0090\t\u0090\4\u0091\t\u0091\4\u0092\t\u0092"+
|
||||
"\4\u0093\t\u0093\4\u0094\t\u0094\4\u0095\t\u0095\4\u0096\t\u0096\4\u0097"+
|
||||
"\t\u0097\4\u0098\t\u0098\4\u0099\t\u0099\4\u009a\t\u009a\4\u009b\t\u009b"+
|
||||
"\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3"+
|
||||
"\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\6\3\7"+
|
||||
"\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3"+
|
||||
"\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3"+
|
||||
"\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16"+
|
||||
"\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21"+
|
||||
"\3\21\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23"+
|
||||
"\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25"+
|
||||
"\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\31"+
|
||||
"\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32"+
|
||||
"\3\32\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34"+
|
||||
"\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36"+
|
||||
"\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \3 \3"+
|
||||
" \3!\3!\3!\3!\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3#"+
|
||||
"\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&"+
|
||||
"\3&\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)"+
|
||||
"\3)\3)\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3,\3,\3,"+
|
||||
"\3,\3,\3,\3,\3,\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3/\3/\3/"+
|
||||
"\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61"+
|
||||
"\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63"+
|
||||
"\3\64\3\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\5\65\u0293\n\65\3\66"+
|
||||
"\3\66\5\66\u0297\n\66\3\67\3\67\5\67\u029b\n\67\38\38\58\u029f\n8\39\3"+
|
||||
"9\59\u02a3\n9\3:\3:\3;\3;\3;\5;\u02aa\n;\3;\3;\3;\5;\u02af\n;\5;\u02b1"+
|
||||
"\n;\3<\3<\5<\u02b5\n<\3<\5<\u02b8\n<\3=\3=\5=\u02bc\n=\3>\3>\3?\6?\u02c1"+
|
||||
"\n?\r?\16?\u02c2\3@\3@\5@\u02c7\n@\3A\6A\u02ca\nA\rA\16A\u02cb\3B\3B\3"+
|
||||
"B\3B\3C\3C\5C\u02d4\nC\3C\5C\u02d7\nC\3D\3D\3E\6E\u02dc\nE\rE\16E\u02dd"+
|
||||
"\3F\3F\5F\u02e2\nF\3G\3G\5G\u02e6\nG\3G\3G\3H\3H\5H\u02ec\nH\3H\5H\u02ef"+
|
||||
"\nH\3I\3I\3J\6J\u02f4\nJ\rJ\16J\u02f5\3K\3K\5K\u02fa\nK\3L\3L\3L\3L\3"+
|
||||
"M\3M\5M\u0302\nM\3M\5M\u0305\nM\3N\3N\3O\6O\u030a\nO\rO\16O\u030b\3P\3"+
|
||||
"P\5P\u0310\nP\3Q\3Q\5Q\u0314\nQ\3R\3R\3R\5R\u0319\nR\3R\5R\u031c\nR\3"+
|
||||
"R\5R\u031f\nR\3R\3R\3R\5R\u0324\nR\3R\5R\u0327\nR\3R\3R\3R\5R\u032c\n"+
|
||||
"R\3R\3R\3R\5R\u0331\nR\3S\3S\3S\3T\3T\3U\5U\u0339\nU\3U\3U\3V\3V\3W\3"+
|
||||
"W\3X\3X\3X\5X\u0344\nX\3Y\3Y\5Y\u0348\nY\3Y\3Y\3Y\5Y\u034d\nY\3Y\3Y\5"+
|
||||
"Y\u0351\nY\3Z\3Z\3Z\3[\3[\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3\\\5\\\u0361"+
|
||||
"\n\\\3]\3]\3]\3]\3]\3]\3]\3]\5]\u036b\n]\3^\3^\3_\3_\5_\u0371\n_\3_\3"+
|
||||
"_\3`\6`\u0376\n`\r`\16`\u0377\3a\3a\5a\u037c\na\3b\3b\3b\3b\5b\u0382\n"+
|
||||
"b\3c\3c\3c\3c\3c\3c\3c\3c\3c\3c\3c\5c\u038f\nc\3d\3d\3e\3e\3e\3e\3e\3"+
|
||||
"e\3e\3f\3f\3f\3f\3f\3g\3g\3h\3h\3i\3i\3j\3j\3k\3k\3l\3l\3m\3m\3n\3n\3"+
|
||||
"o\3o\3p\3p\3q\3q\3r\3r\3s\3s\3t\3t\3u\3u\3v\3v\3w\3w\3w\3x\3x\3x\3y\3"+
|
||||
"y\3y\3z\3z\3z\3{\3{\3{\3|\3|\3|\3}\3}\3}\3~\3~\3~\3\177\3\177\3\u0080"+
|
||||
"\3\u0080\3\u0081\3\u0081\3\u0082\3\u0082\3\u0083\3\u0083\3\u0084\3\u0084"+
|
||||
"\3\u0085\3\u0085\3\u0086\3\u0086\3\u0087\3\u0087\3\u0087\3\u0088\3\u0088"+
|
||||
"\3\u0088\3\u0089\3\u0089\3\u0089\3\u008a\3\u008a\3\u008a\3\u008b\3\u008b"+
|
||||
"\3\u008b\3\u008c\3\u008c\3\u008c\3\u008d\3\u008d\3\u008d\3\u008e\3\u008e"+
|
||||
"\3\u008e\3\u008f\3\u008f\3\u008f\3\u0090\3\u0090\3\u0090\3\u0091\3\u0091"+
|
||||
"\3\u0091\3\u0091\3\u0092\3\u0092\3\u0092\3\u0092\3\u0093\3\u0093\3\u0093"+
|
||||
"\3\u0093\3\u0093\3\u0094\3\u0094\7\u0094\u0414\n\u0094\f\u0094\16\u0094"+
|
||||
"\u0417\13\u0094\3\u0095\3\u0095\3\u0095\3\u0095\3\u0095\3\u0095\5\u0095"+
|
||||
"\u041f\n\u0095\3\u0096\3\u0096\3\u0096\3\u0096\3\u0096\3\u0096\5\u0096"+
|
||||
"\u0427\n\u0096\3\u0097\3\u0097\3\u0098\3\u0098\3\u0098\3\u0098\3\u0099"+
|
||||
"\6\u0099\u0430\n\u0099\r\u0099\16\u0099\u0431\3\u0099\3\u0099\3\u009a"+
|
||||
"\3\u009a\3\u009a\3\u009a\7\u009a\u043a\n\u009a\f\u009a\16\u009a\u043d"+
|
||||
"\13\u009a\3\u009a\3\u009a\3\u009a\3\u009a\3\u009a\3\u009b\3\u009b\3\u009b"+
|
||||
"\3\u009b\7\u009b\u0448\n\u009b\f\u009b\16\u009b\u044b\13\u009b\3\u009b"+
|
||||
"\3\u009b\3\u043b\2\u009c\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f"+
|
||||
"\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63"+
|
||||
"\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62"+
|
||||
"c\63e\64g\65i\66k\2m\2o\2q\2s\2u\2w\2y\2{\2}\2\177\2\u0081\2\u0083\2\u0085"+
|
||||
"\2\u0087\2\u0089\2\u008b\2\u008d\2\u008f\2\u0091\2\u0093\2\u0095\2\u0097"+
|
||||
"\2\u0099\2\u009b\2\u009d\2\u009f\2\u00a1\67\u00a3\2\u00a5\2\u00a7\2\u00a9"+
|
||||
"\2\u00ab\2\u00ad\2\u00af\2\u00b1\2\u00b3\2\u00b5\2\u00b78\u00b99\u00bb"+
|
||||
"\2\u00bd:\u00bf\2\u00c1\2\u00c3\2\u00c5\2\u00c7\2\u00c9\2\u00cb;\u00cd"+
|
||||
"<\u00cf=\u00d1>\u00d3?\u00d5@\u00d7A\u00d9B\u00dbC\u00ddD\u00dfE\u00e1"+
|
||||
"F\u00e3G\u00e5H\u00e7I\u00e9J\u00ebK\u00edL\u00efM\u00f1N\u00f3O\u00f5"+
|
||||
"P\u00f7Q\u00f9R\u00fbS\u00fdT\u00ffU\u0101V\u0103W\u0105X\u0107Y\u0109"+
|
||||
"Z\u010b[\u010d\\\u010f]\u0111^\u0113_\u0115`\u0117a\u0119b\u011bc\u011d"+
|
||||
"d\u011fe\u0121f\u0123g\u0125h\u0127i\u0129\2\u012b\2\u012dj\u012fk\u0131"+
|
||||
"l\u0133m\u0135n\3\2\30\4\2NNnn\3\2\63;\4\2ZZzz\5\2\62;CHch\3\2\629\4\2"+
|
||||
"DDdd\3\2\62\63\4\2GGgg\4\2--//\6\2FFHHffhh\4\2RRrr\4\2))^^\4\2$$^^\n\2"+
|
||||
"$$))^^ddhhppttvv\3\2\62\65\6\2&&C\\aac|\4\2\2\u0081\ud802\udc01\3\2\ud802"+
|
||||
"\udc01\3\2\udc02\ue001\7\2&&\62;C\\aac|\5\2\13\f\16\17\"\"\4\2\f\f\17"+
|
||||
"\17\2\u045c\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2"+
|
||||
"\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27"+
|
||||
"\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2"+
|
||||
"\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2"+
|
||||
"\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2"+
|
||||
"\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2"+
|
||||
"\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S"+
|
||||
"\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2"+
|
||||
"\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2\u00a1\3"+
|
||||
"\2\2\2\2\u00b7\3\2\2\2\2\u00b9\3\2\2\2\2\u00bd\3\2\2\2\2\u00cb\3\2\2\2"+
|
||||
"\2\u00cd\3\2\2\2\2\u00cf\3\2\2\2\2\u00d1\3\2\2\2\2\u00d3\3\2\2\2\2\u00d5"+
|
||||
"\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2\2\2\u00dd\3\2\2"+
|
||||
"\2\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e3\3\2\2\2\2\u00e5\3\2\2\2\2\u00e7"+
|
||||
"\3\2\2\2\2\u00e9\3\2\2\2\2\u00eb\3\2\2\2\2\u00ed\3\2\2\2\2\u00ef\3\2\2"+
|
||||
"\2\2\u00f1\3\2\2\2\2\u00f3\3\2\2\2\2\u00f5\3\2\2\2\2\u00f7\3\2\2\2\2\u00f9"+
|
||||
"\3\2\2\2\2\u00fb\3\2\2\2\2\u00fd\3\2\2\2\2\u00ff\3\2\2\2\2\u0101\3\2\2"+
|
||||
"\2\2\u0103\3\2\2\2\2\u0105\3\2\2\2\2\u0107\3\2\2\2\2\u0109\3\2\2\2\2\u010b"+
|
||||
"\3\2\2\2\2\u010d\3\2\2\2\2\u010f\3\2\2\2\2\u0111\3\2\2\2\2\u0113\3\2\2"+
|
||||
"\2\2\u0115\3\2\2\2\2\u0117\3\2\2\2\2\u0119\3\2\2\2\2\u011b\3\2\2\2\2\u011d"+
|
||||
"\3\2\2\2\2\u011f\3\2\2\2\2\u0121\3\2\2\2\2\u0123\3\2\2\2\2\u0125\3\2\2"+
|
||||
"\2\2\u0127\3\2\2\2\2\u012d\3\2\2\2\2\u012f\3\2\2\2\2\u0131\3\2\2\2\2\u0133"+
|
||||
"\3\2\2\2\2\u0135\3\2\2\2\3\u0137\3\2\2\2\5\u013b\3\2\2\2\7\u0144\3\2\2"+
|
||||
"\2\t\u014b\3\2\2\2\13\u0153\3\2\2\2\r\u0159\3\2\2\2\17\u015e\3\2\2\2\21"+
|
||||
"\u0163\3\2\2\2\23\u0169\3\2\2\2\25\u016e\3\2\2\2\27\u0174\3\2\2\2\31\u017a"+
|
||||
"\3\2\2\2\33\u0183\3\2\2\2\35\u018b\3\2\2\2\37\u018e\3\2\2\2!\u0195\3\2"+
|
||||
"\2\2#\u019a\3\2\2\2%\u019f\3\2\2\2\'\u01a7\3\2\2\2)\u01ad\3\2\2\2+\u01b5"+
|
||||
"\3\2\2\2-\u01bb\3\2\2\2/\u01bf\3\2\2\2\61\u01c2\3\2\2\2\63\u01c7\3\2\2"+
|
||||
"\2\65\u01d2\3\2\2\2\67\u01d9\3\2\2\29\u01e4\3\2\2\2;\u01e8\3\2\2\2=\u01f2"+
|
||||
"\3\2\2\2?\u01f7\3\2\2\2A\u01fe\3\2\2\2C\u0202\3\2\2\2E\u020a\3\2\2\2G"+
|
||||
"\u0212\3\2\2\2I\u021c\3\2\2\2K\u0223\3\2\2\2M\u022a\3\2\2\2O\u0230\3\2"+
|
||||
"\2\2Q\u0237\3\2\2\2S\u0240\3\2\2\2U\u0246\3\2\2\2W\u024d\3\2\2\2Y\u025a"+
|
||||
"\3\2\2\2[\u025f\3\2\2\2]\u0265\3\2\2\2_\u026c\3\2\2\2a\u0276\3\2\2\2c"+
|
||||
"\u027a\3\2\2\2e\u027f\3\2\2\2g\u0288\3\2\2\2i\u0292\3\2\2\2k\u0294\3\2"+
|
||||
"\2\2m\u0298\3\2\2\2o\u029c\3\2\2\2q\u02a0\3\2\2\2s\u02a4\3\2\2\2u\u02b0"+
|
||||
"\3\2\2\2w\u02b2\3\2\2\2y\u02bb\3\2\2\2{\u02bd\3\2\2\2}\u02c0\3\2\2\2\177"+
|
||||
"\u02c6\3\2\2\2\u0081\u02c9\3\2\2\2\u0083\u02cd\3\2\2\2\u0085\u02d1\3\2"+
|
||||
"\2\2\u0087\u02d8\3\2\2\2\u0089\u02db\3\2\2\2\u008b\u02e1\3\2\2\2\u008d"+
|
||||
"\u02e3\3\2\2\2\u008f\u02e9\3\2\2\2\u0091\u02f0\3\2\2\2\u0093\u02f3\3\2"+
|
||||
"\2\2\u0095\u02f9\3\2\2\2\u0097\u02fb\3\2\2\2\u0099\u02ff\3\2\2\2\u009b"+
|
||||
"\u0306\3\2\2\2\u009d\u0309\3\2\2\2\u009f\u030f\3\2\2\2\u00a1\u0313\3\2"+
|
||||
"\2\2\u00a3\u0330\3\2\2\2\u00a5\u0332\3\2\2\2\u00a7\u0335\3\2\2\2\u00a9"+
|
||||
"\u0338\3\2\2\2\u00ab\u033c\3\2\2\2\u00ad\u033e\3\2\2\2\u00af\u0340\3\2"+
|
||||
"\2\2\u00b1\u0350\3\2\2\2\u00b3\u0352\3\2\2\2\u00b5\u0355\3\2\2\2\u00b7"+
|
||||
"\u0360\3\2\2\2\u00b9\u036a\3\2\2\2\u00bb\u036c\3\2\2\2\u00bd\u036e\3\2"+
|
||||
"\2\2\u00bf\u0375\3\2\2\2\u00c1\u037b\3\2\2\2\u00c3\u0381\3\2\2\2\u00c5"+
|
||||
"\u038e\3\2\2\2\u00c7\u0390\3\2\2\2\u00c9\u0392\3\2\2\2\u00cb\u0399\3\2"+
|
||||
"\2\2\u00cd\u039e\3\2\2\2\u00cf\u03a0\3\2\2\2\u00d1\u03a2\3\2\2\2\u00d3"+
|
||||
"\u03a4\3\2\2\2\u00d5\u03a6\3\2\2\2\u00d7\u03a8\3\2\2\2\u00d9\u03aa\3\2"+
|
||||
"\2\2\u00db\u03ac\3\2\2\2\u00dd\u03ae\3\2\2\2\u00df\u03b0\3\2\2\2\u00e1"+
|
||||
"\u03b2\3\2\2\2\u00e3\u03b4\3\2\2\2\u00e5\u03b6\3\2\2\2\u00e7\u03b8\3\2"+
|
||||
"\2\2\u00e9\u03ba\3\2\2\2\u00eb\u03bc\3\2\2\2\u00ed\u03be\3\2\2\2\u00ef"+
|
||||
"\u03c1\3\2\2\2\u00f1\u03c4\3\2\2\2\u00f3\u03c7\3\2\2\2\u00f5\u03ca\3\2"+
|
||||
"\2\2\u00f7\u03cd\3\2\2\2\u00f9\u03d0\3\2\2\2\u00fb\u03d3\3\2\2\2\u00fd"+
|
||||
"\u03d6\3\2\2\2\u00ff\u03d8\3\2\2\2\u0101\u03da\3\2\2\2\u0103\u03dc\3\2"+
|
||||
"\2\2\u0105\u03de\3\2\2\2\u0107\u03e0\3\2\2\2\u0109\u03e2\3\2\2\2\u010b"+
|
||||
"\u03e4\3\2\2\2\u010d\u03e6\3\2\2\2\u010f\u03e9\3\2\2\2\u0111\u03ec\3\2"+
|
||||
"\2\2\u0113\u03ef\3\2\2\2\u0115\u03f2\3\2\2\2\u0117\u03f5\3\2\2\2\u0119"+
|
||||
"\u03f8\3\2\2\2\u011b\u03fb\3\2\2\2\u011d\u03fe\3\2\2\2\u011f\u0401\3\2"+
|
||||
"\2\2\u0121\u0404\3\2\2\2\u0123\u0408\3\2\2\2\u0125\u040c\3\2\2\2\u0127"+
|
||||
"\u0411\3\2\2\2\u0129\u041e\3\2\2\2\u012b\u0426\3\2\2\2\u012d\u0428\3\2"+
|
||||
"\2\2\u012f\u042a\3\2\2\2\u0131\u042f\3\2\2\2\u0133\u0435\3\2\2\2\u0135"+
|
||||
"\u0443\3\2\2\2\u0137\u0138\7x\2\2\u0138\u0139\7c\2\2\u0139\u013a\7t\2"+
|
||||
"\2\u013a\4\3\2\2\2\u013b\u013c\7c\2\2\u013c\u013d\7d\2\2\u013d\u013e\7"+
|
||||
"u\2\2\u013e\u013f\7v\2\2\u013f\u0140\7t\2\2\u0140\u0141\7c\2\2\u0141\u0142"+
|
||||
"\7e\2\2\u0142\u0143\7v\2\2\u0143\6\3\2\2\2\u0144\u0145\7c\2\2\u0145\u0146"+
|
||||
"\7u\2\2\u0146\u0147\7u\2\2\u0147\u0148\7g\2\2\u0148\u0149\7t\2\2\u0149"+
|
||||
"\u014a\7v\2\2\u014a\b\3\2\2\2\u014b\u014c\7d\2\2\u014c\u014d\7q\2\2\u014d"+
|
||||
"\u014e\7q\2\2\u014e\u014f\7n\2\2\u014f\u0150\7g\2\2\u0150\u0151\7c\2\2"+
|
||||
"\u0151\u0152\7p\2\2\u0152\n\3\2\2\2\u0153\u0154\7d\2\2\u0154\u0155\7t"+
|
||||
"\2\2\u0155\u0156\7g\2\2\u0156\u0157\7c\2\2\u0157\u0158\7m\2\2\u0158\f"+
|
||||
"\3\2\2\2\u0159\u015a\7d\2\2\u015a\u015b\7{\2\2\u015b\u015c\7v\2\2\u015c"+
|
||||
"\u015d\7g\2\2\u015d\16\3\2\2\2\u015e\u015f\7e\2\2\u015f\u0160\7c\2\2\u0160"+
|
||||
"\u0161\7u\2\2\u0161\u0162\7g\2\2\u0162\20\3\2\2\2\u0163\u0164\7e\2\2\u0164"+
|
||||
"\u0165\7c\2\2\u0165\u0166\7v\2\2\u0166\u0167\7e\2\2\u0167\u0168\7j\2\2"+
|
||||
"\u0168\22\3\2\2\2\u0169\u016a\7e\2\2\u016a\u016b\7j\2\2\u016b\u016c\7"+
|
||||
"c\2\2\u016c\u016d\7t\2\2\u016d\24\3\2\2\2\u016e\u016f\7e\2\2\u016f\u0170"+
|
||||
"\7n\2\2\u0170\u0171\7c\2\2\u0171\u0172\7u\2\2\u0172\u0173\7u\2\2\u0173"+
|
||||
"\26\3\2\2\2\u0174\u0175\7e\2\2\u0175\u0176\7q\2\2\u0176\u0177\7p\2\2\u0177"+
|
||||
"\u0178\7u\2\2\u0178\u0179\7v\2\2\u0179\30\3\2\2\2\u017a\u017b\7e\2\2\u017b"+
|
||||
"\u017c\7q\2\2\u017c\u017d\7p\2\2\u017d\u017e\7v\2\2\u017e\u017f\7k\2\2"+
|
||||
"\u017f\u0180\7p\2\2\u0180\u0181\7w\2\2\u0181\u0182\7g\2\2\u0182\32\3\2"+
|
||||
"\2\2\u0183\u0184\7f\2\2\u0184\u0185\7g\2\2\u0185\u0186\7h\2\2\u0186\u0187"+
|
||||
"\7c\2\2\u0187\u0188\7w\2\2\u0188\u0189\7n\2\2\u0189\u018a\7v\2\2\u018a"+
|
||||
"\34\3\2\2\2\u018b\u018c\7f\2\2\u018c\u018d\7q\2\2\u018d\36\3\2\2\2\u018e"+
|
||||
"\u018f\7f\2\2\u018f\u0190\7q\2\2\u0190\u0191\7w\2\2\u0191\u0192\7d\2\2"+
|
||||
"\u0192\u0193\7n\2\2\u0193\u0194\7g\2\2\u0194 \3\2\2\2\u0195\u0196\7g\2"+
|
||||
"\2\u0196\u0197\7n\2\2\u0197\u0198\7u\2\2\u0198\u0199\7g\2\2\u0199\"\3"+
|
||||
"\2\2\2\u019a\u019b\7g\2\2\u019b\u019c\7p\2\2\u019c\u019d\7w\2\2\u019d"+
|
||||
"\u019e\7o\2\2\u019e$\3\2\2\2\u019f\u01a0\7g\2\2\u01a0\u01a1\7z\2\2\u01a1"+
|
||||
"\u01a2\7v\2\2\u01a2\u01a3\7g\2\2\u01a3\u01a4\7p\2\2\u01a4\u01a5\7f\2\2"+
|
||||
"\u01a5\u01a6\7u\2\2\u01a6&\3\2\2\2\u01a7\u01a8\7h\2\2\u01a8\u01a9\7k\2"+
|
||||
"\2\u01a9\u01aa\7p\2\2\u01aa\u01ab\7c\2\2\u01ab\u01ac\7n\2\2\u01ac(\3\2"+
|
||||
"\2\2\u01ad\u01ae\7h\2\2\u01ae\u01af\7k\2\2\u01af\u01b0\7p\2\2\u01b0\u01b1"+
|
||||
"\7c\2\2\u01b1\u01b2\7n\2\2\u01b2\u01b3\7n\2\2\u01b3\u01b4\7{\2\2\u01b4"+
|
||||
"*\3\2\2\2\u01b5\u01b6\7h\2\2\u01b6\u01b7\7n\2\2\u01b7\u01b8\7q\2\2\u01b8"+
|
||||
"\u01b9\7c\2\2\u01b9\u01ba\7v\2\2\u01ba,\3\2\2\2\u01bb\u01bc\7h\2\2\u01bc"+
|
||||
"\u01bd\7q\2\2\u01bd\u01be\7t\2\2\u01be.\3\2\2\2\u01bf\u01c0\7k\2\2\u01c0"+
|
||||
"\u01c1\7h\2\2\u01c1\60\3\2\2\2\u01c2\u01c3\7i\2\2\u01c3\u01c4\7q\2\2\u01c4"+
|
||||
"\u01c5\7v\2\2\u01c5\u01c6\7q\2\2\u01c6\62\3\2\2\2\u01c7\u01c8\7k\2\2\u01c8"+
|
||||
"\u01c9\7o\2\2\u01c9\u01ca\7r\2\2\u01ca\u01cb\7n\2\2\u01cb\u01cc\7g\2\2"+
|
||||
"\u01cc\u01cd\7o\2\2\u01cd\u01ce\7g\2\2\u01ce\u01cf\7p\2\2\u01cf\u01d0"+
|
||||
"\7v\2\2\u01d0\u01d1\7u\2\2\u01d1\64\3\2\2\2\u01d2\u01d3\7k\2\2\u01d3\u01d4"+
|
||||
"\7o\2\2\u01d4\u01d5\7r\2\2\u01d5\u01d6\7q\2\2\u01d6\u01d7\7t\2\2\u01d7"+
|
||||
"\u01d8\7v\2\2\u01d8\66\3\2\2\2\u01d9\u01da\7k\2\2\u01da\u01db\7p\2\2\u01db"+
|
||||
"\u01dc\7u\2\2\u01dc\u01dd\7v\2\2\u01dd\u01de\7c\2\2\u01de\u01df\7p\2\2"+
|
||||
"\u01df\u01e0\7e\2\2\u01e0\u01e1\7g\2\2\u01e1\u01e2\7q\2\2\u01e2\u01e3"+
|
||||
"\7h\2\2\u01e38\3\2\2\2\u01e4\u01e5\7k\2\2\u01e5\u01e6\7p\2\2\u01e6\u01e7"+
|
||||
"\7v\2\2\u01e7:\3\2\2\2\u01e8\u01e9\7k\2\2\u01e9\u01ea\7p\2\2\u01ea\u01eb"+
|
||||
"\7v\2\2\u01eb\u01ec\7g\2\2\u01ec\u01ed\7t\2\2\u01ed\u01ee\7h\2\2\u01ee"+
|
||||
"\u01ef\7c\2\2\u01ef\u01f0\7e\2\2\u01f0\u01f1\7g\2\2\u01f1<\3\2\2\2\u01f2"+
|
||||
"\u01f3\7n\2\2\u01f3\u01f4\7q\2\2\u01f4\u01f5\7p\2\2\u01f5\u01f6\7i\2\2"+
|
||||
"\u01f6>\3\2\2\2\u01f7\u01f8\7p\2\2\u01f8\u01f9\7c\2\2\u01f9\u01fa\7v\2"+
|
||||
"\2\u01fa\u01fb\7k\2\2\u01fb\u01fc\7x\2\2\u01fc\u01fd\7g\2\2\u01fd@\3\2"+
|
||||
"\2\2\u01fe\u01ff\7p\2\2\u01ff\u0200\7g\2\2\u0200\u0201\7y\2\2\u0201B\3"+
|
||||
"\2\2\2\u0202\u0203\7r\2\2\u0203\u0204\7c\2\2\u0204\u0205\7e\2\2\u0205"+
|
||||
"\u0206\7m\2\2\u0206\u0207\7c\2\2\u0207\u0208\7i\2\2\u0208\u0209\7g\2\2"+
|
||||
"\u0209D\3\2\2\2\u020a\u020b\7r\2\2\u020b\u020c\7t\2\2\u020c\u020d\7k\2"+
|
||||
"\2\u020d\u020e\7x\2\2\u020e\u020f\7c\2\2\u020f\u0210\7v\2\2\u0210\u0211"+
|
||||
"\7g\2\2\u0211F\3\2\2\2\u0212\u0213\7r\2\2\u0213\u0214\7t\2\2\u0214\u0215"+
|
||||
"\7q\2\2\u0215\u0216\7v\2\2\u0216\u0217\7g\2\2\u0217\u0218\7e\2\2\u0218"+
|
||||
"\u0219\7v\2\2\u0219\u021a\7g\2\2\u021a\u021b\7f\2\2\u021bH\3\2\2\2\u021c"+
|
||||
"\u021d\7r\2\2\u021d\u021e\7w\2\2\u021e\u021f\7d\2\2\u021f\u0220\7n\2\2"+
|
||||
"\u0220\u0221\7k\2\2\u0221\u0222\7e\2\2\u0222J\3\2\2\2\u0223\u0224\7t\2"+
|
||||
"\2\u0224\u0225\7g\2\2\u0225\u0226\7v\2\2\u0226\u0227\7w\2\2\u0227\u0228"+
|
||||
"\7t\2\2\u0228\u0229\7p\2\2\u0229L\3\2\2\2\u022a\u022b\7u\2\2\u022b\u022c"+
|
||||
"\7j\2\2\u022c\u022d\7q\2\2\u022d\u022e\7t\2\2\u022e\u022f\7v\2\2\u022f"+
|
||||
"N\3\2\2\2\u0230\u0231\7u\2\2\u0231\u0232\7v\2\2\u0232\u0233\7c\2\2\u0233"+
|
||||
"\u0234\7v\2\2\u0234\u0235\7k\2\2\u0235\u0236\7e\2\2\u0236P\3\2\2\2\u0237"+
|
||||
"\u0238\7u\2\2\u0238\u0239\7v\2\2\u0239\u023a\7t\2\2\u023a\u023b\7k\2\2"+
|
||||
"\u023b\u023c\7e\2\2\u023c\u023d\7v\2\2\u023d\u023e\7h\2\2\u023e\u023f"+
|
||||
"\7r\2\2\u023fR\3\2\2\2\u0240\u0241\7u\2\2\u0241\u0242\7w\2\2\u0242\u0243"+
|
||||
"\7r\2\2\u0243\u0244\7g\2\2\u0244\u0245\7t\2\2\u0245T\3\2\2\2\u0246\u0247"+
|
||||
"\7u\2\2\u0247\u0248\7y\2\2\u0248\u0249\7k\2\2\u0249\u024a\7v\2\2\u024a"+
|
||||
"\u024b\7e\2\2\u024b\u024c\7j\2\2\u024cV\3\2\2\2\u024d\u024e\7u\2\2\u024e"+
|
||||
"\u024f\7{\2\2\u024f\u0250\7p\2\2\u0250\u0251\7e\2\2\u0251\u0252\7j\2\2"+
|
||||
"\u0252\u0253\7t\2\2\u0253\u0254\7q\2\2\u0254\u0255\7p\2\2\u0255\u0256"+
|
||||
"\7k\2\2\u0256\u0257\7|\2\2\u0257\u0258\7g\2\2\u0258\u0259\7f\2\2\u0259"+
|
||||
"X\3\2\2\2\u025a\u025b\7v\2\2\u025b\u025c\7j\2\2\u025c\u025d\7k\2\2\u025d"+
|
||||
"\u025e\7u\2\2\u025eZ\3\2\2\2\u025f\u0260\7v\2\2\u0260\u0261\7j\2\2\u0261"+
|
||||
"\u0262\7t\2\2\u0262\u0263\7q\2\2\u0263\u0264\7y\2\2\u0264\\\3\2\2\2\u0265"+
|
||||
"\u0266\7v\2\2\u0266\u0267\7j\2\2\u0267\u0268\7t\2\2\u0268\u0269\7q\2\2"+
|
||||
"\u0269\u026a\7y\2\2\u026a\u026b\7u\2\2\u026b^\3\2\2\2\u026c\u026d\7v\2"+
|
||||
"\2\u026d\u026e\7t\2\2\u026e\u026f\7c\2\2\u026f\u0270\7p\2\2\u0270\u0271"+
|
||||
"\7u\2\2\u0271\u0272\7k\2\2\u0272\u0273\7g\2\2\u0273\u0274\7p\2\2\u0274"+
|
||||
"\u0275\7v\2\2\u0275`\3\2\2\2\u0276\u0277\7v\2\2\u0277\u0278\7t\2\2\u0278"+
|
||||
"\u0279\7{\2\2\u0279b\3\2\2\2\u027a\u027b\7x\2\2\u027b\u027c\7q\2\2\u027c"+
|
||||
"\u027d\7k\2\2\u027d\u027e\7f\2\2\u027ed\3\2\2\2\u027f\u0280\7x\2\2\u0280"+
|
||||
"\u0281\7q\2\2\u0281\u0282\7n\2\2\u0282\u0283\7c\2\2\u0283\u0284\7v\2\2"+
|
||||
"\u0284\u0285\7k\2\2\u0285\u0286\7n\2\2\u0286\u0287\7g\2\2\u0287f\3\2\2"+
|
||||
"\2\u0288\u0289\7y\2\2\u0289\u028a\7j\2\2\u028a\u028b\7k\2\2\u028b\u028c"+
|
||||
"\7n\2\2\u028c\u028d\7g\2\2\u028dh\3\2\2\2\u028e\u0293\5k\66\2\u028f\u0293"+
|
||||
"\5m\67\2\u0290\u0293\5o8\2\u0291\u0293\5q9\2\u0292\u028e\3\2\2\2\u0292"+
|
||||
"\u028f\3\2\2\2\u0292\u0290\3\2\2\2\u0292\u0291\3\2\2\2\u0293j\3\2\2\2"+
|
||||
"\u0294\u0296\5u;\2\u0295\u0297\5s:\2\u0296\u0295\3\2\2\2\u0296\u0297\3"+
|
||||
"\2\2\2\u0297l\3\2\2\2\u0298\u029a\5\u0083B\2\u0299\u029b\5s:\2\u029a\u0299"+
|
||||
"\3\2\2\2\u029a\u029b\3\2\2\2\u029bn\3\2\2\2\u029c\u029e\5\u008dG\2\u029d"+
|
||||
"\u029f\5s:\2\u029e\u029d\3\2\2\2\u029e\u029f\3\2\2\2\u029fp\3\2\2\2\u02a0"+
|
||||
"\u02a2\5\u0097L\2\u02a1\u02a3\5s:\2\u02a2\u02a1\3\2\2\2\u02a2\u02a3\3"+
|
||||
"\2\2\2\u02a3r\3\2\2\2\u02a4\u02a5\t\2\2\2\u02a5t\3\2\2\2\u02a6\u02b1\7"+
|
||||
"\62\2\2\u02a7\u02ae\5{>\2\u02a8\u02aa\5w<\2\u02a9\u02a8\3\2\2\2\u02a9"+
|
||||
"\u02aa\3\2\2\2\u02aa\u02af\3\2\2\2\u02ab\u02ac\5\u0081A\2\u02ac\u02ad"+
|
||||
"\5w<\2\u02ad\u02af\3\2\2\2\u02ae\u02a9\3\2\2\2\u02ae\u02ab\3\2\2\2\u02af"+
|
||||
"\u02b1\3\2\2\2\u02b0\u02a6\3\2\2\2\u02b0\u02a7\3\2\2\2\u02b1v\3\2\2\2"+
|
||||
"\u02b2\u02b7\5y=\2\u02b3\u02b5\5}?\2\u02b4\u02b3\3\2\2\2\u02b4\u02b5\3"+
|
||||
"\2\2\2\u02b5\u02b6\3\2\2\2\u02b6\u02b8\5y=\2\u02b7\u02b4\3\2\2\2\u02b7"+
|
||||
"\u02b8\3\2\2\2\u02b8x\3\2\2\2\u02b9\u02bc\7\62\2\2\u02ba\u02bc\5{>\2\u02bb"+
|
||||
"\u02b9\3\2\2\2\u02bb\u02ba\3\2\2\2\u02bcz\3\2\2\2\u02bd\u02be\t\3\2\2"+
|
||||
"\u02be|\3\2\2\2\u02bf\u02c1\5\177@\2\u02c0\u02bf\3\2\2\2\u02c1\u02c2\3"+
|
||||
"\2\2\2\u02c2\u02c0\3\2\2\2\u02c2\u02c3\3\2\2\2\u02c3~\3\2\2\2\u02c4\u02c7"+
|
||||
"\5y=\2\u02c5\u02c7\7a\2\2\u02c6\u02c4\3\2\2\2\u02c6\u02c5\3\2\2\2\u02c7"+
|
||||
"\u0080\3\2\2\2\u02c8\u02ca\7a\2\2\u02c9\u02c8\3\2\2\2\u02ca\u02cb\3\2"+
|
||||
"\2\2\u02cb\u02c9\3\2\2\2\u02cb\u02cc\3\2\2\2\u02cc\u0082\3\2\2\2\u02cd"+
|
||||
"\u02ce\7\62\2\2\u02ce\u02cf\t\4\2\2\u02cf\u02d0\5\u0085C\2\u02d0\u0084"+
|
||||
"\3\2\2\2\u02d1\u02d6\5\u0087D\2\u02d2\u02d4\5\u0089E\2\u02d3\u02d2\3\2"+
|
||||
"\2\2\u02d3\u02d4\3\2\2\2\u02d4\u02d5\3\2\2\2\u02d5\u02d7\5\u0087D\2\u02d6"+
|
||||
"\u02d3\3\2\2\2\u02d6\u02d7\3\2\2\2\u02d7\u0086\3\2\2\2\u02d8\u02d9\t\5"+
|
||||
"\2\2\u02d9\u0088\3\2\2\2\u02da\u02dc\5\u008bF\2\u02db\u02da\3\2\2\2\u02dc"+
|
||||
"\u02dd\3\2\2\2\u02dd\u02db\3\2\2\2\u02dd\u02de\3\2\2\2\u02de\u008a\3\2"+
|
||||
"\2\2\u02df\u02e2\5\u0087D\2\u02e0\u02e2\7a\2\2\u02e1\u02df\3\2\2\2\u02e1"+
|
||||
"\u02e0\3\2\2\2\u02e2\u008c\3\2\2\2\u02e3\u02e5\7\62\2\2\u02e4\u02e6\5"+
|
||||
"\u0081A\2\u02e5\u02e4\3\2\2\2\u02e5\u02e6\3\2\2\2\u02e6\u02e7\3\2\2\2"+
|
||||
"\u02e7\u02e8\5\u008fH\2\u02e8\u008e\3\2\2\2\u02e9\u02ee\5\u0091I\2\u02ea"+
|
||||
"\u02ec\5\u0093J\2\u02eb\u02ea\3\2\2\2\u02eb\u02ec\3\2\2\2\u02ec\u02ed"+
|
||||
"\3\2\2\2\u02ed\u02ef\5\u0091I\2\u02ee\u02eb\3\2\2\2\u02ee\u02ef\3\2\2"+
|
||||
"\2\u02ef\u0090\3\2\2\2\u02f0\u02f1\t\6\2\2\u02f1\u0092\3\2\2\2\u02f2\u02f4"+
|
||||
"\5\u0095K\2\u02f3\u02f2\3\2\2\2\u02f4\u02f5\3\2\2\2\u02f5\u02f3\3\2\2"+
|
||||
"\2\u02f5\u02f6\3\2\2\2\u02f6\u0094\3\2\2\2\u02f7\u02fa\5\u0091I\2\u02f8"+
|
||||
"\u02fa\7a\2\2\u02f9\u02f7\3\2\2\2\u02f9\u02f8\3\2\2\2\u02fa\u0096\3\2"+
|
||||
"\2\2\u02fb\u02fc\7\62\2\2\u02fc\u02fd\t\7\2\2\u02fd\u02fe\5\u0099M\2\u02fe"+
|
||||
"\u0098\3\2\2\2\u02ff\u0304\5\u009bN\2\u0300\u0302\5\u009dO\2\u0301\u0300"+
|
||||
"\3\2\2\2\u0301\u0302\3\2\2\2\u0302\u0303\3\2\2\2\u0303\u0305\5\u009bN"+
|
||||
"\2\u0304\u0301\3\2\2\2\u0304\u0305\3\2\2\2\u0305\u009a\3\2\2\2\u0306\u0307"+
|
||||
"\t\b\2\2\u0307\u009c\3\2\2\2\u0308\u030a\5\u009fP\2\u0309\u0308\3\2\2"+
|
||||
"\2\u030a\u030b\3\2\2\2\u030b\u0309\3\2\2\2\u030b\u030c\3\2\2\2\u030c\u009e"+
|
||||
"\3\2\2\2\u030d\u0310\5\u009bN\2\u030e\u0310\7a\2\2\u030f\u030d\3\2\2\2"+
|
||||
"\u030f\u030e\3\2\2\2\u0310\u00a0\3\2\2\2\u0311\u0314\5\u00a3R\2\u0312"+
|
||||
"\u0314\5\u00afX\2\u0313\u0311\3\2\2\2\u0313\u0312\3\2\2\2\u0314\u00a2"+
|
||||
"\3\2\2\2\u0315\u0316\5w<\2\u0316\u0318\7\60\2\2\u0317\u0319\5w<\2\u0318"+
|
||||
"\u0317\3\2\2\2\u0318\u0319\3\2\2\2\u0319\u031b\3\2\2\2\u031a\u031c\5\u00a5"+
|
||||
"S\2\u031b\u031a\3\2\2\2\u031b\u031c\3\2\2\2\u031c\u031e\3\2\2\2\u031d"+
|
||||
"\u031f\5\u00adW\2\u031e\u031d\3\2\2\2\u031e\u031f\3\2\2\2\u031f\u0331"+
|
||||
"\3\2\2\2\u0320\u0321\7\60\2\2\u0321\u0323\5w<\2\u0322\u0324\5\u00a5S\2"+
|
||||
"\u0323\u0322\3\2\2\2\u0323\u0324\3\2\2\2\u0324\u0326\3\2\2\2\u0325\u0327"+
|
||||
"\5\u00adW\2\u0326\u0325\3\2\2\2\u0326\u0327\3\2\2\2\u0327\u0331\3\2\2"+
|
||||
"\2\u0328\u0329\5w<\2\u0329\u032b\5\u00a5S\2\u032a\u032c\5\u00adW\2\u032b"+
|
||||
"\u032a\3\2\2\2\u032b\u032c\3\2\2\2\u032c\u0331\3\2\2\2\u032d\u032e\5w"+
|
||||
"<\2\u032e\u032f\5\u00adW\2\u032f\u0331\3\2\2\2\u0330\u0315\3\2\2\2\u0330"+
|
||||
"\u0320\3\2\2\2\u0330\u0328\3\2\2\2\u0330\u032d\3\2\2\2\u0331\u00a4\3\2"+
|
||||
"\2\2\u0332\u0333\5\u00a7T\2\u0333\u0334\5\u00a9U\2\u0334\u00a6\3\2\2\2"+
|
||||
"\u0335\u0336\t\t\2\2\u0336\u00a8\3\2\2\2\u0337\u0339\5\u00abV\2\u0338"+
|
||||
"\u0337\3\2\2\2\u0338\u0339\3\2\2\2\u0339\u033a\3\2\2\2\u033a\u033b\5w"+
|
||||
"<\2\u033b\u00aa\3\2\2\2\u033c\u033d\t\n\2\2\u033d\u00ac\3\2\2\2\u033e"+
|
||||
"\u033f\t\13\2\2\u033f\u00ae\3\2\2\2\u0340\u0341\5\u00b1Y\2\u0341\u0343"+
|
||||
"\5\u00b3Z\2\u0342\u0344\5\u00adW\2\u0343\u0342\3\2\2\2\u0343\u0344\3\2"+
|
||||
"\2\2\u0344\u00b0\3\2\2\2\u0345\u0347\5\u0083B\2\u0346\u0348\7\60\2\2\u0347"+
|
||||
"\u0346\3\2\2\2\u0347\u0348\3\2\2\2\u0348\u0351\3\2\2\2\u0349\u034a\7\62"+
|
||||
"\2\2\u034a\u034c\t\4\2\2\u034b\u034d\5\u0085C\2\u034c\u034b\3\2\2\2\u034c"+
|
||||
"\u034d\3\2\2\2\u034d\u034e\3\2\2\2\u034e\u034f\7\60\2\2\u034f\u0351\5"+
|
||||
"\u0085C\2\u0350\u0345\3\2\2\2\u0350\u0349\3\2\2\2\u0351\u00b2\3\2\2\2"+
|
||||
"\u0352\u0353\5\u00b5[\2\u0353\u0354\5\u00a9U\2\u0354\u00b4\3\2\2\2\u0355"+
|
||||
"\u0356\t\f\2\2\u0356\u00b6\3\2\2\2\u0357\u0358\7v\2\2\u0358\u0359\7t\2"+
|
||||
"\2\u0359\u035a\7w\2\2\u035a\u0361\7g\2\2\u035b\u035c\7h\2\2\u035c\u035d"+
|
||||
"\7c\2\2\u035d\u035e\7n\2\2\u035e\u035f\7u\2\2\u035f\u0361\7g\2\2\u0360"+
|
||||
"\u0357\3\2\2\2\u0360\u035b\3\2\2\2\u0361\u00b8\3\2\2\2\u0362\u0363\7)"+
|
||||
"\2\2\u0363\u0364\5\u00bb^\2\u0364\u0365\7)\2\2\u0365\u036b\3\2\2\2\u0366"+
|
||||
"\u0367\7)\2\2\u0367\u0368\5\u00c3b\2\u0368\u0369\7)\2\2\u0369\u036b\3"+
|
||||
"\2\2\2\u036a\u0362\3\2\2\2\u036a\u0366\3\2\2\2\u036b\u00ba\3\2\2\2\u036c"+
|
||||
"\u036d\n\r\2\2\u036d\u00bc\3\2\2\2\u036e\u0370\7$\2\2\u036f\u0371\5\u00bf"+
|
||||
"`\2\u0370\u036f\3\2\2\2\u0370\u0371\3\2\2\2\u0371\u0372\3\2\2\2\u0372"+
|
||||
"\u0373\7$\2\2\u0373\u00be\3\2\2\2\u0374\u0376\5\u00c1a\2\u0375\u0374\3"+
|
||||
"\2\2\2\u0376\u0377\3\2\2\2\u0377\u0375\3\2\2\2\u0377\u0378\3\2\2\2\u0378"+
|
||||
"\u00c0\3\2\2\2\u0379\u037c\n\16\2\2\u037a\u037c\5\u00c3b\2\u037b\u0379"+
|
||||
"\3\2\2\2\u037b\u037a\3\2\2\2\u037c\u00c2\3\2\2\2\u037d\u037e\7^\2\2\u037e"+
|
||||
"\u0382\t\17\2\2\u037f\u0382\5\u00c5c\2\u0380\u0382\5\u00c9e\2\u0381\u037d"+
|
||||
"\3\2\2\2\u0381\u037f\3\2\2\2\u0381\u0380\3\2\2\2\u0382\u00c4\3\2\2\2\u0383"+
|
||||
"\u0384\7^\2\2\u0384\u038f\5\u0091I\2\u0385\u0386\7^\2\2\u0386\u0387\5"+
|
||||
"\u0091I\2\u0387\u0388\5\u0091I\2\u0388\u038f\3\2\2\2\u0389\u038a\7^\2"+
|
||||
"\2\u038a\u038b\5\u00c7d\2\u038b\u038c\5\u0091I\2\u038c\u038d\5\u0091I"+
|
||||
"\2\u038d\u038f\3\2\2\2\u038e\u0383\3\2\2\2\u038e\u0385\3\2\2\2\u038e\u0389"+
|
||||
"\3\2\2\2\u038f\u00c6\3\2\2\2\u0390\u0391\t\20\2\2\u0391\u00c8\3\2\2\2"+
|
||||
"\u0392\u0393\7^\2\2\u0393\u0394\7w\2\2\u0394\u0395\5\u0087D\2\u0395\u0396"+
|
||||
"\5\u0087D\2\u0396\u0397\5\u0087D\2\u0397\u0398\5\u0087D\2\u0398\u00ca"+
|
||||
"\3\2\2\2\u0399\u039a\7p\2\2\u039a\u039b\7w\2\2\u039b\u039c\7n\2\2\u039c"+
|
||||
"\u039d\7n\2\2\u039d\u00cc\3\2\2\2\u039e\u039f\7*\2\2\u039f\u00ce\3\2\2"+
|
||||
"\2\u03a0\u03a1\7+\2\2\u03a1\u00d0\3\2\2\2\u03a2\u03a3\7}\2\2\u03a3\u00d2"+
|
||||
"\3\2\2\2\u03a4\u03a5\7\177\2\2\u03a5\u00d4\3\2\2\2\u03a6\u03a7\7]\2\2"+
|
||||
"\u03a7\u00d6\3\2\2\2\u03a8\u03a9\7_\2\2\u03a9\u00d8\3\2\2\2\u03aa\u03ab"+
|
||||
"\7=\2\2\u03ab\u00da\3\2\2\2\u03ac\u03ad\7.\2\2\u03ad\u00dc\3\2\2\2\u03ae"+
|
||||
"\u03af\7\60\2\2\u03af\u00de\3\2\2\2\u03b0\u03b1\7?\2\2\u03b1\u00e0\3\2"+
|
||||
"\2\2\u03b2\u03b3\7@\2\2\u03b3\u00e2\3\2\2\2\u03b4\u03b5\7>\2\2\u03b5\u00e4"+
|
||||
"\3\2\2\2\u03b6\u03b7\7#\2\2\u03b7\u00e6\3\2\2\2\u03b8\u03b9\7\u0080\2"+
|
||||
"\2\u03b9\u00e8\3\2\2\2\u03ba\u03bb\7A\2\2\u03bb\u00ea\3\2\2\2\u03bc\u03bd"+
|
||||
"\7<\2\2\u03bd\u00ec\3\2\2\2\u03be\u03bf\7?\2\2\u03bf\u03c0\7?\2\2\u03c0"+
|
||||
"\u00ee\3\2\2\2\u03c1\u03c2\7>\2\2\u03c2\u03c3\7?\2\2\u03c3\u00f0\3\2\2"+
|
||||
"\2\u03c4\u03c5\7@\2\2\u03c5\u03c6\7?\2\2\u03c6\u00f2\3\2\2\2\u03c7\u03c8"+
|
||||
"\7#\2\2\u03c8\u03c9\7?\2\2\u03c9\u00f4\3\2\2\2\u03ca\u03cb\7(\2\2\u03cb"+
|
||||
"\u03cc\7(\2\2\u03cc\u00f6\3\2\2\2\u03cd\u03ce\7~\2\2\u03ce\u03cf\7~\2"+
|
||||
"\2\u03cf\u00f8\3\2\2\2\u03d0\u03d1\7-\2\2\u03d1\u03d2\7-\2\2\u03d2\u00fa"+
|
||||
"\3\2\2\2\u03d3\u03d4\7/\2\2\u03d4\u03d5\7/\2\2\u03d5\u00fc\3\2\2\2\u03d6"+
|
||||
"\u03d7\7-\2\2\u03d7\u00fe\3\2\2\2\u03d8\u03d9\7/\2\2\u03d9\u0100\3\2\2"+
|
||||
"\2\u03da\u03db\7,\2\2\u03db\u0102\3\2\2\2\u03dc\u03dd\7\61\2\2\u03dd\u0104"+
|
||||
"\3\2\2\2\u03de\u03df\7(\2\2\u03df\u0106\3\2\2\2\u03e0\u03e1\7~\2\2\u03e1"+
|
||||
"\u0108\3\2\2\2\u03e2\u03e3\7`\2\2\u03e3\u010a\3\2\2\2\u03e4\u03e5\7\'"+
|
||||
"\2\2\u03e5\u010c\3\2\2\2\u03e6\u03e7\7/\2\2\u03e7\u03e8\7@\2\2\u03e8\u010e"+
|
||||
"\3\2\2\2\u03e9\u03ea\7<\2\2\u03ea\u03eb\7<\2\2\u03eb\u0110\3\2\2\2\u03ec"+
|
||||
"\u03ed\7-\2\2\u03ed\u03ee\7?\2\2\u03ee\u0112\3\2\2\2\u03ef\u03f0\7/\2"+
|
||||
"\2\u03f0\u03f1\7?\2\2\u03f1\u0114\3\2\2\2\u03f2\u03f3\7,\2\2\u03f3\u03f4"+
|
||||
"\7?\2\2\u03f4\u0116\3\2\2\2\u03f5\u03f6\7\61\2\2\u03f6\u03f7\7?\2\2\u03f7"+
|
||||
"\u0118\3\2\2\2\u03f8\u03f9\7(\2\2\u03f9\u03fa\7?\2\2\u03fa\u011a\3\2\2"+
|
||||
"\2\u03fb\u03fc\7~\2\2\u03fc\u03fd\7?\2\2\u03fd\u011c\3\2\2\2\u03fe\u03ff"+
|
||||
"\7`\2\2\u03ff\u0400\7?\2\2\u0400\u011e\3\2\2\2\u0401\u0402\7\'\2\2\u0402"+
|
||||
"\u0403\7?\2\2\u0403\u0120\3\2\2\2\u0404\u0405\7>\2\2\u0405\u0406\7>\2"+
|
||||
"\2\u0406\u0407\7?\2\2\u0407\u0122\3\2\2\2\u0408\u0409\7@\2\2\u0409\u040a"+
|
||||
"\7@\2\2\u040a\u040b\7?\2\2\u040b\u0124\3\2\2\2\u040c\u040d\7@\2\2\u040d"+
|
||||
"\u040e\7@\2\2\u040e\u040f\7@\2\2\u040f\u0410\7?\2\2\u0410\u0126\3\2\2"+
|
||||
"\2\u0411\u0415\5\u0129\u0095\2\u0412\u0414\5\u012b\u0096\2\u0413\u0412"+
|
||||
"\3\2\2\2\u0414\u0417\3\2\2\2\u0415\u0413\3\2\2\2\u0415\u0416\3\2\2\2\u0416"+
|
||||
"\u0128\3\2\2\2\u0417\u0415\3\2\2\2\u0418\u041f\t\21\2\2\u0419\u041a\n"+
|
||||
"\22\2\2\u041a\u041f\6\u0095\2\2\u041b\u041c\t\23\2\2\u041c\u041d\t\24"+
|
||||
"\2\2\u041d\u041f\6\u0095\3\2\u041e\u0418\3\2\2\2\u041e\u0419\3\2\2\2\u041e"+
|
||||
"\u041b\3\2\2\2\u041f\u012a\3\2\2\2\u0420\u0427\t\25\2\2\u0421\u0422\n"+
|
||||
"\22\2\2\u0422\u0427\6\u0096\4\2\u0423\u0424\t\23\2\2\u0424\u0425\t\24"+
|
||||
"\2\2\u0425\u0427\6\u0096\5\2\u0426\u0420\3\2\2\2\u0426\u0421\3\2\2\2\u0426"+
|
||||
"\u0423\3\2\2\2\u0427\u012c\3\2\2\2\u0428\u0429\7B\2\2\u0429\u012e\3\2"+
|
||||
"\2\2\u042a\u042b\7\60\2\2\u042b\u042c\7\60\2\2\u042c\u042d\7\60\2\2\u042d"+
|
||||
"\u0130\3\2\2\2\u042e\u0430\t\26\2\2\u042f\u042e\3\2\2\2\u0430\u0431\3"+
|
||||
"\2\2\2\u0431\u042f\3\2\2\2\u0431\u0432\3\2\2\2\u0432\u0433\3\2\2\2\u0433"+
|
||||
"\u0434\b\u0099\2\2\u0434\u0132\3\2\2\2\u0435\u0436\7\61\2\2\u0436\u0437"+
|
||||
"\7,\2\2\u0437\u043b\3\2\2\2\u0438\u043a\13\2\2\2\u0439\u0438\3\2\2\2\u043a"+
|
||||
"\u043d\3\2\2\2\u043b\u043c\3\2\2\2\u043b\u0439\3\2\2\2\u043c\u043e\3\2"+
|
||||
"\2\2\u043d\u043b\3\2\2\2\u043e\u043f\7,\2\2\u043f\u0440\7\61\2\2\u0440"+
|
||||
"\u0441\3\2\2\2\u0441\u0442\b\u009a\2\2\u0442\u0134\3\2\2\2\u0443\u0444"+
|
||||
"\7\61\2\2\u0444\u0445\7\61\2\2\u0445\u0449\3\2\2\2\u0446\u0448\n\27\2"+
|
||||
"\2\u0447\u0446\3\2\2\2\u0448\u044b\3\2\2\2\u0449\u0447\3\2\2\2\u0449\u044a"+
|
||||
"\3\2\2\2\u044a\u044c\3\2\2\2\u044b\u0449\3\2\2\2\u044c\u044d\b\u009b\2"+
|
||||
"\2\u044d\u0136\3\2\2\28\2\u0292\u0296\u029a\u029e\u02a2\u02a9\u02ae\u02b0"+
|
||||
"\u02b4\u02b7\u02bb\u02c2\u02c6\u02cb\u02d3\u02d6\u02dd\u02e1\u02e5\u02eb"+
|
||||
"\u02ee\u02f5\u02f9\u0301\u0304\u030b\u030f\u0313\u0318\u031b\u031e\u0323"+
|
||||
"\u0326\u032b\u0330\u0338\u0343\u0347\u034c\u0350\u0360\u036a\u0370\u0377"+
|
||||
"\u037b\u0381\u038e\u0415\u041e\u0426\u0431\u043b\u0449\3\b\2\2";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
|
||||
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
|
||||
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
|
||||
}
|
||||
}
|
||||
}
|
207
src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.tokens
Normal file
@ -0,0 +1,207 @@
|
||||
T__0=1
|
||||
ABSTRACT=2
|
||||
ASSERT=3
|
||||
BOOLEAN=4
|
||||
BREAK=5
|
||||
BYTE=6
|
||||
CASE=7
|
||||
CATCH=8
|
||||
CHAR=9
|
||||
CLASS=10
|
||||
CONST=11
|
||||
CONTINUE=12
|
||||
DEFAULT=13
|
||||
DO=14
|
||||
DOUBLE=15
|
||||
ELSE=16
|
||||
ENUM=17
|
||||
EXTENDS=18
|
||||
FINAL=19
|
||||
FINALLY=20
|
||||
FLOAT=21
|
||||
FOR=22
|
||||
IF=23
|
||||
GOTO=24
|
||||
IMPLEMENTS=25
|
||||
IMPORT=26
|
||||
INSTANCEOF=27
|
||||
INT=28
|
||||
INTERFACE=29
|
||||
LONG=30
|
||||
NATIVE=31
|
||||
NEW=32
|
||||
PACKAGE=33
|
||||
PRIVATE=34
|
||||
PROTECTED=35
|
||||
PUBLIC=36
|
||||
RETURN=37
|
||||
SHORT=38
|
||||
STATIC=39
|
||||
STRICTFP=40
|
||||
SUPER=41
|
||||
SWITCH=42
|
||||
SYNCHRONIZED=43
|
||||
THIS=44
|
||||
THROW=45
|
||||
THROWS=46
|
||||
TRANSIENT=47
|
||||
TRY=48
|
||||
VOID=49
|
||||
VOLATILE=50
|
||||
WHILE=51
|
||||
IntegerLiteral=52
|
||||
FloatingPointLiteral=53
|
||||
BooleanLiteral=54
|
||||
CharacterLiteral=55
|
||||
StringLiteral=56
|
||||
NullLiteral=57
|
||||
LPAREN=58
|
||||
RPAREN=59
|
||||
LBRACE=60
|
||||
RBRACE=61
|
||||
LBRACK=62
|
||||
RBRACK=63
|
||||
SEMI=64
|
||||
COMMA=65
|
||||
DOT=66
|
||||
ASSIGN=67
|
||||
GT=68
|
||||
LT=69
|
||||
BANG=70
|
||||
TILDE=71
|
||||
QUESTION=72
|
||||
COLON=73
|
||||
EQUAL=74
|
||||
LE=75
|
||||
GE=76
|
||||
NOTEQUAL=77
|
||||
AND=78
|
||||
OR=79
|
||||
INC=80
|
||||
DEC=81
|
||||
ADD=82
|
||||
SUB=83
|
||||
MUL=84
|
||||
DIV=85
|
||||
BITAND=86
|
||||
BITOR=87
|
||||
CARET=88
|
||||
MOD=89
|
||||
ARROW=90
|
||||
COLONCOLON=91
|
||||
ADD_ASSIGN=92
|
||||
SUB_ASSIGN=93
|
||||
MUL_ASSIGN=94
|
||||
DIV_ASSIGN=95
|
||||
AND_ASSIGN=96
|
||||
OR_ASSIGN=97
|
||||
XOR_ASSIGN=98
|
||||
MOD_ASSIGN=99
|
||||
LSHIFT_ASSIGN=100
|
||||
RSHIFT_ASSIGN=101
|
||||
URSHIFT_ASSIGN=102
|
||||
Identifier=103
|
||||
AT=104
|
||||
ELLIPSIS=105
|
||||
WS=106
|
||||
COMMENT=107
|
||||
LINE_COMMENT=108
|
||||
'var'=1
|
||||
'abstract'=2
|
||||
'assert'=3
|
||||
'boolean'=4
|
||||
'break'=5
|
||||
'byte'=6
|
||||
'case'=7
|
||||
'catch'=8
|
||||
'char'=9
|
||||
'class'=10
|
||||
'const'=11
|
||||
'continue'=12
|
||||
'default'=13
|
||||
'do'=14
|
||||
'double'=15
|
||||
'else'=16
|
||||
'enum'=17
|
||||
'extends'=18
|
||||
'final'=19
|
||||
'finally'=20
|
||||
'float'=21
|
||||
'for'=22
|
||||
'if'=23
|
||||
'goto'=24
|
||||
'implements'=25
|
||||
'import'=26
|
||||
'instanceof'=27
|
||||
'int'=28
|
||||
'interface'=29
|
||||
'long'=30
|
||||
'native'=31
|
||||
'new'=32
|
||||
'package'=33
|
||||
'private'=34
|
||||
'protected'=35
|
||||
'public'=36
|
||||
'return'=37
|
||||
'short'=38
|
||||
'static'=39
|
||||
'strictfp'=40
|
||||
'super'=41
|
||||
'switch'=42
|
||||
'synchronized'=43
|
||||
'this'=44
|
||||
'throw'=45
|
||||
'throws'=46
|
||||
'transient'=47
|
||||
'try'=48
|
||||
'void'=49
|
||||
'volatile'=50
|
||||
'while'=51
|
||||
'null'=57
|
||||
'('=58
|
||||
')'=59
|
||||
'{'=60
|
||||
'}'=61
|
||||
'['=62
|
||||
']'=63
|
||||
';'=64
|
||||
','=65
|
||||
'.'=66
|
||||
'='=67
|
||||
'>'=68
|
||||
'<'=69
|
||||
'!'=70
|
||||
'~'=71
|
||||
'?'=72
|
||||
':'=73
|
||||
'=='=74
|
||||
'<='=75
|
||||
'>='=76
|
||||
'!='=77
|
||||
'&&'=78
|
||||
'||'=79
|
||||
'++'=80
|
||||
'--'=81
|
||||
'+'=82
|
||||
'-'=83
|
||||
'*'=84
|
||||
'/'=85
|
||||
'&'=86
|
||||
'|'=87
|
||||
'^'=88
|
||||
'%'=89
|
||||
'->'=90
|
||||
'::'=91
|
||||
'+='=92
|
||||
'-='=93
|
||||
'*='=94
|
||||
'/='=95
|
||||
'&='=96
|
||||
'|='=97
|
||||
'^='=98
|
||||
'%='=99
|
||||
'<<='=100
|
||||
'>>='=101
|
||||
'>>>='=102
|
||||
'@'=104
|
||||
'...'=105
|
2390
src/main/java/de/dhbwstuttgart/parser/antlr/Java8Listener.java
Normal file
18764
src/main/java/de/dhbwstuttgart/parser/antlr/Java8Parser.java
Normal file
@ -43,7 +43,7 @@ public class GatherNames {
|
||||
}
|
||||
else{
|
||||
if(typeDecl.classDeclaration().normalClassDeclaration() != null){
|
||||
if(pkgName != ""){
|
||||
if(!pkgName.isEmpty()){
|
||||
nameString = pkgName + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
|
||||
}
|
||||
else{
|
||||
|
@ -1,8 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.CNF;
|
||||
|
||||
public class CNF {
|
||||
/*
|
||||
Baut die CNF Datei.
|
||||
Hier muss man überlegen, in welchem Form die Constraints gebaut werden
|
||||
*/
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.CNF;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Schreibt CNFs in eine Datei im DIMACS CNF Format
|
||||
*/
|
||||
public class Writer {
|
||||
public Writer(FileWriter output){
|
||||
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp;
|
||||
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ASPStringConverter {
|
||||
private static final Map<String, String> replacements = new HashMap<>();
|
||||
static{
|
||||
replacements.put(".", "_DOT_");
|
||||
replacements.put("$", "_DOLLAR_");
|
||||
}
|
||||
|
||||
public static String toConstant(JavaClassName name){
|
||||
return toConstant(name.toString());
|
||||
}
|
||||
|
||||
public static String toConstant(String name){
|
||||
return "c" + replace(name);
|
||||
}
|
||||
|
||||
public static String fromConstant(String s){
|
||||
return unReplace(s).substring(1);
|
||||
}
|
||||
|
||||
private static String replace(String input){
|
||||
for(String toReplace : replacements.keySet()){
|
||||
input = input.replace(toReplace, replacements.get(toReplace));
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
private static String unReplace(String input){
|
||||
for(String toReplace : replacements.keySet()){
|
||||
input = input.replace(replacements.get(toReplace), toReplace);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp;
|
||||
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Clingo {
|
||||
private final List<File> input;
|
||||
private static final List<File> programFiles = new ArrayList<>();
|
||||
static{
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/basis.lp"));
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/finiteclosure.lp"));
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/subst.lp"));
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce.lp"));
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/unify.lp"));
|
||||
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/adapt.lp"));
|
||||
}
|
||||
|
||||
public Clingo(List<File> inputFiles){
|
||||
this.input = inputFiles;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO: Clingo per Java Wrapper https://stackoverflow.com/questions/3356200/using-java-to-wrap-over-c
|
||||
*/
|
||||
public String runClingo() throws IOException, InterruptedException {
|
||||
String pathToClingo =
|
||||
"/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/clingo-5.2.1-linux-x86_64/clingo";
|
||||
List<String> commands = new ArrayList<>();
|
||||
commands.add(pathToClingo);
|
||||
//commands.add("--outf=2"); //use JSON-Output
|
||||
commands.add("--outf=1"); //use JSON-Output
|
||||
for(File file : input){
|
||||
commands.add(file.getPath());
|
||||
}
|
||||
commands.addAll(programFiles.stream().map(f->f.getPath()).collect(Collectors.toList()));
|
||||
|
||||
Process clingo = new ProcessBuilder( commands.toArray(new String[0])).start();
|
||||
InputStream output = clingo.getInputStream();
|
||||
clingo.waitFor();
|
||||
String result = IOUtils.toString(output, StandardCharsets.UTF_8);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.model;
|
||||
|
||||
public enum ASPGencayRule {
|
||||
ASP_PAIR_EQUALS_NAME("equals"),
|
||||
ASP_PAIR_SMALLER_NAME("sub"),
|
||||
ASP_PAIR_SMALLER_DOT_NAME("subEq"),
|
||||
ASP_PARAMLIST_NAME("paramEq"),
|
||||
ASP_FC_PARAMLIST_NAME("param"),
|
||||
ASP_PARAMLIST_END_POINTER("null"),
|
||||
ASP_TYPE("typeEq"),
|
||||
ASP_FCTYPE("type"),
|
||||
ASP_TYPE_VAR("var"),
|
||||
ASP_GENERIC_VAR("pph"),
|
||||
ASP_PARAMLIST_ORDER("paramOrder");
|
||||
|
||||
private final String text;
|
||||
|
||||
private ASPGencayRule(final String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.model;
|
||||
|
||||
public enum ASPRule {
|
||||
ASP_PAIR_EQUALS_NAME("equals"),
|
||||
ASP_PAIR_SMALLER_NAME("smaller"),
|
||||
ASP_PAIR_SMALLER_DOT_NAME("smallerDot"),
|
||||
ASP_PARAMLIST_NAME("param"),
|
||||
ASP_PARAMLIST_END_POINTER("null"),
|
||||
ASP_TYPE("type"),
|
||||
ASP_FCTYPE("typeFC"),
|
||||
ASP_TYPE_VAR("typeVar");
|
||||
|
||||
private final String text;
|
||||
|
||||
private ASPRule(final String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
@ -1,231 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.parser;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.sat.asp.ASPStringConverter;
|
||||
import de.dhbwstuttgart.sat.asp.model.ASPRule;
|
||||
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultBaseListener;
|
||||
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultLexer;
|
||||
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultParser;
|
||||
import de.dhbwstuttgart.sat.asp.parser.model.ParsedType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.result.*;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArray;
|
||||
import javax.json.JsonObject;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Ablauf:
|
||||
* - Erst werden alle benötigten Statements eingelesen. Die Pointer bleiben als Strings erhalten
|
||||
* - Anschließend müssen diese wieder zu einem Unify Ergebnis zurückgewandelt werden
|
||||
* - Hier nicht die Typen aus dem unify.model packages verwenden.
|
||||
* TODO: Überlegen welche Informationen noch nach der Unifizierung gebraucht werden
|
||||
* -> Eigentlich nur die korrekten Namen der Typen und TPHs
|
||||
*/
|
||||
public class ASPParser extends UnifyResultBaseListener {
|
||||
private Collection<TypePlaceholder> originalTPHs;
|
||||
private ResultSet resultSet;
|
||||
private Map<String, ParsedType> types = new HashMap<>();
|
||||
private Set<String> tphs = new HashSet<>();
|
||||
private Map<String, ParameterListNode> parameterLists = new HashMap<>();
|
||||
private Set<Relation> equalsRelations = new HashSet<>();
|
||||
private Set<Relation> smallerRelations = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Parst clingo output welcher als JSON (option --outf=2) ausgibt
|
||||
* @param toParse
|
||||
* @return
|
||||
*/
|
||||
public static ResultSet parse(String toParse, Collection<TypePlaceholder> oldPlaceholders){
|
||||
return new ASPParser(toParse, oldPlaceholders).resultSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterParameter(UnifyResultParser.ParameterContext ctx) {
|
||||
//Linked List (pointer, Type, nextPointer)
|
||||
List<String> params = parseParameterList(ctx.parameterList());
|
||||
parameterLists.put(params.get(0), new ParameterListNode(params.get(1), params.get(2)));
|
||||
}
|
||||
|
||||
private static class Relation {
|
||||
public final String right;
|
||||
public final String left;
|
||||
|
||||
Relation(String leftType, String rightType){
|
||||
this.left = leftType;
|
||||
this.right = rightType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (left+right).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof Relation)
|
||||
return (right+left).equals(((Relation) obj).left+((Relation) obj).right);
|
||||
return super.equals(obj);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> parseParameterList(UnifyResultParser.ParameterListContext ctx){
|
||||
return ctx.value().stream().map(v ->
|
||||
//ASPStringConverter.fromConstant(v.getText())
|
||||
v.getText()
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterEquals(UnifyResultParser.EqualsContext ctx) {
|
||||
List<String> parameterList = parseParameterList(ctx.parameterList());
|
||||
if(parameterList.size()<2)throw new DebugException("Fehler in Equals-Regel");
|
||||
String ls = parameterList.get(0);
|
||||
String rs = parameterList.get(1);
|
||||
equalsRelations.add(new Relation(ls, rs));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterSmaller(UnifyResultParser.SmallerContext ctx) {
|
||||
List<String> parameterList = parseParameterList(ctx.parameterList());
|
||||
if(parameterList.size()<2)throw new DebugException("Fehler in Smaller-Regel");
|
||||
String ls = parameterList.get(0);
|
||||
String rs = parameterList.get(1);
|
||||
smallerRelations.add(new Relation(ls, rs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterTypeVar(UnifyResultParser.TypeVarContext ctx) {
|
||||
List<String> parameterList = parseParameterList(ctx.parameterList());
|
||||
if(parameterList.size()<1)throw new DebugException("Fehler in typeVar-Regel");
|
||||
tphs.add(parameterList.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterType(UnifyResultParser.TypeContext ctx){
|
||||
List<String> parameterList = parseParameterList(ctx.parameterList());
|
||||
if(parameterList.size()<3)throw new DebugException("Fehler in Type-Regel");
|
||||
String name = parameterList.get(0);
|
||||
String typeName = parameterList.get(1);
|
||||
String paramPointer = parameterList.get(2);
|
||||
types.put(name, new ParsedType(typeName, paramPointer));
|
||||
}
|
||||
|
||||
/*
|
||||
private List<String> parsedRule;
|
||||
private List<String> parseRule(String rule){
|
||||
UnifyResultLexer lexer = new UnifyResultLexer(CharStreams.fromString(rule));
|
||||
UnifyResultParser.AspruleContext parseTree = new UnifyResultParser(new CommonTokenStream(lexer)).asprule();
|
||||
parsedRule = new ArrayList<>();
|
||||
new ParseTreeWalker().walk(this, parseTree);
|
||||
return parsedRule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enterAsprule(UnifyResultParser.AspruleContext ctx) {
|
||||
super.enterAsprule(ctx);
|
||||
for(int i = 0; i< ctx.getChildCount();i++){
|
||||
parsedRule.add(ctx.getChild(i).getText());
|
||||
}
|
||||
}
|
||||
*/
|
||||
private ASPParser(String toParse, Collection<TypePlaceholder> oldPlaceholders){
|
||||
//System.out.println(toParse);
|
||||
this.originalTPHs = oldPlaceholders;
|
||||
|
||||
/*
|
||||
JsonObject jsonResult = Json.createReader(new StringReader(toParse)).readObject();
|
||||
JsonArray results = jsonResult.getJsonArray("Call").getJsonObject(0).
|
||||
getJsonArray("Witnesses").getJsonObject(0).
|
||||
getJsonArray("Value");
|
||||
|
||||
//Im ersten Schritt werden alle Regeln geparst
|
||||
String completeResult = "";
|
||||
for(int i = 0; i<results.size();i++){
|
||||
String aspStatement = results.getString(i);
|
||||
completeResult += aspStatement + " ";
|
||||
}
|
||||
System.out.println(completeResult);
|
||||
*/
|
||||
UnifyResultLexer lexer = new UnifyResultLexer(CharStreams.fromString(toParse));
|
||||
UnifyResultParser.AnswerContext parseTree = new UnifyResultParser(new CommonTokenStream(lexer)).answer();
|
||||
new ParseTreeWalker().walk(this, parseTree);
|
||||
|
||||
/*
|
||||
Diese Funktion läuft im folgenden mehrmals über das Result aus dem ASP Programm.
|
||||
Dabei werden Schritt für Schritt die Felder dieser Klasse befüllt die am Schluss das ResultSet ergeben
|
||||
*/
|
||||
Set<ResultPair> ret = new HashSet<>();
|
||||
//Zuerst die params und typeVars:
|
||||
//for(String paramPointer : types.values().stream().map(parsedType -> parsedType.params).collect(Collectors.toList())){ }
|
||||
|
||||
//Dann die Equalsdot Statements
|
||||
for(Relation eq : equalsRelations){
|
||||
RefTypeOrTPHOrWildcardOrGeneric lsType = this.getType(eq.left);
|
||||
RefTypeOrTPHOrWildcardOrGeneric rsType = this.getType(eq.right);
|
||||
if(lsType instanceof TypePlaceholder && rsType instanceof RefType)
|
||||
ret.add(new PairTPHequalRefTypeOrWildcardType((TypePlaceholder) lsType, rsType));
|
||||
else if(lsType instanceof TypePlaceholder && rsType instanceof TypePlaceholder)
|
||||
ret.add(new PairTPHEqualTPH((TypePlaceholder)lsType, (TypePlaceholder)rsType));
|
||||
else throw new NotImplementedException();
|
||||
}
|
||||
this.resultSet = new ResultSet(ret);
|
||||
}
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric getType(String name) {
|
||||
if(tphs.contains(name)){
|
||||
name = ASPStringConverter.fromConstant(name);
|
||||
for(TypePlaceholder tph : originalTPHs){
|
||||
if(tph.getName().equals(name))return tph;
|
||||
}
|
||||
return TypePlaceholder.fresh(new NullToken());
|
||||
}else
|
||||
if(types.containsKey(name)){
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
ParsedType t = types.get(name);
|
||||
|
||||
for(String param : getParams(t.params)){
|
||||
params.add(this.getType(param));
|
||||
}
|
||||
return new RefType(new JavaClassName(ASPStringConverter.fromConstant(t.name)), params, new NullToken());
|
||||
}else throw new DebugException("Der Typ " + name + " konnte nicht bestimmt werden");
|
||||
}
|
||||
|
||||
private static class ParameterListNode{
|
||||
final String type;
|
||||
final String nextNode;
|
||||
|
||||
public ParameterListNode(String type, String next) {
|
||||
this.type = type;
|
||||
this.nextNode = next;
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getParams(String pointer) {
|
||||
List<String> params = new ArrayList<>();
|
||||
while(pointer != null){
|
||||
if(pointer.equals(ASPRule.ASP_PARAMLIST_END_POINTER.toString()))return params;
|
||||
if(!parameterLists.containsKey(pointer))
|
||||
throw new DebugException("Fehler in Ergebnisparsen");
|
||||
//TODO: Fehler in ASP. Die adapt Regel muss erkennen, wenn die Parameterliste auf der linken Seite kürzer ist und diese Rechtzeitig beenden
|
||||
ParameterListNode param = parameterLists.get(pointer);
|
||||
pointer = param.nextNode;
|
||||
params.add(param.type);
|
||||
}
|
||||
return params;
|
||||
//Optional<ASPParameterList> ret = parameterLists.stream().filter(aspParameterList -> aspParameterList.name.equals(rs)).findAny();
|
||||
//return ret.get();
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.parser.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParsedType {
|
||||
public final String name;
|
||||
public final String params;
|
||||
public ParsedType(String name, String params){
|
||||
this.name = name;
|
||||
this.params = params;
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.writer;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
|
||||
import de.dhbwstuttgart.sat.asp.ASPStringConverter;
|
||||
import de.dhbwstuttgart.sat.asp.model.ASPRule;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ASPFactory implements TypeVisitor<String>{
|
||||
|
||||
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses, ClassLoader classLoader) throws ClassNotFoundException{
|
||||
ASPFactory factory = new ASPFactory();
|
||||
factory.convertFC(fcClasses, classLoader);
|
||||
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
||||
for(Constraint<Pair> constraint : constraints1){
|
||||
for(Pair p : constraint){
|
||||
factory.convertPair(p);
|
||||
}
|
||||
}
|
||||
|
||||
return factory.writer.getASPFile();
|
||||
}
|
||||
|
||||
ASPWriter writer = new ASPWriter();
|
||||
boolean isFCType = false;
|
||||
|
||||
private void convertFC(Collection<ClassOrInterface> classes, ClassLoader classLoader) throws ClassNotFoundException {
|
||||
Set<Pair> fc = FCGenerator.toFC(classes, classLoader);
|
||||
isFCType = true;
|
||||
for(Pair fcp : fc){
|
||||
convertPair(fcp);
|
||||
}
|
||||
isFCType = false;
|
||||
}
|
||||
|
||||
private void convertPair(Pair p){
|
||||
String ls = p.TA1.acceptTV(this);
|
||||
String rs = p.TA2.acceptTV(this);
|
||||
ASPStatement pairStmt = null;
|
||||
if(p.GetOperator().equals(PairOperator.SMALLERDOT)){
|
||||
pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString(), ls, rs);
|
||||
}else if(p.GetOperator().equals(PairOperator.EQUALSDOT)){
|
||||
pairStmt = makeStatement(ASPRule.ASP_PAIR_EQUALS_NAME.toString(), ls, rs);
|
||||
}else if(p.GetOperator().equals(PairOperator.SMALLER)){
|
||||
pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs);
|
||||
}else throw new NotImplementedException();
|
||||
writer.add(pairStmt);
|
||||
}
|
||||
|
||||
private ASPStatement makeStatement(String rule, String... params){
|
||||
String stmt = rule + "(";
|
||||
for(String param : params){
|
||||
stmt += param + ",";
|
||||
}
|
||||
stmt = stmt.substring(0,stmt.length()-1);
|
||||
stmt += ")";
|
||||
return new ASPStatement(stmt);
|
||||
}
|
||||
|
||||
private String convertParameterlist(List<String> pointers){
|
||||
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
Iterator<String> it = pointers.iterator();
|
||||
String p = pointer;
|
||||
if(!it.hasNext()){
|
||||
return ASPRule.ASP_PARAMLIST_END_POINTER.toString();
|
||||
}
|
||||
while (it.hasNext()){
|
||||
ASPStatement stmt;
|
||||
String type = it.next();
|
||||
String nextP = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
if(it.hasNext()){
|
||||
stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type, nextP);
|
||||
}else{
|
||||
stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type,
|
||||
ASPRule.ASP_PARAMLIST_END_POINTER.toString());
|
||||
}
|
||||
p = nextP;
|
||||
writer.add(stmt);
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(RefType refType) {
|
||||
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
List<String> params = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
|
||||
params.add(param.acceptTV(this));
|
||||
}
|
||||
String typeName = ASPStringConverter.toConstant(refType.getName());
|
||||
String ruleName = isFCType?ASPRule.ASP_FCTYPE.toString():ASPRule.ASP_TYPE.toString();
|
||||
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, convertParameterlist(params));
|
||||
writer.add(stmt);
|
||||
return pointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(TypePlaceholder typePlaceholder) {
|
||||
String name = ASPStringConverter.toConstant(typePlaceholder.getName());
|
||||
ASPStatement stmt = makeStatement(ASPRule.ASP_TYPE_VAR.toString(), name);
|
||||
writer.add(stmt);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(GenericRefType genericRefType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.writer;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
|
||||
import de.dhbwstuttgart.sat.asp.ASPStringConverter;
|
||||
import de.dhbwstuttgart.sat.asp.model.ASPGencayRule;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ASPGencayFactory implements TypeVisitor<String> {
|
||||
/* TODO:
|
||||
* Alle TPHs müssen als var(tph) definiert sein
|
||||
* Wenn es eine Variable ist, dann direkt in die type-Regel schreiben: type(p, type, tph)
|
||||
* Für die FCTypen eindeutige Namen für die pph-Regeln
|
||||
* (ergibt sich von selbst, weil man einfach den Namen der TPH in der FC verwenden kann)
|
||||
* paramOrder wird benötigt!
|
||||
* Nur bei parameterlisten > 1
|
||||
* paramOrder(paralistPointer, parameter, num)
|
||||
* (ähnlich meiner paramNum)
|
||||
* Trennung von FC und Eq:
|
||||
* sub -> type -> param
|
||||
* ...Eq -> typeEq -> paramEq
|
||||
* type..(_,_,_p): p kann sein:
|
||||
* 1. Variable
|
||||
* 2. ParameterPointer
|
||||
* 3. null
|
||||
*/
|
||||
ASPWriter writer = new ASPWriter();
|
||||
boolean isFCType = false;
|
||||
|
||||
private static List<ASPStatement> generateVar(ConstraintSet<Pair> constraints){
|
||||
List<ASPStatement> ret = new ArrayList<>();
|
||||
for(TypePlaceholder tph : getInvolvedTPHS(constraints)){
|
||||
ret.add(makeStatement(ASPGencayRule.ASP_TYPE_VAR.toString(),
|
||||
ASPStringConverter.toConstant(tph.getName())));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected static Collection<TypePlaceholder> getInvolvedTPHS(ConstraintSet<Pair> toTest) {
|
||||
List<TypePlaceholder> ret = new ArrayList<>();
|
||||
toTest.map((Pair p)-> {
|
||||
ret.addAll(p.TA1.acceptTV(new TPHExtractor()));
|
||||
ret.addAll(p.TA2.acceptTV(new TPHExtractor()));
|
||||
return p;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses, ClassLoader classLoader) throws ClassNotFoundException{
|
||||
ASPGencayFactory factory = new ASPGencayFactory();
|
||||
factory.convertFC(fcClasses, classLoader);
|
||||
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
|
||||
for(Constraint<Pair> constraint : constraints1){
|
||||
for(Pair p : constraint){
|
||||
factory.convertPair(p);
|
||||
}
|
||||
}
|
||||
factory.writer.addAll(generateVar(constraints));
|
||||
|
||||
return factory.writer.getASPFile();
|
||||
}
|
||||
|
||||
private void convertFC(Collection<ClassOrInterface> classes, ClassLoader classLoader) throws ClassNotFoundException {
|
||||
Set<Pair> fc = FCGenerator.toFC(classes, classLoader);
|
||||
isFCType = true;
|
||||
for(Pair fcp : fc){
|
||||
generateTheta((RefType) fcp.TA1);
|
||||
generateTheta((RefType) fcp.TA2);
|
||||
convertPair(fcp);
|
||||
}
|
||||
isFCType = false;
|
||||
}
|
||||
|
||||
private void generateTheta(RefType t){
|
||||
String rule = "theta"+t.getParaList().size() ;
|
||||
String name = ASPStringConverter.toConstant(t.getName());
|
||||
writer.add(makeStatement(rule, name));
|
||||
}
|
||||
|
||||
private void convertPair(Pair p){
|
||||
String ls = p.TA1.acceptTV(this);
|
||||
String rs = p.TA2.acceptTV(this);
|
||||
ASPStatement pairStmt = null;
|
||||
if(p.GetOperator().equals(PairOperator.SMALLERDOT)){
|
||||
pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_SMALLER_DOT_NAME.toString(), ls, rs);
|
||||
}else if(p.GetOperator().equals(PairOperator.EQUALSDOT)){
|
||||
pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_EQUALS_NAME.toString(), ls, rs);
|
||||
}else if(p.GetOperator().equals(PairOperator.SMALLER)){
|
||||
pairStmt = makeStatement(ASPGencayRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs);
|
||||
}else throw new NotImplementedException();
|
||||
writer.add(pairStmt);
|
||||
}
|
||||
|
||||
private static ASPStatement makeStatement(String rule, String... params){
|
||||
String stmt = rule + "(";
|
||||
for(String param : params){
|
||||
stmt += param + ",";
|
||||
}
|
||||
stmt = stmt.substring(0,stmt.length()-1);
|
||||
stmt += ")";
|
||||
return new ASPStatement(stmt);
|
||||
}
|
||||
|
||||
private String convertParameterlist(List<String> pointers){
|
||||
//if(pointers.size()==1)return pointers.get(0);
|
||||
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
Iterator<String> it = pointers.iterator();
|
||||
String p = pointer;
|
||||
String paramname = ASPGencayRule.ASP_PARAMLIST_NAME.toString();
|
||||
if(this.isFCType)paramname = ASPGencayRule.ASP_FC_PARAMLIST_NAME.toString();
|
||||
if(!it.hasNext()){
|
||||
return ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString();
|
||||
}
|
||||
while (it.hasNext()){
|
||||
ASPStatement stmt;
|
||||
String type = it.next();
|
||||
String nextP = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
if(it.hasNext()){
|
||||
stmt = makeStatement(paramname, p, type, nextP);
|
||||
}else{
|
||||
stmt = makeStatement(paramname, p, type,
|
||||
ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString());
|
||||
}
|
||||
p = nextP;
|
||||
writer.add(stmt);
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
|
||||
//Wird zum erstellen der pph(..) Regeln gebraucht
|
||||
private String currentFCTypePointer = "";
|
||||
@Override
|
||||
public String visit(RefType refType) {
|
||||
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
currentFCTypePointer = pointer;
|
||||
String paramPointer = ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString();
|
||||
if(refType.getParaList().size() == 1 ){
|
||||
if(refType.getParaList().get(0) instanceof TypePlaceholder){
|
||||
TypePlaceholder typePlaceholder = (TypePlaceholder) refType.getParaList().get(0);
|
||||
paramPointer = typePlaceholder.acceptTV(this);
|
||||
}
|
||||
}else{
|
||||
List<String> params = null;
|
||||
params = generateParameter(refType);
|
||||
params.remove(0);
|
||||
paramPointer = convertParameterlist(params);
|
||||
if(refType.getParaList().size()>1){
|
||||
//paramOrder generieren:
|
||||
for(String param : params) {
|
||||
ASPStatement pOstmt = makeStatement(ASPGencayRule.ASP_PARAMLIST_ORDER.toString(),
|
||||
paramPointer, param);
|
||||
writer.add(pOstmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
String typeName = ASPStringConverter.toConstant(refType.getName());
|
||||
String ruleName = isFCType? ASPGencayRule.ASP_FCTYPE.toString(): ASPGencayRule.ASP_TYPE.toString();
|
||||
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, paramPointer);
|
||||
writer.add(stmt);
|
||||
return pointer;
|
||||
/*
|
||||
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
|
||||
List<String> params = null;
|
||||
params = generateParameter(refType);
|
||||
params.remove(0); //Das erste ist der eigentliche Typ kein parameter
|
||||
String typeName = ASPStringConverter.toConstant(refType.getName());
|
||||
String ruleName = isFCType? ASPGencayRule.ASP_FCTYPE.toString(): ASPGencayRule.ASP_TYPE.toString();
|
||||
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, convertParameterlist(params));
|
||||
writer.add(stmt);
|
||||
return pointer;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt die Parameterliste, wobei type auch schon als Parameter betrachtet wird.
|
||||
* Die RefTypes werden nicht zu extra type-Regeln umgewandelt. Es wird nur ihr Name als Konstante benutzt
|
||||
* Das funktioniert, weil nacher das ParamOrder zuteilt, welche Typen zusammenhängen.
|
||||
* Diese funktion nur verwenden, wenn auch ein paramOrder generiert wird
|
||||
*/
|
||||
private List<String> generateParameter(RefType type){
|
||||
List<String> ret = new ArrayList<>();
|
||||
ret.add(ASPStringConverter.toConstant(type.getName()));
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : type.getParaList()){
|
||||
if(param instanceof RefType){
|
||||
ret.addAll(generateParameter((RefType) param));
|
||||
}else if(param instanceof TypePlaceholder){
|
||||
ret.add(param.acceptTV(this));
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(TypePlaceholder typePlaceholder) {
|
||||
String name = ASPStringConverter.toConstant(typePlaceholder.getName());
|
||||
|
||||
ASPStatement stmt = null;
|
||||
if(isFCType){
|
||||
stmt = makeStatement(ASPGencayRule.ASP_GENERIC_VAR.toString(),
|
||||
currentFCTypePointer, name);
|
||||
} else {
|
||||
stmt = makeStatement(ASPGencayRule.ASP_TYPE_VAR.toString(), name);
|
||||
}
|
||||
|
||||
writer.add(stmt);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(GenericRefType genericRefType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static class TPHExtractor implements TypeVisitor<List<TypePlaceholder>>{
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(RefType refType) {
|
||||
ArrayList<TypePlaceholder> ret = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
|
||||
ret.addAll(param.acceptTV(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(SuperWildcardType superWildcardType) {
|
||||
return superWildcardType.getInnerType().acceptTV(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(TypePlaceholder typePlaceholder) {
|
||||
return Arrays.asList(typePlaceholder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(ExtendsWildcardType extendsWildcardType) {
|
||||
return extendsWildcardType.getInnerType().acceptTV(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(GenericRefType genericRefType) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.writer;
|
||||
|
||||
public class ASPStatement {
|
||||
private final String stmt;
|
||||
public ASPStatement(String stmt) {
|
||||
this.stmt = stmt;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return stmt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return stmt.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj instanceof ASPStatement)return stmt.equals(((ASPStatement) obj).stmt);
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getASP() {
|
||||
return stmt;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package de.dhbwstuttgart.sat.asp.writer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class ASPWriter {
|
||||
|
||||
private HashSet<ASPStatement> content = new HashSet<>();
|
||||
|
||||
public void add(ASPStatement stmt){
|
||||
content.add(stmt);
|
||||
}
|
||||
|
||||
public String getASPFile(){
|
||||
String ret = "";
|
||||
for(ASPStatement statement : content){
|
||||
ret += statement.getASP() + ".\n";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void addAll(Collection<ASPStatement> aspStatements) {
|
||||
content.addAll(aspStatements);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ import org.antlr.v4.runtime.Token;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
/**
|
||||
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
||||
* Eine Feldinitialisation steht für eine Felddeklaration mit gleichzeitiger Wertzuweisung
|
||||
* Beispiel: 'public Feld FeldVar = FeldWert;'
|
||||
* @author janulrich
|
||||
*
|
||||
@ -17,7 +17,7 @@ public class FieldDeclaration extends Field{
|
||||
|
||||
/**
|
||||
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
|
||||
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
|
||||
* Kein nachträgliches hinzfügen von Informationen oder aufrufen von parserPostProcessing ist notwendig.
|
||||
*/
|
||||
public FieldDeclaration(String name, RefTypeOrTPHOrWildcardOrGeneric typ, int modifier, Expression value, Token offset){
|
||||
super(name, typ, modifier, offset);//Dieser Deklarator wird nicht vom Parser aufgerufen. Dadurch gibt es auch keinen Offset
|
||||
|
@ -77,7 +77,7 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope
|
||||
|
||||
@Override
|
||||
public Token getOffset() {
|
||||
return null;
|
||||
return super.getOffset();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -7,13 +7,10 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.sat.asp.model.ASPRule;
|
||||
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Void;
|
||||
|
@ -41,7 +41,7 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
/**
|
||||
* @author Andreas Stadelmeier, a10023
|
||||
* Ruft die TypePlaceholder.fresh()-Methode auf.
|
||||
* Fügt zusätzlich einen Replacementlistener hinzu.
|
||||
* Fügt zusätzlich einen Replacementlistener hinzu.
|
||||
* @return
|
||||
*/
|
||||
public static TypePlaceholder fresh(Token position){
|
||||
@ -64,6 +64,10 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
|
@ -124,10 +124,8 @@ public class OutputGenerator implements ASTVisitor{
|
||||
f.accept(this);
|
||||
out.append("\n");
|
||||
}
|
||||
Optional<Constructor> fI;
|
||||
if ((fI = classOrInterface.getfieldInitializations()).isPresent()) {
|
||||
out.append("Initializations:");
|
||||
fI.get().accept(this);
|
||||
if (classOrInterface.getfieldInitializations().isPresent()) {//PL 2019-11-28: Zum Ausdrucken der Fieldinitializer
|
||||
classOrInterface.getfieldInitializations().get().accept(this);
|
||||
}
|
||||
for(Method m : classOrInterface.getMethods()){
|
||||
out.append(tabs);
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
public enum KindOfTypeInsertPoint {
|
||||
NORMAL_INSERT,
|
||||
GENERIC_CLASS_INSERT,
|
||||
GENERERIC_METHOD_INSERT
|
||||
}
|
@ -1,8 +1,13 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.antlr.v4.parse.BlockSetTransformer.setAlt_return;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
@ -23,10 +28,15 @@ public class TypeInsert {
|
||||
|
||||
public String insert(String intoSource){
|
||||
List<TypeInsertPoint> offsets = new ArrayList<>();
|
||||
String ret = point.insert(intoSource, offsets);
|
||||
offsets.add(point);
|
||||
for(TypeInsertPoint insertPoint : inserts){
|
||||
ret = insertPoint.insert(ret, offsets);
|
||||
String ret = intoSource;
|
||||
|
||||
List<TypeInsertPoint> insertsSorted = new ArrayList<>();
|
||||
insertsSorted.add(point);
|
||||
insertsSorted.addAll(inserts);
|
||||
Collections.sort(insertsSorted, new TypeInsertPoint.TypeInsertPointPositionComparator().reversed());
|
||||
|
||||
for(TypeInsertPoint insertPoint : insertsSorted) {
|
||||
ret = insertPoint.insert(ret, new ArrayList<>());
|
||||
offsets.add(insertPoint);
|
||||
}
|
||||
return ret;
|
||||
@ -56,7 +66,14 @@ public class TypeInsert {
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPoints() {
|
||||
return this.inserts;
|
||||
TypeInsertPoint.TypeInsertPointPositionComparator comparator = new TypeInsertPoint.TypeInsertPointPositionComparator();
|
||||
TreeSet<TypeInsertPoint> result = new TreeSet<>(comparator.reversed());
|
||||
result.addAll(inserts);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPointsUnsorted() {
|
||||
return inserts;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
@ -1,20 +1,35 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.result.*;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
|
||||
import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH;
|
||||
import de.dhbwstuttgart.typeinference.result.ResolvedType;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSetVisitor;
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
@ -33,18 +48,21 @@ public class TypeInsertFactory {
|
||||
|
||||
private static List<ResultSet> newResults;
|
||||
|
||||
public static Set<TypeInsert> createTypeInsertPoints(SourceFile forSourcefile, ResultSet withResults, List<ResultSet> newResults){
|
||||
public static Set<TypeInsert> createTypeInsertPoints(SourceFile forSourcefile, ResultSet withResults, List<ResultSet> newResults, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles){
|
||||
TypeInsertFactory.newResults = newResults;
|
||||
return new TypeInsertPlacer().getTypeInserts(forSourcefile, withResults);
|
||||
return new TypeInsertPlacer().getTypeInserts(forSourcefile, withResults, simplifyResultsForAllSourceFiles);
|
||||
}
|
||||
|
||||
public static TypeInsert createInsertPoints(RefTypeOrTPHOrWildcardOrGeneric type, Token offset, ClassOrInterface cl, Method m,
|
||||
ResultSet resultSet) {
|
||||
ResultSet resultSet, List<GenericsGeneratorResult> constraints, List<GenericsGeneratorResult> classConstraints) {
|
||||
|
||||
try {
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
* try {
|
||||
*/
|
||||
ResolvedType resolvedType = resultSet.resolveType(type);
|
||||
TypeInsertPoint insertPoint = new TypeInsertPoint(offset,
|
||||
new TypeToInsertString(resolvedType.resolvedType).insert);
|
||||
new TypeToInsertString(resolvedType.resolvedType, constraints, classConstraints).insert, KindOfTypeInsertPoint.NORMAL_INSERT);
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
List<GenericGenratorResultForSourceFile> simplifyResults = JavaTXCompiler.INSTANCE.getGeneratedGenericResultsForAllSourceFiles(newResults);
|
||||
for (GenericGenratorResultForSourceFile simplifyResultsEntries : simplifyResults) {
|
||||
GenericsGeneratorResultForClass genericResultsForClass = simplifyResultsEntries.getSimplifyResultsByName(cl.getClassName());
|
||||
@ -52,30 +70,36 @@ public class TypeInsertFactory {
|
||||
}
|
||||
|
||||
return new TypeInsert(insertPoint, new HashSet<>(), resolvedType.getResultPair());
|
||||
*/
|
||||
//GenericsGeneratorResultForClass genericResultsForClass = genericResult.getSimplifyResultsByName("", cl.getClassName().toString());
|
||||
return new TypeInsert(insertPoint, createGenericInsert(constraints, classConstraints, cl, m, resultSet, offset), resolvedType.getResultPair());
|
||||
|
||||
/* PL 2020-04-11 auskommentiert
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private static synchronized Set<TypeInsertPoint> createGenericInsert(GenericsGeneratorResultForClass genericResult, ClassOrInterface cl, Method m, ResultSet resultSet, Token mOffset){
|
||||
Set<TypeInsertPoint> result = createGenericClassInserts(genericResult, cl);
|
||||
|
||||
for (Method method : cl.getMethods()) {
|
||||
Resolver resolver = new Resolver(resultSet);
|
||||
List<GenericsGeneratorResult> methodConstraints = genericResult.getMethodConstraintsByID(MethodUtility.createID(resolver, method));
|
||||
result.addAll(createMethodConstraints(method, methodConstraints, mOffset));
|
||||
}
|
||||
private static synchronized Set<TypeInsertPoint> createGenericInsert(List<GenericsGeneratorResult> methodConstraints, List<GenericsGeneratorResult> classConstraints,ClassOrInterface cl, Method m, ResultSet resultSet, Token mOffset){
|
||||
Set<TypeInsertPoint> result = createGenericClassInserts(classConstraints, cl);
|
||||
|
||||
Resolver resolver = new Resolver(resultSet);
|
||||
|
||||
if (m != null) {
|
||||
//List<GenericsGeneratorResult> methodConstraints = genericResult.getMethodConstraintsByID(MethodUtility.createID(resolver, m));
|
||||
result.addAll(createMethodConstraints(methodConstraints, m.getOffset() != null ? m.getOffset() : mOffset));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Set<TypeInsertPoint> createMethodConstraints(Method method, List<GenericsGeneratorResult> constraints, Token mOffset) {
|
||||
private static Set<TypeInsertPoint> createMethodConstraints(List<GenericsGeneratorResult> constraints, Token mOffset) {
|
||||
Set<TypeInsertPoint> result = new HashSet<>();
|
||||
Token offset = mOffset;
|
||||
|
||||
if (constraints.size() == 0) {
|
||||
result.add(new TypeInsertPoint(offset, ""));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -85,25 +109,25 @@ public class TypeInsertFactory {
|
||||
if (genericInsertConstraint.getConstraint().getRight().equals(Type.getInternalName(Object.class))) {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft();
|
||||
} else {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight() + ", ";
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight();
|
||||
}
|
||||
insert += ", ";
|
||||
}
|
||||
|
||||
insert = insert.substring(0, insert.length() -2);
|
||||
insert += ">";
|
||||
|
||||
result.add(new TypeInsertPoint(offset, insert));
|
||||
result.add(new TypeInsertPoint(offset, insert, KindOfTypeInsertPoint.GENERERIC_METHOD_INSERT));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Set<TypeInsertPoint> createGenericClassInserts(GenericsGeneratorResultForClass genericResult, ClassOrInterface cl) {
|
||||
private static Set<TypeInsertPoint> createGenericClassInserts(List<GenericsGeneratorResult> classConstraints, ClassOrInterface cl) {
|
||||
Set<TypeInsertPoint> result = new HashSet<>();
|
||||
Token offset = cl.getGenerics().getOffset();
|
||||
|
||||
List<GenericsGeneratorResult> classConstraints = genericResult.getClassConstraints();
|
||||
//List<GenericsGeneratorResult> classConstraints = genericResult.getClassConstraints();
|
||||
|
||||
if (classConstraints.size() == 0) {
|
||||
result.add(new TypeInsertPoint(offset, ""));
|
||||
if (classConstraints == null || classConstraints.size() == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -113,14 +137,15 @@ public class TypeInsertFactory {
|
||||
if (genericInsertConstraint.getConstraint().getRight().equals(Type.getInternalName(Object.class))) {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft();
|
||||
} else {
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight() + ", ";
|
||||
insert += genericInsertConstraint.getConstraint().getLeft() + " extends " + genericInsertConstraint.getConstraint().getRight();
|
||||
}
|
||||
insert += ", ";
|
||||
}
|
||||
|
||||
insert = insert.substring(0, insert.length() -2);
|
||||
insert += ">";
|
||||
|
||||
result.add(new TypeInsertPoint(offset, insert));
|
||||
result.add(new TypeInsertPoint(offset, insert, KindOfTypeInsertPoint.GENERIC_CLASS_INSERT));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -128,9 +153,14 @@ public class TypeInsertFactory {
|
||||
|
||||
class TypeToInsertString implements ResultSetVisitor{
|
||||
String insert = "";
|
||||
private List<GenericsGeneratorResult> constraints;
|
||||
private List<GenericsGeneratorResult> classConstraints;
|
||||
|
||||
|
||||
TypeToInsertString(RefTypeOrTPHOrWildcardOrGeneric type){
|
||||
type.accept(this);
|
||||
TypeToInsertString(RefTypeOrTPHOrWildcardOrGeneric type, List<GenericsGeneratorResult> constraints, List<GenericsGeneratorResult> classConstraints){
|
||||
this.constraints = constraints;
|
||||
this.classConstraints = classConstraints;
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -156,7 +186,7 @@ class TypeToInsertString implements ResultSetVisitor{
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> iterator = resolved.getParaList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
RefTypeOrTPHOrWildcardOrGeneric typeParam = iterator.next();
|
||||
insert += new TypeToInsertString(typeParam).insert;
|
||||
insert += new TypeToInsertString(typeParam, constraints, classConstraints).insert;
|
||||
if(iterator.hasNext())insert += ", ";
|
||||
}
|
||||
insert += ">";
|
||||
@ -170,16 +200,37 @@ class TypeToInsertString implements ResultSetVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
insert += "? super " + new TypeToInsertString(superWildcardType.getInnerType()).insert;
|
||||
insert += "? super " + new TypeToInsertString(superWildcardType.getInnerType(), constraints, classConstraints).insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
insert += typePlaceholder.getName();
|
||||
String realName = typePlaceholder.getName();
|
||||
//String realName = sig2.substring(1, sig2.length() - 1);
|
||||
//String toVisit = realName+SPECIAL_CHAR;
|
||||
//if(!genericsAndBounds.containsKey(toVisit)) {//PL 202-04-1 vielleicht braucht man das, vgl. Signature.java
|
||||
Optional<GenericsGeneratorResult> equalTPH = getEqualTPHFromClassConstraints(classConstraints, realName);
|
||||
if(equalTPH.isPresent()){
|
||||
insert += equalTPH.get().getConstraint().getLeft();// + SPECIAL_CHAR;
|
||||
} else {
|
||||
insert += getEqualTPH(constraints, realName);// + SPECIAL_CHAR;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
insert += "? extends " + new TypeToInsertString(extendsWildcardType.getInnerType()).insert;
|
||||
insert += "? extends " + new TypeToInsertString(extendsWildcardType.getInnerType(), constraints, classConstraints).insert;
|
||||
}
|
||||
|
||||
private Optional<GenericsGeneratorResult> getEqualTPHFromClassConstraints(List<GenericsGeneratorResult> listOfConstraints, String tph) {
|
||||
return listOfConstraints.stream()
|
||||
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private String getEqualTPH(List<GenericsGeneratorResult> constraints2, String tph) {
|
||||
return constraints2.stream()
|
||||
.filter(c -> c.getConstraint().getLeft().equals(tph) || c.getEqualsTPHs().contains(tph))
|
||||
.findFirst().get().getConstraint().getLeft();
|
||||
}
|
||||
}
|
@ -1,10 +1,16 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResult;
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodUtility;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Resolver;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -12,47 +18,68 @@ import java.util.Set;
|
||||
public class TypeInsertPlacer extends AbstractASTWalker{
|
||||
Set<TypeInsert> inserts = new HashSet<>();
|
||||
private ResultSet withResults;
|
||||
String pkgName;
|
||||
private List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles;
|
||||
|
||||
public Set<TypeInsert> getTypeInserts(SourceFile forSourceFile, ResultSet withResults){
|
||||
public Set<TypeInsert> getTypeInserts(SourceFile forSourceFile, ResultSet withResults, List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles){
|
||||
this.withResults = withResults;
|
||||
this.simplifyResultsForAllSourceFiles = simplifyResultsForAllSourceFiles;
|
||||
pkgName = forSourceFile.getPkgName();
|
||||
forSourceFile.accept(this);
|
||||
return inserts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults);
|
||||
GenericsGeneratorResultForClass generatedGenerics = simplifyResultsForAllSourceFiles
|
||||
.stream()
|
||||
.map(sr->sr.getSimplifyResultsByName(classOrInterface.getClassName()))
|
||||
.findFirst()
|
||||
.get();
|
||||
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults, generatedGenerics);
|
||||
this.inserts.addAll(cl.inserts);
|
||||
}
|
||||
}
|
||||
|
||||
class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||
protected final ResultSet results;
|
||||
private GenericsGeneratorResultForClass generatedGenerics;
|
||||
protected final ClassOrInterface cl;
|
||||
public final Set<TypeInsert> inserts = new HashSet<>();
|
||||
private Method method;
|
||||
|
||||
private Resolver resolver;
|
||||
|
||||
List<GenericsGeneratorResult> constraints;
|
||||
List<GenericsGeneratorResult> classConstraints;
|
||||
|
||||
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults){
|
||||
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults, GenericsGeneratorResultForClass generatedGenerics){
|
||||
this.cl = forClass;
|
||||
this.method = null;
|
||||
this.results = withResults;
|
||||
this.generatedGenerics = generatedGenerics;
|
||||
resolver = new Resolver(withResults); //PL 2020-04-12 Ob das stimmt weiss ich nicht
|
||||
forClass.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
this.method = method;
|
||||
String id = MethodUtility.createID(resolver, method);
|
||||
constraints = generatedGenerics.getMethodConstraintsByID(id);
|
||||
classConstraints = generatedGenerics.getClassConstraints();
|
||||
if(method.getReturnType() instanceof TypePlaceholder)
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
method.getReturnType(), method.getReturnType().getOffset(), cl, method, results));
|
||||
method.getReturnType(), method.getReturnType().getOffset(), cl, method, results, constraints, classConstraints));
|
||||
super.visit(method);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
if(field.getType() instanceof TypePlaceholder){
|
||||
classConstraints = generatedGenerics.getClassConstraints();
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
field.getType(), field.getType().getOffset(), cl, method, results));
|
||||
field.getType(), field.getType().getOffset(), cl, method, results, new ArrayList<>(), classConstraints));
|
||||
}
|
||||
super.visit(field);
|
||||
}
|
||||
@ -61,7 +88,7 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||
public void visit(FormalParameter param) {
|
||||
if(param.getType() instanceof TypePlaceholder)
|
||||
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||
param.getType(), param.getType().getOffset(), cl, method, results));
|
||||
param.getType(), param.getType().getOffset(), cl, method, results, constraints, classConstraints));
|
||||
super.visit(param);
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,29 @@
|
||||
package de.dhbwstuttgart.typedeployment;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class TypeInsertPoint {
|
||||
public Token point;
|
||||
private String insertString;
|
||||
private int extraOffset = 0;
|
||||
private KindOfTypeInsertPoint kind;
|
||||
|
||||
public TypeInsertPoint(Token point, String toInsert){
|
||||
public TypeInsertPoint(Token point, String toInsert, KindOfTypeInsertPoint kind){
|
||||
this.point = point;
|
||||
this.kind = kind;
|
||||
this.insertString = (toInsert.endsWith(" ")) ? toInsert : toInsert + " " ;
|
||||
}
|
||||
|
||||
public boolean isGenericClassInsertPoint() {
|
||||
return kind == KindOfTypeInsertPoint.GENERIC_CLASS_INSERT;
|
||||
}
|
||||
|
||||
public String insert(String intoSource, List<TypeInsertPoint> additionalOffset){
|
||||
int offset = additionalOffset.stream().filter((token ->
|
||||
//token.point.getLine() != point.getLine() && token.point.getCharPositionInLine() <= point.getCharPositionInLine()))
|
||||
token.point.getStartIndex() <= point.getStartIndex()))
|
||||
.mapToInt((typeInsertPoint -> typeInsertPoint.insertString.length())).sum();
|
||||
return new StringBuilder(intoSource).insert(point.getStartIndex()+offset+extraOffset, insertString).toString();
|
||||
return new StringBuilder(intoSource).insert(point.getStartIndex()+extraOffset, insertString).toString();
|
||||
}
|
||||
|
||||
public String getInsertString() {
|
||||
@ -45,13 +44,21 @@ public class TypeInsertPoint {
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
/*
|
||||
if(!(obj instanceof TypeInsertPoint)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return ((TypeInsertPoint)obj).point.equals(this.point) &&
|
||||
((TypeInsertPoint)obj).insertString.equals(this.insertString);
|
||||
}
|
||||
return
|
||||
((TypeInsertPoint)obj).getPositionInCode() == this.getPositionInCode() &&
|
||||
((TypeInsertPoint)obj).insertString.equals(this.insertString);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getPositionInCode() * 11 * insertString.hashCode();
|
||||
}
|
||||
|
||||
public Set<TypeInsertPoint> getAdditionalPoints() {
|
||||
@ -59,6 +66,28 @@ public class TypeInsertPoint {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return point.toString() + " " + insertString.toString();
|
||||
return point.getLine() + ":" + point.getCharPositionInLine() + ":" + insertString;
|
||||
}
|
||||
|
||||
public static final class TypeInsertPointPositionComparator implements Comparator<TypeInsertPoint> {
|
||||
|
||||
@Override
|
||||
public int compare(TypeInsertPoint o1, TypeInsertPoint o2) {
|
||||
if (o1.point == null && o2.point == null) {
|
||||
return 0;
|
||||
} else if (o2.point == null) {
|
||||
return 1;
|
||||
} else if (o1.point == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (o1.getPositionInCode() > o2.getPositionInCode()) {
|
||||
return 1;
|
||||
} else if (o1.getPositionInCode() < o2.getPositionInCode()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
for(FieldAssumption fieldAssumption : info.getFields(fieldVar.fieldVarName)){
|
||||
Constraint constraint = new Constraint();
|
||||
GenericsResolver resolver = getResolverInstance();
|
||||
constraint.add(new Pair(fieldVar.receiver.getType(), fieldAssumption.getReceiverType(resolver), PairOperator.EQUALSDOT));
|
||||
constraint.add(new Pair(fieldVar.receiver.getType(), fieldAssumption.getReceiverType(resolver), PairOperator.SMALLERDOT)); //PL 2019-12-09: SMALLERDOT eingefuegt, EQUALSDOT entfernt, wenn ds Field privat ist muesste es EQUALSDOT lauten
|
||||
constraint.add(new Pair(
|
||||
fieldVar.getType(), fieldAssumption.getType(resolver), PairOperator.EQUALSDOT));
|
||||
oderConstraints.add(constraint);
|
||||
@ -587,14 +587,10 @@ public class TYPEStmt implements StatementVisitor{
|
||||
*/
|
||||
|
||||
RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver);
|
||||
methodConstraint.add(new Pair(forMethod.receiver.getType(), retType,
|
||||
PairOperator.EQUALSDOT));//PL 2020-03-17 SMALLERDOT in EQUALSDOT umgewandelt, weil alle geerbten Methoden in den jeweilen Klassen enthalten sind.
|
||||
|
||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
||||
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
||||
// PairOperator.EQUALSDOT));
|
||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||
|
||||
methodConstraint.add(forMethod.name.equals("apply") ? //PL 2019-11-29: Tenaerer Operator eingefügt, weil bei Lambda-Ausdrücken keine Suntype FunN$$ existiert
|
||||
new Pair(forMethod.receiver.getType(), retType, PairOperator.EQUALSDOT)
|
||||
: new Pair(forMethod.receiver.getType(), retType, PairOperator.SMALLERDOT));
|
||||
|
||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
||||
PairOperator.EQUALSDOT));
|
||||
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
||||
|
@ -28,8 +28,8 @@ public class TypeUnify {
|
||||
* @param cons
|
||||
* @return
|
||||
*/
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||
@ -54,8 +54,8 @@ public class TypeUnify {
|
||||
* @param ret
|
||||
* @return
|
||||
*/
|
||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
return ret;
|
||||
@ -68,12 +68,11 @@ public class TypeUnify {
|
||||
* @param fc
|
||||
* @param logFile
|
||||
* @param log
|
||||
* @param cons
|
||||
* @param ret
|
||||
* @return
|
||||
*/
|
||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, usedTasks);
|
||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||
ForkJoinPool pool = new ForkJoinPool();
|
||||
pool.invoke(unifyTask);
|
||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||
@ -102,11 +101,10 @@ public class TypeUnify {
|
||||
* @param fc
|
||||
* @param logFile
|
||||
* @param log
|
||||
* @param cons
|
||||
* @return
|
||||
*/
|
||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret, UnifyTaskModel usedTasks) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret, usedTasks);
|
||||
public Set<Set<UnifyPair>> unifyOderConstraints(Set<UnifyPair> undConstrains, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret);
|
||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||
try {
|
||||
logFile.write("\nnoShortendElements: " + unifyTask.noShortendElements +"\n");
|
||||
|
@ -0,0 +1,30 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TypeUnify2Future {
|
||||
|
||||
Set<Set<UnifyPair>> setToFlatten;
|
||||
|
||||
public TypeUnify2Future(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
this.setToFlatten = setToFlatten;
|
||||
this.nextSetElement = nextSetElement;
|
||||
}
|
||||
|
||||
Set<UnifyPair> getNextSetElement() {
|
||||
return nextSetElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Set<UnifyPair>> compute() {
|
||||
Set<Set<UnifyPair>> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, true);
|
||||
return res;
|
||||
}
|
||||
}
|
@ -18,8 +18,8 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
||||
|
||||
Set<Set<UnifyPair>> setToFlatten;
|
||||
|
||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
this.setToFlatten = setToFlatten;
|
||||
this.nextSetElement = nextSetElement;
|
||||
}
|
||||
@ -30,35 +30,7 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
||||
|
||||
@Override
|
||||
protected Set<Set<UnifyPair>> compute() {
|
||||
if (one) {
|
||||
System.out.println("two");
|
||||
}
|
||||
one = true;
|
||||
Set<Set<UnifyPair>> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, true);
|
||||
/*if (isUndefinedPairSetSet(res)) {
|
||||
return new HashSet<>(); }
|
||||
else
|
||||
*/
|
||||
//writeLog("xxx");
|
||||
//noOfThread--;
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public void closeLogFile() {
|
||||
|
||||
try {
|
||||
logFile.close();
|
||||
}
|
||||
catch (IOException ioE) {
|
||||
System.err.println("no log-File" + thNo);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,33 @@ import com.google.common.collect.Ordering;
|
||||
* Implementation of the type unification algorithm
|
||||
* @author Florian Steurer
|
||||
*/
|
||||
public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
public class TypeUnifyTask {
|
||||
|
||||
public static Set<Set<UnifyPair>> typeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm){
|
||||
Set<UnifyPair> neweq = new HashSet<>(eq);
|
||||
/* 1-elementige Oder-Constraints werden in und-Constraints umgewandelt */
|
||||
oderConstraints.stream()
|
||||
.filter(x -> x.size()==1)
|
||||
.map(y -> y.stream().findFirst().get()).forEach(x -> neweq.addAll(x));
|
||||
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraints.stream()
|
||||
.filter(x -> x.size()>1)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefe, true);
|
||||
try {
|
||||
logFile.close();
|
||||
}
|
||||
catch (IOException ioE) {
|
||||
System.err.println("no log-File");
|
||||
}
|
||||
if (isUndefinedPairSetSet(res)) {
|
||||
throw new TypeinferenceException("Unresolved constraints: " + res.toString(), new NullToken()); //return new HashSet<>();
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static int i = 0;
|
||||
@ -71,16 +97,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* Element, das aus dem nextSet den Gleichunen dieses Threads hinzugefuegt wurde
|
||||
*/
|
||||
Set<UnifyPair> nextSetElement;
|
||||
|
||||
Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm
|
||||
/**
|
||||
* Fuer die Threads
|
||||
*/
|
||||
UnifyResultModel urm;
|
||||
protected static int noOfThread = 0;
|
||||
private static int totalnoOfThread = 0;
|
||||
int thNo;
|
||||
protected boolean one = false;
|
||||
Integer MaxNoOfThreads = 8;
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||
Writer logFile;
|
||||
@ -123,31 +144,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
static int noBacktracking;
|
||||
|
||||
static Integer noShortendElements = 0;
|
||||
|
||||
Boolean myIsCanceled = false;
|
||||
|
||||
volatile UnifyTaskModel usedTasks;
|
||||
|
||||
|
||||
public TypeUnifyTask() {
|
||||
rules = new RuleSet();
|
||||
}
|
||||
|
||||
/*
|
||||
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log) {
|
||||
this.eq = eq;
|
||||
this.fc = fc;
|
||||
this.oup = new OrderingUnifyPair(fc);
|
||||
this.parallel = parallel;
|
||||
this.logFile = logFile;
|
||||
this.log = log;
|
||||
rules = new RuleSet(logFile);
|
||||
noOfThread++;
|
||||
thNo = noOfThread;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, UnifyTaskModel usedTasks) {
|
||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||
synchronized (this) {
|
||||
this.eq = eq;
|
||||
//this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
||||
@ -167,82 +170,28 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
this.parallel = parallel;
|
||||
this.logFile = logFile;
|
||||
this.log = log;
|
||||
|
||||
noOfThread++;
|
||||
totalnoOfThread++;
|
||||
//writeLog("thNo1 " + thNo);
|
||||
thNo = totalnoOfThread;
|
||||
writeLog("thNo2 " + thNo);
|
||||
try {
|
||||
this.logFile = //new OutputStreamWriter(new NullOutputStream());
|
||||
//new FileWriter(new File(System.getProperty("user.dir")+"/src/test/resources/logFiles/"+"Thread_"+thNo));
|
||||
new FileWriter(new File(System.getProperty("user.dir")+"/logFiles/"+"Thread_"+thNo));
|
||||
logFile.write("");
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("log-File nicht vorhanden");
|
||||
}
|
||||
|
||||
/*Abbruchtest
|
||||
if (thNo > 10) {
|
||||
System.out.println("cancel");
|
||||
usedTasks.cancel();
|
||||
writeLog(nOfUnify.toString() + "cancel");
|
||||
System.out.println("cancel");
|
||||
try {
|
||||
logFile.write("Abbruch");
|
||||
}
|
||||
catch (IOException e) {
|
||||
System.err.println("log-File nicht vorhanden");
|
||||
}
|
||||
}
|
||||
*/
|
||||
rules = new RuleSet(logFile);
|
||||
this.rekTiefeField = rekTiefe;
|
||||
this.urm = urm;
|
||||
this.usedTasks = usedTasks;
|
||||
this.usedTasks.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vererbt alle Variancen
|
||||
* @param eq The set of constraints
|
||||
*/
|
||||
/* PL 2018-05- 17 verschoben nach JavaTXCompiler
|
||||
private void varianceInheritance(Set<UnifyPair> eq) {
|
||||
Set<PlaceholderType> usedTPH = new HashSet<>();
|
||||
Set<PlaceholderType> phSet = eq.stream().map(x -> {
|
||||
Set<PlaceholderType> pair = new HashSet<>();
|
||||
if (x.getLhsType() instanceof PlaceholderType) pair.add((PlaceholderType)x.getLhsType());
|
||||
if (x.getRhsType() instanceof PlaceholderType) pair.add((PlaceholderType)x.getRhsType());
|
||||
return pair;
|
||||
}).reduce(new HashSet<>(), (a,b) -> { a.addAll(b); return a;} , (c,d) -> { c.addAll(d); return c;});
|
||||
|
||||
ArrayList<PlaceholderType> phSetVariance = new ArrayList<>(phSet);
|
||||
phSetVariance.removeIf(x -> (x.getVariance() == 0));
|
||||
while(!phSetVariance.isEmpty()) {
|
||||
PlaceholderType a = phSetVariance.remove(0);
|
||||
usedTPH.add(a);
|
||||
//HashMap<PlaceholderType,Integer> ht = new HashMap<>();
|
||||
//ht.put(a, a.getVariance());
|
||||
Set<UnifyPair> eq1 = new HashSet<>(eq);
|
||||
eq1.removeIf(x -> !(x.getLhsType() instanceof PlaceholderType && ((PlaceholderType)x.getLhsType()).equals(a)));
|
||||
eq1.stream().forEach(x -> { x.getRhsType().accept(new distributeVariance(), a.getVariance());});
|
||||
eq1 = new HashSet<>(eq);
|
||||
eq1.removeIf(x -> !(x.getRhsType() instanceof PlaceholderType && ((PlaceholderType)x.getRhsType()).equals(a)));
|
||||
eq1.stream().forEach(x -> { x.getLhsType().accept(new distributeVariance(), a.getVariance());});
|
||||
phSetVariance = new ArrayList<>(phSet);
|
||||
phSetVariance.removeIf(x -> (x.getVariance() == 0 || usedTPH.contains(x)));
|
||||
}
|
||||
}
|
||||
*/
|
||||
void myCancel(Boolean b) {
|
||||
myIsCanceled = true;
|
||||
}
|
||||
|
||||
public boolean myIsCancelled() {
|
||||
return myIsCanceled;
|
||||
}
|
||||
|
||||
protected Set<Set<UnifyPair>> compute() {
|
||||
if (one) {
|
||||
System.out.println("two");
|
||||
}
|
||||
one = true;
|
||||
Set<UnifyPair> neweq = new HashSet<>(eq);
|
||||
/* 1-elementige Oder-Constraints werden in und-Constraints umgewandelt */
|
||||
oderConstraintsField.stream()
|
||||
@ -252,7 +201,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
.filter(x -> x.size()>1)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, true);
|
||||
noOfThread--;
|
||||
try {
|
||||
logFile.close();
|
||||
}
|
||||
@ -263,15 +211,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
throw new TypeinferenceException("Unresolved constraints: " + res.toString(), new NullToken()); //return new HashSet<>();
|
||||
}
|
||||
else {
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
@ -293,23 +236,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
* @param fc The finite closure
|
||||
* @return The set of all principal type unifiers
|
||||
*/
|
||||
protected Set<Set<UnifyPair>> unify(final Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
||||
//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("");
|
||||
//}
|
||||
protected static Set<Set<UnifyPair>> unify(final Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
||||
|
||||
//.collect(Collectors.toCollection(HashSet::new)));
|
||||
/*
|
||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||
*/
|
||||
|
||||
rekTiefe++;
|
||||
nOfUnify++;
|
||||
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
||||
writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString());
|
||||
|
||||
/*
|
||||
* Variancen auf alle Gleichungen vererben
|
||||
@ -446,7 +375,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
//Aufruf von computeCartesianRecursive ANFANG
|
||||
//writeLog("topLevelSets: " + topLevelSets.toString());
|
||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe, finalresult);
|
||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, rekTiefe, finalresult);
|
||||
|
||||
}
|
||||
|
||||
@ -454,18 +383,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
||||
//Aufruf von computeCartesianRecursive ENDE
|
||||
|
||||
//keine Ahnung woher das kommt
|
||||
//Set<Set<UnifyPair>> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
//Muss auskommentiert werden, wenn computeCartesianRecursive ANFANG
|
||||
// Cartesian product over all (up to 10) top level sets
|
||||
//Set<Set<Set<UnifyPair>>> eqPrimeSet = setOps.cartesianProduct(topLevelSets)
|
||||
// .stream().map(x -> new HashSet<>(x))
|
||||
// .collect(Collectors.toCollection(HashSet::new));
|
||||
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
|
||||
|
||||
|
||||
|
||||
Set<Set<UnifyPair>> eqPrimePrimeSet = new HashSet<>();
|
||||
|
||||
Set<TypeUnifyTask> forks = new HashSet<>();
|
||||
@ -488,47 +406,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<Set<UnifyPair>> unifyres1 = null;
|
||||
Set<Set<UnifyPair>> unifyres2 = null;
|
||||
if (!ocString.equals(newOderConstraints.toString())) writeLog("nach Subst: " + newOderConstraints);
|
||||
//writeLog("nach Subst: " + eqPrimePrime);
|
||||
/*
|
||||
* Step 6 a) Restart (fork) for pairs where subst was applied
|
||||
*/
|
||||
/*
|
||||
if(parallel) {
|
||||
if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()
|
||||
&& oderConstraints.isEmpty()) //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch
|
||||
//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.
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
else if(eqPrimePrime.isPresent()) {
|
||||
//System.out.println("nextStep: " + eqPrimePrime.get());
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true, logFile, log);
|
||||
forks.add(fork);
|
||||
fork.fork();
|
||||
}
|
||||
else {
|
||||
//System.out.println("nextStep: " + eqPrime);
|
||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true, logFile, log);
|
||||
forks.add(fork);
|
||||
fork.fork();
|
||||
}
|
||||
}
|
||||
else */
|
||||
{// sequentiell (Step 6b is included)
|
||||
if (printtag) System.out.println("nextStep: " + eqPrimePrime);
|
||||
if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()
|
||||
&& oderConstraints.isEmpty()) { //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch
|
||||
//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)) {
|
||||
// writeLog("eqPrime:" + eqPrime.toString()+"\n");
|
||||
//}
|
||||
//}
|
||||
//catch (IOException e) {
|
||||
// System.err.println("log-File nicht vorhanden");
|
||||
//}
|
||||
&& oderConstraints.isEmpty()) {
|
||||
eqPrimePrimeSet.add(eqPrime);
|
||||
if (finalresult && isSolvedForm(eqPrime)) {
|
||||
writeLog("eqPrime:" + eqPrime.toString()+"\n");
|
||||
@ -547,23 +427,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
eqPrimePrimeSet.addAll(unifyres);
|
||||
}
|
||||
}
|
||||
//Muss auskommentiert werden, wenn computeCartesianRecursive ANFANG
|
||||
//}
|
||||
//Muss auskommentiert werden, wenn computeCartesianRecursive ENDE
|
||||
|
||||
/*
|
||||
* Step 6 b) Build the union over everything.
|
||||
*/
|
||||
/*
|
||||
* PL 2019-01-22: geloescht
|
||||
|
||||
if(parallel)
|
||||
for(TypeUnifyTask fork : forks)
|
||||
eqPrimePrimeSet.addAll(fork.join());
|
||||
*/
|
||||
/*
|
||||
* 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());
|
||||
@ -573,9 +436,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
|
||||
|
||||
|
||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
||||
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
||||
|
||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, int rekTiefe, Boolean finalresult) {
|
||||
fstElems.addAll(topLevelSets.stream()
|
||||
.filter(x -> x.size()==1)
|
||||
.map(y -> y.stream().findFirst().get())
|
||||
@ -588,17 +449,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
return result;
|
||||
}
|
||||
Set<? extends Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||
//writeLog("nextSet: " + nextSet.toString());
|
||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||
/*
|
||||
try {
|
||||
//List<Set<UnifyPair>>
|
||||
//nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet);
|
||||
}
|
||||
catch (java.lang.IllegalArgumentException e) {
|
||||
System.out.print("");
|
||||
}
|
||||
*/
|
||||
|
||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||
int variance = 0;
|
||||
|
||||
@ -655,25 +507,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
System.out.print("");
|
||||
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||
System.out.print("");
|
||||
//writeLog("nextSetasList: " + nextSetasList.toString());
|
||||
|
||||
Set<UnifyPair> nextSetElem = nextSetasList.get(0);
|
||||
//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 */
|
||||
Set<UnifyPair> sameEqSet = new HashSet<>();
|
||||
Optional<UnifyPair> optOrigPair = null;
|
||||
//if (variance != 2) {
|
||||
if (!oderConstraint) {
|
||||
optOrigPair = nextSetElem.stream().filter(x -> (
|
||||
//x.getBasePair() != null && ist gegeben wenn variance != 2
|
||||
//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.getPairOp().equals(PairOperator.EQUALSDOT)
|
||||
))).filter(x -> //Sicherstellen, dass bei a = ty a auch wirklich die gesuchte Typvariable ist
|
||||
x.getLhsType().equals(x.getBasePair().getLhsType()) ||
|
||||
x.getLhsType().equals(x.getBasePair().getRhsType())
|
||||
@ -822,7 +664,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
/* PL 2019-03-11 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */
|
||||
|
||||
if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) {
|
||||
if(parallel && (variance == 1)) {
|
||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||
@ -830,14 +672,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
newElemsOrig.add(a);
|
||||
|
||||
/* FORK ANFANG */
|
||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
//forks.add(forkOrig);
|
||||
synchronized(usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
forkOrig.fork();
|
||||
}
|
||||
/* FORK ENDE */
|
||||
|
||||
synchronized (this) {
|
||||
@ -886,37 +722,20 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||
List<Set<Constraint<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||
newElems.add(nSaL);
|
||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||
forks.add(fork);
|
||||
synchronized(usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
fork.fork();
|
||||
}
|
||||
TypeUnify2Task fork = new TypeUnify2Task(newElems, newEq, newOderConstraints, nSaL, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
}
|
||||
//res = unify2(newElemsOrig, newEqOrig, newOderConstraintsOrig, fc, parallel, rekTiefe);
|
||||
|
||||
/* FORK ANFANG */
|
||||
synchronized (this) {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig 1");
|
||||
forkOrig.closeLogFile();
|
||||
//Set<Set<UnifyPair>> fork_res = forkOrig.join();
|
||||
writeLog("JoinOrig " + new Integer(forkOrig.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
//add_res.add(fork_res);
|
||||
};
|
||||
/* FORK ENDE */
|
||||
|
||||
forks.forEach(x -> writeLog("wait: " + x.thNo));
|
||||
|
||||
res = forkOrig.join();
|
||||
|
||||
for(TypeUnify2Task fork : forks) {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -927,28 +746,18 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
aParDef.add(fork.getNextSetElement());
|
||||
}
|
||||
fork.writeLog("final 1");
|
||||
fork.closeLogFile();
|
||||
};
|
||||
}
|
||||
//noOfThread++;
|
||||
} else {
|
||||
if(parallel && (variance == -1) && noOfThread <= MaxNoOfThreads) {
|
||||
if((variance == -1)) {
|
||||
Set<TypeUnify2Task> forks = new HashSet<>();
|
||||
Set<UnifyPair> newEqOrig = new HashSet<>(eq);
|
||||
Set<Set<UnifyPair>> newElemsOrig = new HashSet<>(elems);
|
||||
List<Set<Constraint<UnifyPair>>> newOderConstraintsOrig = new ArrayList<>(oderConstraints);
|
||||
newElemsOrig.add(a);
|
||||
|
||||
/* FORK ANFANG */
|
||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm, usedTasks);
|
||||
//forks.add(forkOrig);
|
||||
synchronized(usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
forkOrig.fork();
|
||||
}
|
||||
/* FORK ENDE */
|
||||
|
||||
TypeUnify2Task forkOrig = new TypeUnify2Task(newElemsOrig, newEqOrig, newOderConstraintsOrig, a, fc, parallel, logFile, log, rekTiefe, urm);
|
||||
|
||||
synchronized (this) {
|
||||
writeLog("a in " + variance + " "+ a);
|
||||
@ -1012,6 +821,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig -1");
|
||||
forkOrig.closeLogFile();
|
||||
@ -1027,6 +841,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -1088,6 +907,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
writeLog("wait "+ forkOrig.thNo);
|
||||
noOfThread--;
|
||||
res = forkOrig.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
forkOrig.writeLog("final Orig 2");
|
||||
forkOrig.closeLogFile();
|
||||
@ -1102,6 +926,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
synchronized (this) {
|
||||
noOfThread--;
|
||||
Set<Set<UnifyPair>> fork_res = fork.join();
|
||||
synchronized (usedTasks) {
|
||||
if (this.myIsCancelled()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
//noOfThread++;
|
||||
writeLog("Join " + new Integer(fork.thNo).toString());
|
||||
//noOfThread--; an das Ende von compute verschoben
|
||||
@ -1223,7 +1052,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) {
|
||||
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
||||
result = par_res;
|
||||
if (par_res.iterator().next() instanceof WildcardType) {
|
||||
if (!par_res.isEmpty() && par_res.iterator().next() instanceof WildcardType) {
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
@ -1583,7 +1412,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
return true;}).reduce((xx, yy) -> xx || yy).get();
|
||||
}
|
||||
|
||||
protected boolean isUndefinedPairSet(Set<UnifyPair> s) {
|
||||
protected static boolean isUndefinedPairSet(Set<UnifyPair> s) {
|
||||
if (s.size() >= 1 ) {
|
||||
Boolean ret = s.stream().map(x -> x.isUndefinedPair()).reduce(true, (x,y)-> (x && y));
|
||||
return ret;
|
||||
@ -1593,7 +1422,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isUndefinedPairSetSet(Set<Set<UnifyPair>> s) {
|
||||
protected static boolean isUndefinedPairSetSet(Set<Set<UnifyPair>> s) {
|
||||
if (s.size() >= 1) {
|
||||
Boolean ret = s.stream(). map(x -> isUndefinedPairSet(x)).reduce(true, (x,y)-> (x && y));
|
||||
return ret;
|
||||
@ -1652,7 +1481,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
/*
|
||||
* Apply rules until the queue is empty
|
||||
*/
|
||||
while(!eqQueue.isEmpty()) {
|
||||
while(!eqQueue.isEmpty()) {
|
||||
UnifyPair pair = eqQueue.pollFirst();
|
||||
|
||||
// ReduceUp, ReduceLow, ReduceUpLow
|
||||
|
@ -1,18 +0,0 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
public class UnifyResultEvent {
|
||||
|
||||
private List<ResultSet> newTypeResult;
|
||||
|
||||
public UnifyResultEvent(List<ResultSet> newTypeResult) {
|
||||
this.newTypeResult = newTypeResult;
|
||||
}
|
||||
|
||||
public List<ResultSet> getNewTypeResult() {
|
||||
return newTypeResult;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
public interface UnifyResultListener {
|
||||
|
||||
void onNewTypeResultFound(UnifyResultEvent evt);
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class UnifyResultListenerImpl implements UnifyResultListener {
|
||||
|
||||
List<ResultSet> results = new ArrayList<>();
|
||||
|
||||
public synchronized void onNewTypeResultFound(UnifyResultEvent evt) {
|
||||
results.addAll(evt.getNewTypeResult());
|
||||
}
|
||||
|
||||
public List<ResultSet> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class UnifyResultModel {
|
||||
|
||||
ConstraintSet<de.dhbwstuttgart.typeinference.constraints.Pair> cons;
|
||||
|
||||
IFiniteClosure fc;
|
||||
|
||||
public UnifyResultModel(ConstraintSet<de.dhbwstuttgart.typeinference.constraints.Pair> cons,
|
||||
IFiniteClosure fc) {
|
||||
this.cons = cons;
|
||||
this.fc = fc;
|
||||
}
|
||||
|
||||
private List<UnifyResultListener> listeners = new ArrayList<>();
|
||||
|
||||
public void addUnifyResultListener(UnifyResultListener listenerToAdd) {
|
||||
listeners.add(listenerToAdd);
|
||||
}
|
||||
|
||||
public void removeUnifyResultListener(UnifyResultListener listenerToRemove) {
|
||||
listeners.remove(listenerToRemove);
|
||||
}
|
||||
|
||||
public void notify(Set<Set<UnifyPair>> eqPrimePrimeSet) {
|
||||
Set<Set<UnifyPair>> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> {
|
||||
Optional<Set<UnifyPair>> res = new RuleSet().subst(x.stream().map(y -> {
|
||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
|
||||
return y; //alle Paare a <.? b erden durch a =. b ersetzt
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert
|
||||
return new TypeUnifyTask().applyTypeUnificationRules(res.get(), fc);
|
||||
}
|
||||
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
List<ResultSet> newResult = eqPrimePrimeSetRet.stream().map(unifyPairs ->
|
||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, de.dhbwstuttgart.typeinference.constraints.Pair.generateTPHMap(cons))))
|
||||
.collect(Collectors.toList());
|
||||
UnifyResultEvent evt = new UnifyResultEvent(newResult);
|
||||
|
||||
for (UnifyResultListener listener : listeners) {
|
||||
listener.onNewTypeResultFound(evt);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package de.dhbwstuttgart.typeinference.unify;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UnifyTaskModel {
|
||||
|
||||
ArrayList<TypeUnifyTask> usedTasks = new ArrayList<>();
|
||||
|
||||
public synchronized void add(TypeUnifyTask t) {
|
||||
usedTasks.add(t);
|
||||
}
|
||||
|
||||
public synchronized void cancel() {
|
||||
for(TypeUnifyTask t : usedTasks) {
|
||||
t.myCancel(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,8 +29,6 @@ public class UnifyPair {
|
||||
*/
|
||||
private PairOperator pairOp;
|
||||
|
||||
private boolean undefinedPair = false;
|
||||
|
||||
/**
|
||||
* Unifier/substitute that generated this pair
|
||||
* PL 2018-03-15
|
||||
@ -114,10 +112,7 @@ public class UnifyPair {
|
||||
public void addSubstitutions(Set<UnifyPair> sup) {
|
||||
substitution.addAll(sup);
|
||||
}
|
||||
|
||||
public void setUndefinedPair() {
|
||||
undefinedPair = true;
|
||||
}
|
||||
|
||||
public Set<UnifyPair> getSubstitution() {
|
||||
return new HashSet<>(substitution);
|
||||
}
|
||||
@ -125,10 +120,6 @@ public class UnifyPair {
|
||||
public UnifyPair getBasePair() {
|
||||
return basePair;
|
||||
}
|
||||
public boolean isUndefinedPair() {
|
||||
return undefinedPair;
|
||||
}
|
||||
|
||||
public Set<UnifyPair> getAllSubstitutions () {
|
||||
Set<UnifyPair> ret = new HashSet<>();
|
||||
ret.addAll(new ArrayList<>(getSubstitution()));
|
||||
|
@ -114,6 +114,7 @@ public abstract class UnifyType {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(obj == null)return false;
|
||||
return this.toString().equals(obj.toString());
|
||||
}
|
||||
}
|
@ -39,7 +39,8 @@ public class AllgemeinTest {
|
||||
//String className = "Pair";
|
||||
//String className = "FCTest3";
|
||||
//String className = "Var";
|
||||
String className = "Put";
|
||||
//String className = "Put";
|
||||
String className = "Cycle";
|
||||
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
|
@ -1,52 +0,0 @@
|
||||
package asp;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
|
||||
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
|
||||
import de.dhbwstuttgart.sat.asp.Clingo;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonObject;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ClingoTest {
|
||||
public static final String tempDirectory = "/tmp/";
|
||||
private final TypePlaceholder testType = TypePlaceholder.fresh(new NullToken());
|
||||
@Test
|
||||
public void test() throws IOException, InterruptedException, ClassNotFoundException {
|
||||
String content = "";
|
||||
content = ASPFactory.generateASP(this.getPairs(), this.getFC(), ClassLoader.getSystemClassLoader());
|
||||
|
||||
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
||||
writer.println(content);
|
||||
writer.close();
|
||||
|
||||
Clingo clingo = new Clingo(Arrays.asList(new File(tempDirectory + "test.lp")));
|
||||
String result = clingo.runClingo();
|
||||
System.out.println(result);
|
||||
ResultSet resultSet = ASPParser.parse(result, Arrays.asList(testType));
|
||||
RefTypeOrTPHOrWildcardOrGeneric resolvedType = resultSet.resolveType(testType).resolvedType;
|
||||
assert resolvedType.toString().equals(ASTFactory.createObjectType().toString());
|
||||
}
|
||||
|
||||
public Collection<ClassOrInterface> getFC() {
|
||||
Set<ClassOrInterface> ret = new HashSet<>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ConstraintSet<Pair> getPairs() {
|
||||
ConstraintSet<Pair> ret = new ConstraintSet<>();
|
||||
ret.addUndConstraint(new Pair(testType, ASTFactory.createObjectType(), PairOperator.EQUALSDOT));
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package asp;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.sat.asp.Clingo;
|
||||
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
|
||||
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Ref;
|
||||
import java.util.*;
|
||||
|
||||
public class UnifyWithoutWildcards {
|
||||
|
||||
public static final String tempDirectory = "/tmp/";
|
||||
|
||||
@Test
|
||||
public void adapt() throws InterruptedException, IOException, ClassNotFoundException {
|
||||
ConstraintSet<Pair> testSet = new ConstraintSet<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(TypePlaceholder.fresh(new NullToken()));
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(TypePlaceholder.fresh(new NullToken()),TypePlaceholder.fresh(new NullToken()));
|
||||
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
|
||||
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
|
||||
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
||||
ResultSet resultSet = run(testSet);
|
||||
System.out.println(ResultSetPrinter.print(resultSet));
|
||||
assert resultSet.results.size() > 0;
|
||||
}
|
||||
|
||||
public ResultSet run(ConstraintSet<Pair> toTest) throws IOException, InterruptedException, ClassNotFoundException {
|
||||
String content = "";
|
||||
content = ASPFactory.generateASP(toTest, this.getFC(), ClassLoader.getSystemClassLoader());
|
||||
|
||||
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
||||
writer.println(content);
|
||||
writer.close();
|
||||
Clingo clingo = new Clingo(Arrays.asList(new File(tempDirectory + "test.lp")));
|
||||
String result = clingo.runClingo();
|
||||
ResultSet resultSet = ASPParser.parse(result, getInvolvedTPHS(toTest));
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private static class TPHExtractor implements TypeVisitor<List<TypePlaceholder>>{
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(RefType refType) {
|
||||
ArrayList<TypePlaceholder> ret = new ArrayList<>();
|
||||
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
|
||||
ret.addAll(param.acceptTV(this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(SuperWildcardType superWildcardType) {
|
||||
return superWildcardType.getInnerType().acceptTV(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(TypePlaceholder typePlaceholder) {
|
||||
return Arrays.asList(typePlaceholder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(ExtendsWildcardType extendsWildcardType) {
|
||||
return extendsWildcardType.getInnerType().acceptTV(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypePlaceholder> visit(GenericRefType genericRefType) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
protected Collection<TypePlaceholder> getInvolvedTPHS(ConstraintSet<Pair> toTest) {
|
||||
List<TypePlaceholder> ret = new ArrayList<>();
|
||||
toTest.map((Pair p)-> {
|
||||
ret.addAll(p.TA1.acceptTV(new TPHExtractor()));
|
||||
ret.addAll(p.TA2.acceptTV(new TPHExtractor()));
|
||||
return p;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Collection<ClassOrInterface> getFC() {
|
||||
Set<ClassOrInterface> ret = new HashSet<>();
|
||||
ret.add(ASTFactory.createClass(Matrix.class));
|
||||
//ret.add(ASTFactory.createObjectClass());
|
||||
//ret.add(ASTFactory.createClass(java.util.List.class));
|
||||
return ret;
|
||||
}
|
||||
private class Matrix<A> extends HashMap<A,Map<Integer, A>>{}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package asp.gencay;
|
||||
|
||||
import asp.UnifyWithoutWildcards;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.sat.asp.Clingo;
|
||||
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
|
||||
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
|
||||
import de.dhbwstuttgart.sat.asp.writer.ASPGencayFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
public class GeneratorTest extends UnifyWithoutWildcards{
|
||||
@Test
|
||||
public void simple() throws ClassNotFoundException {
|
||||
ConstraintSet<Pair> testSet = new ConstraintSet<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(TypePlaceholder.fresh(new NullToken()));
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(TypePlaceholder.fresh(new NullToken()));
|
||||
RefType t1 = new RefType(new JavaClassName("java.util.List"), list1, new NullToken());
|
||||
RefType t2 = new RefType(new JavaClassName("java.util.List"), list2, new NullToken());
|
||||
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
||||
String resultSet = ASPGencayFactory.generateASP(testSet,
|
||||
new HashSet<>(Arrays.asList(ASTFactory.createClass(List.class))), ClassLoader.getSystemClassLoader());
|
||||
System.out.println(resultSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matrix() throws ClassNotFoundException {
|
||||
ConstraintSet<Pair> testSet = new ConstraintSet<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(TypePlaceholder.fresh(new NullToken()));
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(TypePlaceholder.fresh(new NullToken()),TypePlaceholder.fresh(new NullToken()));
|
||||
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
|
||||
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
|
||||
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
|
||||
String resultSet = ASPGencayFactory.generateASP(testSet, this.getFC(), ClassLoader.getSystemClassLoader());
|
||||
System.out.println(resultSet);
|
||||
}
|
||||
|
||||
private Collection<ClassOrInterface> getFC() {
|
||||
Set<ClassOrInterface> ret = new HashSet<>();
|
||||
ret.add(ASTFactory.createClass(Matrix.class));
|
||||
//ret.add(ASTFactory.createObjectClass());
|
||||
//ret.add(ASTFactory.createClass(java.util.List.class));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {}
|
@ -1,70 +0,0 @@
|
||||
package asp.typeinference;
|
||||
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ASPTest {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/";
|
||||
private static final List<File> filesToTest = new ArrayList<>();
|
||||
protected File fileToTest = null;
|
||||
|
||||
public ASPTest(){
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, ClassNotFoundException {
|
||||
if(fileToTest != null)filesToTest.add(fileToTest);
|
||||
else return;
|
||||
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"EmptyMethod.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"fc.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Vector.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Generics.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Import.jav"));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||
Set<ClassOrInterface> allClasses = new HashSet<>();
|
||||
for(SourceFile sf : compiler.sourceFiles.values()) {
|
||||
allClasses.addAll(compiler.getAvailableClasses(sf));
|
||||
}
|
||||
for(SourceFile sf : compiler.sourceFiles.values()) {
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
|
||||
final ConstraintSet<Pair> cons = compiler.getConstraints();
|
||||
String asp = ASPFactory.generateASP(cons, allClasses, ClassLoader.getSystemClassLoader());
|
||||
System.out.println(asp);
|
||||
}
|
||||
|
||||
static String readFile(String path, Charset encoding)
|
||||
throws IOException
|
||||
{
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return new String(encoded, encoding);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package asp.typeinference;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class GenericsTest extends ASPTest {
|
||||
public GenericsTest() {
|
||||
this.fileToTest = new File(rootDirectory+"Generics.jav");
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package asp.typeinference;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class VectorTest extends ASPTest {
|
||||
public VectorTest() {
|
||||
this.fileToTest = new File(rootDirectory+"Vector.jav");
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package asp.unifywithoutwildcards;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ASPTests {
|
||||
@Test
|
||||
public void test(){
|
||||
|
||||
}
|
||||
}
|
68
src/test/java/constraintSimplify/FamilyOfGenerics.java
Normal file
@ -0,0 +1,68 @@
|
||||
package constraintSimplify;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder;
|
||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FamilyOfGenerics {
|
||||
|
||||
@Test
|
||||
public void generateBC() throws Exception {
|
||||
SourceFile sf = generateAST();
|
||||
PositionFinder.getPositionOfTPH(sf, null);
|
||||
TPHExtractor tphExtractor = new TPHExtractor();
|
||||
List<ResultSet> results = new ArrayList<ResultSet>();
|
||||
GeneratedGenericsFinder generatedGenericsFinder = new GeneratedGenericsFinder(sf, results);
|
||||
}
|
||||
|
||||
public static SourceFile generateAST(){
|
||||
ArrayList<ClassOrInterface> classes = new ArrayList<>();
|
||||
ArrayList<Field> fields = new ArrayList<>();
|
||||
ArrayList<Method> methods = new ArrayList<>();
|
||||
|
||||
fields.add(generateField("fld1"));
|
||||
String[] paramNames = {"a"};
|
||||
methods.add(generateMethod("testMethode", paramNames));
|
||||
|
||||
classes.add(new ClassOrInterface(Modifier.PUBLIC, new JavaClassName("Test"), fields, Optional.empty(), methods,
|
||||
new ArrayList<>(), generateEmptyGenericDeclList(),
|
||||
new RefType(new JavaClassName("java.lang.Object"), new NullToken()),
|
||||
false, new ArrayList<>(), new NullToken()));
|
||||
|
||||
return new SourceFile("Test.jav", classes, new HashSet<>());
|
||||
}
|
||||
|
||||
public static Method generateMethod(String methodName, String[] paramNames){
|
||||
ArrayList<FormalParameter> parameters = new ArrayList<>();
|
||||
for(String str: paramNames) {
|
||||
FormalParameter fp = new FormalParameter(str, TypePlaceholder.fresh(new NullToken()), new NullToken());
|
||||
parameters.add(fp);
|
||||
|
||||
}
|
||||
ParameterList parameterList = new ParameterList(parameters, new NullToken());
|
||||
return new Method(Modifier.PUBLIC, methodName, TypePlaceholder.fresh(new NullToken()), parameterList,
|
||||
new Block(new ArrayList<>(), new NullToken()), generateEmptyGenericDeclList(), new NullToken());
|
||||
}
|
||||
|
||||
public static GenericDeclarationList generateEmptyGenericDeclList(){
|
||||
return new GenericDeclarationList(new ArrayList<>(), new NullToken());
|
||||
}
|
||||
|
||||
public static Field generateField(String fieldName) {
|
||||
return new Field(fieldName, TypePlaceholder.fresh(new NullToken()), Modifier.PUBLIC, new NullToken());
|
||||
}
|
||||
}
|
206
src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java
Normal file
@ -0,0 +1,206 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.*;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||
|
||||
public void testIdentityMethod(){
|
||||
/*
|
||||
Example method:
|
||||
A id(B i) return i;
|
||||
gives constraint: B <. A, which is a method constraint
|
||||
*/
|
||||
|
||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||
inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
||||
PairTphMethod<PositionFinder.Position, String> meth1 = new PairTphMethod<PositionFinder.Position, String>(PositionFinder.Position.METHOD, "m1");
|
||||
tphPositions.put("A", meth1);
|
||||
tphPositions.put("B", meth1);
|
||||
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
assertTrue(classConstraints.isEmpty());
|
||||
|
||||
/*
|
||||
MethodConstraints should be the same as the input constraint
|
||||
*/
|
||||
List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, tphPositions);
|
||||
assertTrue(methodConstraints.size() == 1);
|
||||
assertTrue(methodConstraints.get(0).getLeft().equals("B"));
|
||||
assertTrue(methodConstraints.get(0).getRight().equals("A"));
|
||||
}
|
||||
|
||||
public void testClassField(){
|
||||
/*
|
||||
class Example{
|
||||
A f;
|
||||
B fReturn(){
|
||||
return f;
|
||||
}
|
||||
}
|
||||
gives constraint: A <. B, which is a class constraint
|
||||
*/
|
||||
|
||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
||||
PairTphMethod<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
|
||||
tphPositions.put("A", posOfA);
|
||||
PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn");
|
||||
tphPositions.put("B", posOfB);
|
||||
|
||||
/*
|
||||
ClassConstraints should not be the same as the input constraint
|
||||
*/
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
System.out.println(classConstraints);
|
||||
assertTrue(classConstraints.size() == 2);
|
||||
//assertTrue(classConstraints.get(0).getLeft().equals("A"));
|
||||
//assertTrue(classConstraints.get(0).getRight().equals("B"));
|
||||
}
|
||||
|
||||
public void testSecondLineOfClassConstraints() {
|
||||
/*
|
||||
class Example() {
|
||||
A a;
|
||||
B b = a;
|
||||
C anyMethod() {
|
||||
F f;
|
||||
return f;
|
||||
}
|
||||
D otherMethod(E e) {
|
||||
this.b = e;
|
||||
e = this.a;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("F", "C", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("E", "B", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("A", "E", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("E", "D", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
||||
PairTphMethod<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
|
||||
PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
|
||||
PairTphMethod<PositionFinder.Position, String> posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "anyMethod");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "otherMethod");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfF = new PairTphMethod<>(PositionFinder.Position.METHOD, "anyMethod");
|
||||
|
||||
tphPositions.put("A", posOfA);
|
||||
tphPositions.put("B", posOfB);
|
||||
tphPositions.put("C", posOfC);
|
||||
tphPositions.put("F", posOfF);
|
||||
tphPositions.put("D", posOfD);
|
||||
tphPositions.put("E", posOfE);
|
||||
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
System.out.println(classConstraints);
|
||||
assertFalse(classConstraints.isEmpty());
|
||||
assertTrue(classConstraints.size() == 6);
|
||||
|
||||
}
|
||||
|
||||
public void testTPHsAndGenerics() {
|
||||
/*
|
||||
class TPHsAndGenerics {
|
||||
Fun1<A,B> id = x -> x;
|
||||
C id2 (D x) {
|
||||
return id.apply(x);
|
||||
}
|
||||
E m(F a, G b){
|
||||
var c = m2(a,b);
|
||||
return a;
|
||||
}
|
||||
H m2(I a, J b){
|
||||
return b;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
List<TPHConstraint> inputConstraints = new ArrayList<>();
|
||||
inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("B","C", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("D","A", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("F","E", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("F","I", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("G","J", TPHConstraint.Relation.EXTENDS));
|
||||
inputConstraints.add(new TPHConstraint("J","H", TPHConstraint.Relation.EXTENDS));
|
||||
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> tphPositions = new HashMap<>();
|
||||
PairTphMethod<PositionFinder.Position, String> posOfA = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
|
||||
PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.FIELD, null);
|
||||
PairTphMethod<PositionFinder.Position, String> posOfC = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfD = new PairTphMethod<>(PositionFinder.Position.METHOD, "id2");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfE = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfF = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfG = new PairTphMethod<>(PositionFinder.Position.METHOD, "m");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfH = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfI = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2");
|
||||
PairTphMethod<PositionFinder.Position, String> posOfJ = new PairTphMethod<>(PositionFinder.Position.METHOD, "m2");
|
||||
|
||||
tphPositions.put("A", posOfA);
|
||||
tphPositions.put("B", posOfB);
|
||||
tphPositions.put("C", posOfC);
|
||||
tphPositions.put("D", posOfD);
|
||||
tphPositions.put("E", posOfE);
|
||||
tphPositions.put("F", posOfF);
|
||||
tphPositions.put("G", posOfG);
|
||||
tphPositions.put("H", posOfH);
|
||||
tphPositions.put("I", posOfI);
|
||||
tphPositions.put("J", posOfJ);
|
||||
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
System.out.println(classConstraints);
|
||||
|
||||
assertFalse(classConstraints.isEmpty());
|
||||
assertTrue(classConstraints.size() == 3);
|
||||
}
|
||||
|
||||
|
||||
public void testPositionConverter() {
|
||||
HashMap<String, Boolean> allTphsOld = new HashMap<>();
|
||||
List<MethodAndTPH> listOfMethodsAndTphs = new ArrayList<>();
|
||||
allTphsOld.put("A", true);
|
||||
allTphsOld.put("B", false);
|
||||
MethodAndTPH m1 = new MethodAndTPH("m1");
|
||||
m1.getTphs().add("A");
|
||||
MethodAndTPH bla = new MethodAndTPH("bla");
|
||||
MethodAndTPH blubb = new MethodAndTPH("blubb");
|
||||
// blubb.getTphs().add("A");
|
||||
listOfMethodsAndTphs.add(bla);
|
||||
listOfMethodsAndTphs.add(blubb);
|
||||
listOfMethodsAndTphs.add(m1);
|
||||
|
||||
|
||||
|
||||
HashMap<String, PairTphMethod<PositionFinder.Position, String>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs);
|
||||
System.out.println(allTphsNew);
|
||||
//was tun wenn zwei (oder mehr) Methoden gleiches TPH enthalten?
|
||||
//ist dies möglich oder werden die TPHs immer verschieden initialisiert und dann erst am Ende gemappt?
|
||||
//überarbeiten oder lassen?
|
||||
|
||||
|
||||
assertTrue(allTphsNew.get("A").fst.equals(PositionFinder.Position.METHOD));
|
||||
assertTrue(allTphsNew.get("B").fst.equals(PositionFinder.Position.FIELD));
|
||||
}
|
||||
|
||||
|
||||
public void testFirstTransitiveSubtypeForMethodTypes(){
|
||||
|
||||
}
|
||||
|
||||
}
|
30
src/test/java/insertGenerics/MethodsTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import junit.framework.TestResult;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class MethodsTest {
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/";
|
||||
public static final String fileDirectory = rootDirectory + "TestGGFinder.jav";
|
||||
|
||||
@Test
|
||||
public void testVisit(ClassOrInterface coi) throws IOException, ClassNotFoundException {
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(new File(fileDirectory));
|
||||
SourceFile sf = compiler.sourceFiles.get(compiler.sourceFiles.keySet());
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
|
||||
GeneratedGenericsFinder ggf = new GeneratedGenericsFinder(sf, results);
|
||||
ClassOrInterface coiHere = coi;
|
||||
ggf.visit(coiHere);
|
||||
//assert results.size()>0;
|
||||
}
|
||||
}
|
56
src/test/java/insertGenerics/TestExample42.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.PositionFinder;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TestExample42 {
|
||||
public List<TPHConstraint> fillConstraintsList() {
|
||||
List<TPHConstraint> cs = new ArrayList<>();
|
||||
cs.add(new TPHConstraint("M", "N", Relation.EXTENDS));
|
||||
cs.add(new TPHConstraint("N", "Z", Relation.EXTENDS));
|
||||
cs.add(new TPHConstraint("Q", "K", Relation.EXTENDS));
|
||||
cs.add(new TPHConstraint("K", "P", Relation.EXTENDS));
|
||||
cs.add(new TPHConstraint("W", "M", Relation.EXTENDS));
|
||||
cs.add(new TPHConstraint("Z", "V", Relation.EXTENDS));
|
||||
return cs;
|
||||
}
|
||||
|
||||
public HashMap<String, PositionFinder.Position> fillPosOfTphs() {
|
||||
BufferedReader l;
|
||||
HashMap<String, PositionFinder.Position> posOfTphs = new HashMap<>();
|
||||
posOfTphs.put("K", PositionFinder.Position.FIELD);
|
||||
posOfTphs.put("L", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("M", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("N", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("P", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("Q", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("U", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("V", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("W", PositionFinder.Position.METHOD);
|
||||
posOfTphs.put("Z", PositionFinder.Position.METHOD);
|
||||
return posOfTphs;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void genericTest() {
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs());
|
||||
System.out.println("ClassConstraints: " + classConstraints);
|
||||
List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),fillPosOfTphs());
|
||||
System.out.println("MethodConstraints: " + methodConstraints);
|
||||
|
||||
List<TPHConstraint> testCons;
|
||||
}
|
||||
}
|
||||
*/
|
28
src/test/java/insertGenerics/TestTransitiveClosure.java
Normal file
@ -0,0 +1,28 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestTransitiveClosure {
|
||||
public List<TPHConstraint> fillList() {
|
||||
List<TPHConstraint> list = new ArrayList<>();
|
||||
list.add(new TPHConstraint("A", "B", Relation.EXTENDS));
|
||||
list.add(new TPHConstraint("B", "C", Relation.EXTENDS));
|
||||
list.add(new TPHConstraint("C", "D", Relation.EXTENDS));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void genericTest() {
|
||||
List<TPHConstraint> testCons = FamilyOfGeneratedGenerics.buildTransitiveClosure(fillList());
|
||||
System.out.println(testCons);
|
||||
|
||||
}
|
||||
}
|
92
src/test/java/insertGenerics/TryTest.java
Normal file
@ -0,0 +1,92 @@
|
||||
package insertGenerics;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TryTest {
|
||||
|
||||
public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/";
|
||||
|
||||
@Test
|
||||
public void ggFinder() throws IOException, ClassNotFoundException {
|
||||
execute(new File(rootDirectory+"TestGGFinder.jav"));
|
||||
}
|
||||
|
||||
private static class TestResultSet{
|
||||
|
||||
}
|
||||
|
||||
public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException {
|
||||
//filesToTest.add(new File(rootDirectory+"fc.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Vector.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Generics.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Import.jav"));
|
||||
// //filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
||||
// //filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||
// //filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
// System.out.println(ASTTypePrinter.print(sf));
|
||||
// System.out.println("---------------------------1");
|
||||
// System.out.println(ASTPrinter.print(sf));
|
||||
// System.out.println("---------------------------2");
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
//compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles);
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
System.out.println(ASTTypePrinter.print(sf));
|
||||
// System.out.println("---------------------------3");
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
// System.out.println("---------------------------4");
|
||||
//List<ResultSet> results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
insertedTypes.add(tip.insert(content));
|
||||
}
|
||||
}
|
||||
for(String s : insertedTypes){
|
||||
System.out.println("---------------------------51");
|
||||
System.out.println(s);
|
||||
System.out.println("---------------------------52");
|
||||
}
|
||||
}
|
||||
return new TestResultSet();
|
||||
}
|
||||
|
||||
static String readFile(String path, Charset encoding)
|
||||
throws IOException
|
||||
{
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return new String(encoded, encoding);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -137,7 +138,8 @@ public class JavaTXCompilerTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
//compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles);
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
System.out.println(ASTTypePrinter.print(sf));
|
||||
@ -146,7 +148,7 @@ public class JavaTXCompilerTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -105,6 +106,7 @@ public class Meth_GenTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
@ -114,7 +116,7 @@ public class Meth_GenTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|
@ -1,5 +1,6 @@
|
||||
package typeinference;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||
@ -131,6 +132,7 @@ public class UnifyTest {
|
||||
System.out.println(ASTPrinter.print(sf));
|
||||
}
|
||||
List<ResultSet> results = compiler.typeInference();
|
||||
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
|
||||
|
||||
for(File f : compiler.sourceFiles.keySet()){
|
||||
SourceFile sf = compiler.sourceFiles.get(f);
|
||||
@ -140,7 +142,7 @@ public class UnifyTest {
|
||||
assert results.size()>0;
|
||||
Set<String> insertedTypes = new HashSet<>();
|
||||
for(ResultSet resultSet : results){
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results);
|
||||
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles);
|
||||
assert result.size()>0;
|
||||
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
|
||||
for(TypeInsert tip : result){
|
||||
|