Compare commits
30 Commits
plugin
...
strucTypes
Author | SHA1 | Date | |
---|---|---|---|
23786184ad | |||
55f6fe47ac | |||
4919dd34b2 | |||
aac113e12e | |||
e9d5d5f7c7 | |||
092ee53f74 | |||
413cb48a96 | |||
24f93f0bcb | |||
f44f08b895 | |||
e972282620 | |||
f7160c10f4 | |||
7a5940ac65 | |||
86e94b8cc0 | |||
25a5e79509 | |||
7e1d6fad01 | |||
c7e0281d53 | |||
23ae5d5745 | |||
427a87598c | |||
403430d0c4 | |||
d9ab487253 | |||
6f85c2b376 | |||
a17342458e | |||
ab46709390 | |||
48e22982c8 | |||
3ed300268f | |||
ebacb72dcb | |||
663ce36e22 | |||
ce2b4e0303 | |||
52dd0e6276 | |||
f29faa2680 |
README.md
doc
pom.xmlsrc
build_compiler.sh
de
dhbwstuttgart
.DS_Store
bytecode
AStatement.javaArgumentExpr.javaAssignStmt.javaBytecodeGen.javaBytecodeGenMethod.javaIStatement.javaLoopStmt.javaReturnStmt.java
descriptor
signature
utilities
core
environment
exceptions
parser
JavaTXParser.javaNullToken.java
SyntaxTreeGenerator
AssignToLocal.javaFCGenerator.javaGenericContext.javaStatementGenerator.javaSyntacticSugar.javaSyntaxTreeGenerator.javaTypeGenerator.java
TODOantlr
Java8.g4Java8.tokensJava8BaseListener.javaJava8Lexer.javaJava8Lexer.tokensJava8Listener.javaJava8Parser.java
notes
parse_treescope
sat
CNF
asp
strucTypes
Construct.javaRuleSetStrucType.javaSolve.javaStrucTYPE.javaStrucTypeUnify.javaStrucTypeUnifyUtils.java
constraint
diagram
exception
IllegalInterfaceTypeException.javaImpossibleSubTypeException.javaInconsistentConstraintsException.java
model
printutils
visitor
syntaxtree
ASTVisitor.javaAbstractASTWalker.javaClassOrInterface.javaConstructor.javaExceptionList.javaField.javaFieldDeclaration.javaFormalParameter.javaGenericDeclarationList.javaGenericTypeVar.javaMethod.javaParameterList.javaSourceFile.javaStatementVisitor.javaSyntaxTreeNode.javaTypeScope.java
factory
statement
ArgumentList.javaAssign.javaAssignLeftSide.javaAssignToField.javaBinaryExpr.javaBlock.javaCastExpr.javaDoStmt.javaEmptyStmt.javaExpression.javaExpressionReceiver.javaFieldVar.javaForStmt.javaIfStmt.javaInstanceOf.javaJavaInternalExpression.javaLambdaExpression.javaLiteral.javaLocalVar.javaLocalVarDecl.javaMethodCall.javaNewArray.javaNewClass.javaReceiver.javaReturn.javaReturnVoid.javaStatement.javaStaticClassName.javaSuper.javaSuperCall.javaThis.javaThisCall.javaTypableStatement.javaUnaryExpr.javaWhileStmt.java
type
ExtendsWildcardType.javaFunN.javaGenericRefType.javaRefType.javaRefTypeOrTPHOrWildcardOrGeneric.javaSuperWildcardType.javaTypePlaceholder.javaTypeVisitor.javaVoid.javaWildcardType.java
visual
typedeployment
typeinference
assumptions
Assumption.javaFieldAssumption.javaFunNClass.javaMethodAssumption.javaTypeInferenceBlockInformation.javaTypeInferenceInformation.javaTypeScopeContainer.java
constraints
result
GenericInsertPair.javaPairTPHEqualTPH.javaPairTPHequalRefTypeOrWildcardType.javaPairTPHsmallerTPH.javaResolvedType.javaResultPair.javaResultPairVisitor.javaResultSet.javaResultSetVisitor.java
typeAlgo
unify
GuavaSetOperations.javaMartelliMontanariUnify.javaMatch.javaRuleSet.javaTypeUnify.javaTypeUnifyTask.javaUnifikationsalgorithmus.javadistributeVariance.javafreshPlaceholder.java
interfaces
model
ExtendsType.javaFiniteClosure.javaFunNType.javaNode.javaOrderingUnifyPair.javaPair.javaPairOperator.javaPlaceholderType.javaReferenceType.javaSuperType.javaTypeParams.javaUnifier.javaUnifyPair.javaUnifyType.javaWildcardType.java
visitUnifyTypeVisitor.javamain
antlr4
java
de
dhbwstuttgart
bytecode
core
syntaxtree
typeinference
test
java
bytecode
BinaryTest.javaFacultyTest.javaFieldTph2Test.javaFieldTphConsMethTest.javaFieldTphMMethTest.javaFunOLTest.javaGenTest.javaLambdaCapturetest.javaLambdaTest.javaLambdaVoidTest.javaMatrixOpTest.javaMatrixTest.javaMergeTest.javaOLTest.javaOverloadingSortingTest.javaSortingTest.javaSubMatTest.javaTph2Test.javaTph3Test.javaTph5Test.javaTph6Test.javaTphTest.javaYTest.javaapplyLambdaTest.java
simplifyalgo
resources
target
test
asp
astfactory
bytecode
BinaryTest.javaFacTest.javaGenTest.javaGreaterEqualTest.javaGreaterThanTest.javaLambdaTest.javaLessEqualTest.javaLessThanTest.javaMatrixTest.javaOLTest.javaOpTest.javaOverloadingTest.javaPlusTest.javaPostIncTest.javaPreIncTest.javaRelOpsTest.javaStaticTest.javaWhileTest.java
javFiles
AssignToLit.javBinaryInMeth.javDuMethod.javEmptyMethod.javExample.javExceptions.javFac.javFaculty.javFaculty2.javFor.javGen.javGenerics.javGenerics2.javGreaterEqual.javGreaterThan.javIfTest.javImport.javInterface1.javLamRunnable.javLambda.javLambda2.javLambda3.javLambda4.javLessEqual.javLessThan.javMatrix.javMethods.javOL.javOp.javOp2.javOverlaodGen.javOverloading.javPlus.javPostIncDec.javPreInc.javRecursiveMeth.javRelOps.javReturnMethod.javStaticM.javVoidMeth.javWhile.jav
finiteClosure
javFiles
AddLong.javEmptyClass.javEmptyMethod.javExpressions.javFC_Matrix.javFaculty.javFacultyTyped.javGenerics.javImport.javLambda.javLambda2.javLambda3.javLambdaField.javLambdaRunnable.javMatrix.javMeth_Gen.javMethodCallGenerics.javMethods.javMethodsEasy.javOp1.javPackage.javSubclass.javSuperclass.javVector.javfc.javmathStruc.javtest.javtest1.jav
log4jTesting.xmlparser
AntlrTest.javBoundedParameter.javCastTest.javExtendsTest.javFeatherWeightJava.javFieldInitializationTest.javFieldVarTest.javGeneralParserTest.javaGenericFieldVarTest.javImportTest.javImportTest2.javImportTestGeneric.javNewTest.javOpratorTest.javPackageNameTest.javStatementsTest.javStructuralTypes.javWhileTest.jav
strucType
TestASTPrinter.javaTestConstruct.javaTestInferTypesVisitor.javaTestInterface.javaTestPaperExample.javaTestRuleSetStrucType.javaTestSolve.javaTestStrucType.javaTestStrucTypeUnifyUtils.javaTestSyntaxTreePrinter.java
constructed
javFiles
testCast.javtestFieldMethod.javtestFieldVar.javtestInterface.javtestLocalVar.javtestMain.javtestMethod.javtestNew.javtestPaperExample.jav
typedtestclasses
typeinference
visualisation
testBytecode
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
|
||||
# plugin site erstellen
|
||||
* die JAvaTXCOmpiler DAtei in ein plugin umwandeln und deployen.
|
||||
* siehe: http://www.vogella.com/tutorials/EclipseJarToPlugin/article.html#convert-jar-files-to-osgi-bundles-with-the-p2-maven-plugin
|
||||
* AUsführung:
|
||||
* mvn deploy #erstellt die JAR-Datei und steckt sie in ein lokales Repo (maven-repository)
|
||||
* mvn p2:site
|
||||
* mvn package # hier wird die ZIP-Filf zum Einbinden in Eclipse erstellt
|
||||
|
||||
# Einbinden in Eclipse
|
||||
* In Eclipse kann die Zip-FIle wie ein Plugin installiert werden
|
||||
* Hier tritt FEhler auf. Reflections-Library kann nicht installiert werden. Möglicherweise wird sie auch nicht gebraucht
|
||||
* Nach dem installieren de.dhbwstuttagrt.JavaTXcompiler zu den DEpendencies des plugins hinzufügen
|
||||
* Anschließend unter "Overview" auf "Updata Classpath" klicken
|
||||
|
||||
# Windows
|
||||
* JAVA_HOME setzen:
|
||||
* export JAVA_HOME=/c/Program\ Files/Java/jdk1.8.0_102/
|
Binary file not shown.
BIN
doc/Studienarbeiten/S2018_Marcel_Vollmer_Implementierung eines Typinferenzalgorithmus für Strukturelle Typen.pdf
Normal file
BIN
doc/Studienarbeiten/S2018_Marcel_Vollmer_Implementierung eines Typinferenzalgorithmus für Strukturelle Typen.pdf
Normal file
Binary file not shown.
@ -1,24 +0,0 @@
|
||||
# Dateien
|
||||
* sämtliche Datein im Ordner de.dhbwstuttgart.parser gehören zum Parser
|
||||
* Auch zu beachten: pom.xml
|
||||
* Ein Teil der pom.xml instruiert maven zur Kompilierung der Java8.g4 Datei
|
||||
* VORSICHT! Wird nicht zwangsläufig von der IDE ausgeführt
|
||||
* siehe Kapitel "Grammatik -> Parser"
|
||||
|
||||
|
||||
## Unterordner antlr
|
||||
* Java8.g4
|
||||
* die eigentliche Java Grammatik
|
||||
* hier wurden Anpassungen vorgenommen, damit sie auch typloses Java annimmt
|
||||
* alle anderen Dateien in diesem Ordner sind vom ANTLR-Parsergenerator autogeneriert
|
||||
|
||||
## Unterordner SyntaxTreeGenerator
|
||||
* SyntaxTreeGenerator
|
||||
* TODO
|
||||
|
||||
# Grammatik -> Parser
|
||||
* Die Antlr-Grammatik (Java8.g4) wandelt
|
||||
* Folgende Stellen sind relevant
|
||||
* TODO
|
||||
|
||||
|
348
pom.xml
348
pom.xml
@ -1,175 +1,181 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaTXcompiler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.dhbwstuttgart</groupId>
|
||||
<artifactId>JavaTXcompiler</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<version>0.1</version>
|
||||
<name>JavaTXcompiler</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4</artifactId>
|
||||
<version>4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>22.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-all</artifactId>
|
||||
<version>[4.0.0,)</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.bitbucket.mstrobel</groupId>
|
||||
<artifactId>procyon-reflection</artifactId>
|
||||
<version>[0.5.32,)</version>
|
||||
</dependency> -->
|
||||
</dependencies>
|
||||
|
||||
<version>0.1</version>
|
||||
<name>JavaTXcompiler</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4</artifactId>
|
||||
<version>4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>22.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.11</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>7.0</version>
|
||||
</dependency>
|
||||
<!-- <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm-all</artifactId>
|
||||
<version>[4.0.0,)</version> </dependency> -->
|
||||
<!-- <dependency> <groupId>org.bitbucket.mstrobel</groupId> <artifactId>procyon-reflection</artifactId>
|
||||
<version>[0.5.32,)</version> </dependency> -->
|
||||
</dependencies>
|
||||
<build>
|
||||
<directory>target</directory>
|
||||
<outputDirectory>target/classes</outputDirectory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
||||
<sourceDirectory>src/</sourceDirectory>
|
||||
<testSourceDirectory>test/</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-maven-plugin</artifactId>
|
||||
<version>4.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>antlr</id>
|
||||
<goals>
|
||||
<goal>antlr4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/de/dhbwstuttgart/parser/antlr/</sourceDirectory>
|
||||
<outputDirectory>src/de/dhbwstuttgart/parser/antlr/</outputDirectory>
|
||||
<arguments> <argument>-package</argument> <argument>de.dhbwstuttgart.parser.antlr</argument> </arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>aspParser</id>
|
||||
<goals>
|
||||
<goal>antlr4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/de/dhbwstuttgart/sat/asp/parser/antlr/</sourceDirectory>
|
||||
<outputDirectory>src/de/dhbwstuttgart/sat/asp/parser/antlr/</outputDirectory>
|
||||
<arguments>
|
||||
<argument>-package</argument>
|
||||
<argument>de.dhbwstuttgart.sat.asp.parser.antlr</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<build>
|
||||
<directory>target</directory>
|
||||
<outputDirectory>target/classes</outputDirectory>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M3</version>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-maven-plugin</artifactId>
|
||||
<version>4.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>antlr</id>
|
||||
<goals>
|
||||
<goal>antlr4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/main/antlr4/java8</sourceDirectory>
|
||||
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/de/dhbwstuttgart/parser/antlr</outputDirectory>
|
||||
<arguments>
|
||||
<argument>-package</argument>
|
||||
<argument>de.dhbwstuttgart.parser.antlr</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>aspParser</id>
|
||||
<goals>
|
||||
<goal>antlr4</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirectory>src/main/antlr4/sat</sourceDirectory>
|
||||
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/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>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</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.1</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>
|
||||
<url>file:///${project.basedir}/target</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<tycho.version>0.23.0</tycho.version>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-repository</id>
|
||||
<name>MyCo Internal Repository</name>
|
||||
<url>file:///${project.basedir}/maven-repository/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</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.1</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>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.tycho</groupId>
|
||||
<artifactId>tycho-p2-repository-plugin</artifactId>
|
||||
<version>${tycho.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>archive-repository</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>reficio</id>
|
||||
<url>http://repo.reficio.org/maven/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-repository</id>
|
||||
<url>file:///${project.basedir}/target</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<tycho.version>0.23.0</tycho.version>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>maven-repository</id>
|
||||
<name>MyCo Internal Repository</name>
|
||||
<url>file:///${project.basedir}/maven-repository/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
|
24
src/build_compiler.sh
Executable file
24
src/build_compiler.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# A basic script to compile the necessary packages and their subpackages to work with the parser.
|
||||
# Messages are logged to stderr.
|
||||
>&2 echo "Building de.dhbwstuttgart.typecheck..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/typecheck/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.factory..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/factory/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.operator..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/operator/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement.literal..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/literal/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.type..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/type/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.parser..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/parser/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.parser.SyntaxTreeGenerator..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/parser/SyntaxTreeGenerator/*.java
|
||||
>&2 echo "Building de.dhbwstuttgart.parser.antlr..."
|
||||
javac -d ../bin ./de/dhbwstuttgart/parser/antlr/*.java
|
||||
echo "Done. Now its your turn to debug:)."
|
BIN
src/de/dhbwstuttgart/.DS_Store
vendored
Normal file
BIN
src/de/dhbwstuttgart/.DS_Store
vendored
Normal file
Binary file not shown.
@ -2,12 +2,8 @@ package de.dhbwstuttgart.bytecode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
@ -17,18 +13,12 @@ import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||
import de.dhbwstuttgart.bytecode.descriptor.DescriptorToString;
|
||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||
import de.dhbwstuttgart.bytecode.signature.Signature;
|
||||
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
||||
import de.dhbwstuttgart.bytecode.signature.TypeToString;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||
import de.dhbwstuttgart.bytecode.utilities.NormalConstructor;
|
||||
import de.dhbwstuttgart.bytecode.utilities.NormalMethod;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Literal;
|
||||
@ -38,8 +28,6 @@ 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.GenericInsertPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResolvedType;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
@ -48,32 +36,19 @@ public class BytecodeGen implements ASTVisitor {
|
||||
ClassWriter cw =new ClassWriter(ClassWriter.COMPUTE_FRAMES|ClassWriter.COMPUTE_MAXS);
|
||||
|
||||
String type;
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric THISTYPE = null;
|
||||
|
||||
String className;
|
||||
private boolean isInterface;
|
||||
private List<ResultSet> listOfResultSets;
|
||||
private ResultSet resultSet;
|
||||
private SourceFile sf;
|
||||
private String path;
|
||||
|
||||
private Optional<Constructor> fieldInitializations;
|
||||
|
||||
private int indexOfFirstParam = 0;
|
||||
|
||||
private String superClass;
|
||||
|
||||
private ArrayList<TypePlaceholder> tphsClass;
|
||||
|
||||
// stores parameter, local vars and the next index on the local variable table, which use for aload_i, astore_i,...
|
||||
HashMap<String, Integer> paramsAndLocals = new HashMap<>();
|
||||
// stores generics and their bounds of class
|
||||
HashMap<String, String> genericsAndBounds = new HashMap<>();
|
||||
|
||||
private int constructorPos = 0;
|
||||
|
||||
private final TPHExtractor tphExtractor = new TPHExtractor();
|
||||
private final ArrayList<GenericInsertPair> commonPairs = new ArrayList<>();
|
||||
// stores generics and their bounds of method
|
||||
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
|
||||
|
||||
HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes = new HashMap<>();
|
||||
byte[] bytecode;
|
||||
@ -81,18 +56,16 @@ public class BytecodeGen implements ASTVisitor {
|
||||
|
||||
ArrayList<String> methodNameAndParamsT = new ArrayList<>();
|
||||
|
||||
public BytecodeGen(HashMap<String,byte[]> classFiles, List<ResultSet> listOfResultSets,SourceFile sf ,String path) {
|
||||
public BytecodeGen(HashMap<String,byte[]> classFiles, List<ResultSet> listOfResultSets) {
|
||||
this.classFiles = classFiles;
|
||||
this.listOfResultSets = listOfResultSets;
|
||||
this.sf = sf;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
for(ClassOrInterface cl : sourceFile.getClasses()) {
|
||||
System.out.println("in Class: " + cl.getClassName().toString());
|
||||
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets, sf, path);
|
||||
BytecodeGen classGen = new BytecodeGen(classFiles, listOfResultSets);
|
||||
cl.accept(classGen);
|
||||
classGen.writeClass(cl.getClassName().toString());
|
||||
}
|
||||
@ -117,7 +90,6 @@ public class BytecodeGen implements ASTVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
|
||||
className = classOrInterface.getClassName().toString();
|
||||
|
||||
cw.visitSource(className +".jav", null);
|
||||
@ -125,76 +97,32 @@ public class BytecodeGen implements ASTVisitor {
|
||||
isInterface = (classOrInterface.getModifiers()&512)==512;
|
||||
|
||||
int acc = isInterface?classOrInterface.getModifiers()+Opcodes.ACC_ABSTRACT:classOrInterface.getModifiers()+Opcodes.ACC_SUPER;
|
||||
String sig = null;
|
||||
/* if class has generics then creates signature
|
||||
* Signature looks like:
|
||||
* <E:Ljava/...>Superclass
|
||||
*/
|
||||
if(classOrInterface.getGenerics().iterator().hasNext()) {
|
||||
Signature signature = new Signature(classOrInterface, genericsAndBounds);
|
||||
sig = signature.toString();
|
||||
}
|
||||
// needs implemented Interfaces?
|
||||
cw.visit(Opcodes.V1_8, acc, classOrInterface.getClassName().toString()
|
||||
, sig, classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()), null);
|
||||
|
||||
fieldInitializations = classOrInterface.getfieldInitializations();
|
||||
|
||||
for(Field f : classOrInterface.getFieldDecl()) {
|
||||
f.accept(this);
|
||||
}
|
||||
// resultSet = listOfResultSets.get(0);
|
||||
boolean isConsWithNoParamsVisited = false;
|
||||
boolean isVisited = false;
|
||||
for(ResultSet rs : listOfResultSets) {
|
||||
superClass = classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor());
|
||||
resultSet = rs;
|
||||
tphExtractor.setResultSet(resultSet);
|
||||
|
||||
// Nur einmal ausführen!!
|
||||
if(!isVisited) {
|
||||
classOrInterface.accept(tphExtractor);
|
||||
|
||||
getCommonTPHS(tphExtractor);
|
||||
|
||||
tphsClass = new ArrayList<>();
|
||||
for(TypePlaceholder t : tphExtractor.allTPHS.keySet()) {
|
||||
if(!tphExtractor.allTPHS.get(t))
|
||||
tphsClass.add(t);
|
||||
}
|
||||
|
||||
String sig = null;
|
||||
/* if class has generics then creates signature
|
||||
* Signature looks like:
|
||||
* <E:Ljava/...>Superclass
|
||||
*/
|
||||
if(classOrInterface.getGenerics().iterator().hasNext() || !commonPairs.isEmpty() ||
|
||||
classOrInterface.getSuperClass().acceptTV(new TypeToSignature()).contains("<")
|
||||
|| !tphsClass.isEmpty()) {
|
||||
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraintsClass(tphExtractor,tphsClass);
|
||||
ArrayList<TPHConstraint> consClass = new ArrayList<>();
|
||||
for(TPHConstraint cons : constraints.keySet()) {
|
||||
TypePlaceholder right = null;
|
||||
for(TypePlaceholder tph : tphsClass) {
|
||||
if(cons.getLeft().equals(tph.getName())) {
|
||||
|
||||
consClass.add(cons);
|
||||
right = getTPH(cons.getRight());
|
||||
}
|
||||
}
|
||||
if(right != null) {
|
||||
tphsClass.add(right);
|
||||
removeFromMethod(right.getName());
|
||||
right = null;
|
||||
}
|
||||
}
|
||||
Signature signature = new Signature(classOrInterface, genericsAndBounds,commonPairs,tphsClass, consClass);
|
||||
sig = signature.toString();
|
||||
System.out.println("Signature: => " + sig);
|
||||
}
|
||||
|
||||
cw.visit(Opcodes.V1_8, acc, classOrInterface.getClassName().toString()
|
||||
, sig, classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()), null);
|
||||
|
||||
isVisited = true;
|
||||
}
|
||||
|
||||
for(Field f : classOrInterface.getFieldDecl()) {
|
||||
f.accept(this);
|
||||
}
|
||||
|
||||
for(Constructor c : classOrInterface.getConstructors()) {
|
||||
// if(!isConsWithNoParamsVisited) {
|
||||
if(!isConsWithNoParamsVisited)
|
||||
c.accept(this);
|
||||
// }
|
||||
|
||||
// if(!c.getParameterList().iterator().hasNext())
|
||||
// isConsWithNoParamsVisited = true;
|
||||
if(!c.getParameterList().iterator().hasNext())
|
||||
isConsWithNoParamsVisited = true;
|
||||
}
|
||||
|
||||
for(Method m : classOrInterface.getMethods()) {
|
||||
@ -205,104 +133,32 @@ public class BytecodeGen implements ASTVisitor {
|
||||
|
||||
}
|
||||
|
||||
private void removeFromMethod(String name) {
|
||||
for(MethodAndTPH m : tphExtractor.ListOfMethodsAndTph) {
|
||||
ArrayList<String> toRemove = new ArrayList<>();
|
||||
for(String tph : m.getTphs()) {
|
||||
if(tph.equals(name)) {
|
||||
toRemove.add(tph);
|
||||
}
|
||||
}
|
||||
|
||||
if(!toRemove.isEmpty()) {
|
||||
m.getTphs().removeAll(toRemove);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private TypePlaceholder getTPH(String name) {
|
||||
for(TypePlaceholder tph: tphExtractor.allTPHS.keySet()) {
|
||||
if(tph.getName().equals(name))
|
||||
return tph;
|
||||
}
|
||||
throw new NoSuchElementException("TPH "+name +" does not exist");
|
||||
}
|
||||
|
||||
private void getCommonTPHS(TPHExtractor tphExtractor) {
|
||||
// Gemeinsame TPHs
|
||||
ArrayList<TypePlaceholder> cTPHs = new ArrayList<>();
|
||||
// Alle TPHs der Felder speichern
|
||||
for(TypePlaceholder tph : tphExtractor.allTPHS.keySet()) {
|
||||
if(!tphExtractor.allTPHS.get(tph))
|
||||
cTPHs.add(tph);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
System.out.println("ResultSet: ");
|
||||
resultSet.results.forEach(a->{
|
||||
System.out.println(a.getLeft().toString() + " = " + a.getRight().toString());
|
||||
});
|
||||
System.out.println("---------------");
|
||||
|
||||
// stores generics and their bounds of method
|
||||
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
|
||||
|
||||
field.getParameterList().accept(this);
|
||||
|
||||
String methParamTypes = field.name+"%%";
|
||||
|
||||
Iterator<FormalParameter> itr = field.getParameterList().iterator();
|
||||
while(itr.hasNext()) {
|
||||
FormalParameter fp = itr.next();
|
||||
methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
||||
// methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToSignature())+";";
|
||||
}
|
||||
|
||||
if(methodNameAndParamsT.contains(methParamTypes)) {
|
||||
System.out.println("ignore - Method: "+field.name +" , paramsType: "+methParamTypes);
|
||||
return;
|
||||
}
|
||||
methodNameAndParamsT.add(methParamTypes);
|
||||
System.out.println("Method: "+field.name +" , paramsType: "+methParamTypes);
|
||||
|
||||
String desc = null;
|
||||
boolean hasGen = false;
|
||||
|
||||
for(String paramName : methodParamsAndTypes.keySet()) {
|
||||
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToSignature());
|
||||
System.out.println(typeOfParam);
|
||||
if(genericsAndBounds.containsKey(typeOfParam) ||typeOfParam.contains("$")
|
||||
|| typeOfParam.contains("<")) {
|
||||
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToDescriptor());
|
||||
if(genericsAndBounds.containsKey(typeOfParam)) {
|
||||
hasGen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String sig = null;
|
||||
if(hasGen) {
|
||||
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(field.name, tphExtractor,tphsClass);
|
||||
Signature signature = new Signature(field, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
||||
Signature signature = new Signature(field, genericsAndBounds,methodParamsAndTypes);
|
||||
sig = signature.toString();
|
||||
}
|
||||
if(field.getParameterList().iterator().hasNext())
|
||||
System.out.println(field.getParameterList().iterator().next().getType().acceptTV(new TypeToDescriptor()));
|
||||
|
||||
NormalConstructor constructor = new NormalConstructor(field,genericsAndBounds,hasGen);
|
||||
desc = constructor.accept(new DescriptorToString(resultSet));
|
||||
System.out.println("Constructor: " + field.getName() + " Sig: "+ sig + " Desc: " + desc);
|
||||
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", desc, sig, null);
|
||||
mv.visitCode();
|
||||
|
||||
Block block = fieldInitializations.get().block;
|
||||
|
||||
constructorPos += 1;
|
||||
|
||||
BytecodeGenMethod gen = new BytecodeGenMethod(className,superClass,resultSet,field, mv,paramsAndLocals,cw,
|
||||
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, sf,path, block, constructorPos);
|
||||
if(!field.getParameterList().iterator().hasNext() && !(field.block.statements.get(field.block.statements.size()-1) instanceof ReturnVoid)) {
|
||||
mv.visitCode();
|
||||
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,field, mv,paramsAndLocals,cw,
|
||||
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles);
|
||||
if(!field.getParameterList().iterator().hasNext()) {
|
||||
mv.visitInsn(Opcodes.RETURN);
|
||||
}
|
||||
mv.visitMaxs(0, 0);
|
||||
@ -314,7 +170,6 @@ public class BytecodeGen implements ASTVisitor {
|
||||
// TODO: check if the method is static => if static then the first param will be stored in pos 0
|
||||
// else it will be stored in pos 1 and this will be stored in pos 0
|
||||
String retType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
// String retType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
||||
String methParamTypes = retType+method.name+"%%";
|
||||
method.getParameterList().accept(this);
|
||||
|
||||
@ -322,7 +177,6 @@ public class BytecodeGen implements ASTVisitor {
|
||||
while(itr.hasNext()) {
|
||||
FormalParameter fp = itr.next();
|
||||
methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
||||
// methParamTypes += resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToSignature())+";";
|
||||
}
|
||||
|
||||
if(methodNameAndParamsT.contains(methParamTypes)) {
|
||||
@ -330,8 +184,6 @@ public class BytecodeGen implements ASTVisitor {
|
||||
}
|
||||
methodNameAndParamsT.add(methParamTypes);
|
||||
System.out.println("Method: "+method.name +" , paramsType: "+methParamTypes);
|
||||
// stores generics and their bounds of method
|
||||
HashMap<String, String> genericsAndBoundsMethod = new HashMap<>();
|
||||
String methDesc = null;
|
||||
|
||||
// Method getModifiers() ?
|
||||
@ -339,20 +191,19 @@ public class BytecodeGen implements ASTVisitor {
|
||||
System.out.println(acc);
|
||||
|
||||
/*Prüfe, ob die Rückgabe-Type der Methode eine Type-Variable ist*/
|
||||
boolean hasGenInParameterList = genericsAndBounds.containsKey(retType) || retType.subSequence(0, 4).equals("TPH ") ||
|
||||
resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature()).contains("<");
|
||||
boolean hasGenInParameterList = genericsAndBounds.containsKey(retType) || retType.subSequence(0, 4).equals("TPH ");
|
||||
/*Wenn die Rückgabe-Type eine Typ-variable ist, erzeuge direkt die Signature, wenn nicht,
|
||||
* prüfe, ob einer der Parameter Typ-Variable als Typ hat*/
|
||||
if(!hasGenInParameterList) {
|
||||
for(String paramName : methodParamsAndTypes.keySet()) {
|
||||
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToDescriptor());
|
||||
String sigOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToSignature());
|
||||
if(genericsAndBounds.containsKey(typeOfParam)||typeOfParam.substring(0, 4).equals("TPH ")||sigOfParam.contains("<")) {
|
||||
if(genericsAndBounds.containsKey(typeOfParam)||typeOfParam.substring(0, 4).equals("TPH ")) {
|
||||
hasGenInParameterList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Test if the return-type or any of the parameter is a parameterized type. (VP)
|
||||
//then create the descriptor with the new syntax.
|
||||
|
||||
@ -360,18 +211,15 @@ public class BytecodeGen implements ASTVisitor {
|
||||
/* method.getGenerics: <....> RT method(..)
|
||||
* */
|
||||
boolean hasGen = method.getGenerics().iterator().hasNext() || hasGenInParameterList;
|
||||
|
||||
/* if method has generics or return type is TPH, create signature */
|
||||
// zwite operand muss weggelassen werden
|
||||
if(hasGen||resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToString()).equals("TPH")) {
|
||||
System.out.println("ALL CONST: " + tphExtractor.allCons.size());
|
||||
tphExtractor.allCons.forEach(c->System.out.println(c.toString()));
|
||||
System.out.println("----------------");
|
||||
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(method.name, tphExtractor, tphsClass);
|
||||
// ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs,tphExtractor.allCons);
|
||||
Signature signature = new Signature(method, genericsAndBoundsMethod, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
||||
if(hasGen||method.getReturnType().acceptTV(new TypeToString()).equals("TPH")) {
|
||||
// resultset hier zum testen
|
||||
Signature signature = new Signature(method, genericsAndBoundsMethod, methodParamsAndTypes,resultSet);
|
||||
sig = signature.toString();
|
||||
}
|
||||
System.out.println(method.getName()+" ==> "+sig);
|
||||
// System.out.println(sig);
|
||||
NormalMethod meth = new NormalMethod(method,genericsAndBounds,genericsAndBoundsMethod,hasGen);
|
||||
methDesc = meth.accept(new DescriptorToString(resultSet));
|
||||
|
||||
@ -379,8 +227,8 @@ public class BytecodeGen implements ASTVisitor {
|
||||
MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC+acc, method.getName(), methDesc, sig, null);
|
||||
|
||||
mv.visitCode();
|
||||
BytecodeGenMethod gen = new BytecodeGenMethod(className,superClass,resultSet,method, mv,paramsAndLocals,cw,
|
||||
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles, sf,path);
|
||||
BytecodeGenMethod gen = new BytecodeGenMethod(className,resultSet,method, mv,paramsAndLocals,cw,
|
||||
genericsAndBoundsMethod,genericsAndBounds,isInterface,classFiles);
|
||||
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
@ -438,31 +286,16 @@ public class BytecodeGen implements ASTVisitor {
|
||||
// ??
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
System.out.println("In FieldVar ---");
|
||||
// cw.newField(fieldVar.receiver.toString(), fieldVar.fieldVarName.toString(), fieldVar.getType().toString());
|
||||
FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, fieldVar.fieldVarName, "L"+fieldVar.getType()+";", null, null);
|
||||
fv.visitEnd();
|
||||
}
|
||||
|
||||
// access flages?? modifiers
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
System.out.println("In Field ---");
|
||||
String des = "L";
|
||||
if(resultSet.resolveType(field.getType()).resolvedType instanceof TypePlaceholder) {
|
||||
des += Type.getInternalName(Object.class);
|
||||
} else {
|
||||
des += resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
}
|
||||
des +=";";
|
||||
System.out.println(des);
|
||||
String sig = resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToSignature());
|
||||
System.out.println(sig);
|
||||
if(sig.charAt(sig.length()-1) != (";").charAt(0)) {
|
||||
sig +=";";
|
||||
}
|
||||
cw.visitField(field.modifier, field.getName(),
|
||||
des, sig,
|
||||
null);
|
||||
FieldVisitor fv = cw.visitField(Opcodes.ACC_PRIVATE, field.getName(), "L"+field.getType().toString().replace(".", "/")+";", null, null);
|
||||
fv.visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -642,6 +475,5 @@ public class BytecodeGen implements ASTVisitor {
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -8,16 +8,9 @@ import java.lang.invoke.CallSite;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
@ -36,21 +29,15 @@ import org.objectweb.asm.signature.SignatureWriter;
|
||||
import de.dhbwstuttgart.bytecode.descriptor.DescriptorToString;
|
||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||
import de.dhbwstuttgart.bytecode.signature.Signature;
|
||||
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
||||
import de.dhbwstuttgart.bytecode.utilities.KindOfLambda;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Lambda;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodFromMethodCall;
|
||||
import de.dhbwstuttgart.bytecode.utilities.SamMethod;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
public class BytecodeGenMethod implements StatementVisitor {
|
||||
@ -63,20 +50,12 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
private ClassWriter cw;
|
||||
private ResultSet resultSet;
|
||||
private boolean isInterface;
|
||||
private HashMap<String, String> genericsAndBoundsMethod;
|
||||
HashMap<String, String> genericsAndBoundsMethod;
|
||||
private HashMap<String, String> genericsAndBounds;
|
||||
public boolean isBinaryExp = false;
|
||||
private String superClass;
|
||||
private String path;
|
||||
private SourceFile sf;
|
||||
private boolean isBinaryExp = false;
|
||||
|
||||
private IStatement statement = null;
|
||||
private boolean isReturnStmt = false;
|
||||
private boolean isParentBinary = false;
|
||||
|
||||
private boolean needDUP = false;
|
||||
|
||||
private Block blockFieldInit = null;
|
||||
private boolean isBlockFieldInitVisited = false;
|
||||
|
||||
// for tests **
|
||||
private String fieldName;
|
||||
private String fieldDesc;
|
||||
@ -85,18 +64,14 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
private boolean isRightSideALambda = false;
|
||||
private KindOfLambda kindOfLambda;
|
||||
private HashMap<String, byte[]> classFiles;
|
||||
|
||||
private int constructorPos = 0;
|
||||
|
||||
private ArrayList<RefTypeOrTPHOrWildcardOrGeneric> varsFunInterface = new ArrayList<>();;
|
||||
// generate bytecode for constructor
|
||||
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
|
||||
|
||||
public BytecodeGenMethod(String className, ResultSet resultSet, Method m, MethodVisitor mv,
|
||||
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
|
||||
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles,
|
||||
SourceFile sf,String path, Block block, int constructorPos) {
|
||||
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles) {
|
||||
|
||||
this.className = className;
|
||||
this.superClass = superClass;
|
||||
this.resultSet = resultSet;
|
||||
this.m = m;
|
||||
this.mv = mv;
|
||||
@ -106,57 +81,22 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
this.genericsAndBounds = genericsAndBounds;
|
||||
this.isInterface = isInterface;
|
||||
this.classFiles = classFiles;
|
||||
this.sf = sf;
|
||||
this.path = path;
|
||||
this.constructorPos = constructorPos;
|
||||
if(block != null)
|
||||
this.blockFieldInit = block;
|
||||
this.m.block.accept(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public BytecodeGenMethod(String className, String superClass,ResultSet resultSet, Method m, MethodVisitor mv,
|
||||
HashMap<String, Integer> paramsAndLocals, ClassWriter cw, HashMap<String, String> genericsAndBoundsMethod,
|
||||
HashMap<String, String> genericsAndBounds, boolean isInterface, HashMap<String, byte[]> classFiles, SourceFile sf,String path) {
|
||||
|
||||
this.className = className;
|
||||
this.superClass = superClass;
|
||||
this.resultSet = resultSet;
|
||||
this.m = m;
|
||||
this.mv = mv;
|
||||
this.paramsAndLocals = paramsAndLocals;
|
||||
this.cw = cw;
|
||||
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||
this.genericsAndBounds = genericsAndBounds;
|
||||
this.isInterface = isInterface;
|
||||
this.classFiles = classFiles;
|
||||
this.sf = sf;
|
||||
this.path = path;
|
||||
|
||||
if (!isInterface)
|
||||
this.m.block.accept(this);
|
||||
|
||||
}
|
||||
|
||||
public BytecodeGenMethod(LambdaExpression lambdaExpression, ArrayList<String> usedVars, ResultSet resultSet, MethodVisitor mv,
|
||||
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter, SourceFile sf) {
|
||||
public BytecodeGenMethod(LambdaExpression lambdaExpression, ResultSet resultSet, MethodVisitor mv,
|
||||
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles) {
|
||||
|
||||
this.resultSet = resultSet;
|
||||
this.mv = mv;
|
||||
this.isInterface = isInterface;
|
||||
this.classFiles = classFiles;
|
||||
this.path = path;
|
||||
this.lamCounter = lamCounter;
|
||||
this.sf = sf;
|
||||
|
||||
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
||||
int i = indexOfFirstParamLam;
|
||||
|
||||
for(String var : usedVars) {
|
||||
this.paramsAndLocals.put(var, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
while (itr.hasNext()) {
|
||||
FormalParameter fp = itr.next();
|
||||
this.paramsAndLocals.put(fp.getName(), i);
|
||||
@ -164,12 +104,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
}
|
||||
lambdaExpression.methodBody.accept(this);
|
||||
}
|
||||
|
||||
public void isBinary(boolean isBinary) {
|
||||
this.isBinaryExp =isBinary;
|
||||
}
|
||||
|
||||
public String getResolvedType(RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||
|
||||
private String getResolvedType(RefTypeOrTPHOrWildcardOrGeneric type) {
|
||||
return resultSet.resolveType(type).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
}
|
||||
|
||||
@ -177,11 +113,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
public void visit(Block block) {
|
||||
for (Statement stmt : block.getStatements()) {
|
||||
stmt.accept(this);
|
||||
if(stmt instanceof MethodCall) {
|
||||
String ret = getResolvedType(((MethodCall) stmt).getType());
|
||||
if(!ret.equals("void"))
|
||||
mv.visitInsn(Opcodes.POP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,19 +120,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
public void visit(SuperCall superCall) {
|
||||
superCall.receiver.accept(this);
|
||||
superCall.arglist.accept(this);
|
||||
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, this.superClass, superCall.name, "()V",
|
||||
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), superCall.name, "()V",
|
||||
isInterface);
|
||||
|
||||
if(blockFieldInit!=null && !isBlockFieldInitVisited) {
|
||||
isBlockFieldInitVisited =true;
|
||||
//blockFieldInit.accept(this);
|
||||
for(Statement stmt : blockFieldInit.statements) {
|
||||
if(stmt instanceof SuperCall)
|
||||
continue;
|
||||
|
||||
stmt.accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ??
|
||||
@ -209,9 +129,9 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
public void visit(LocalVar localVar) {
|
||||
// wenn String + String zuerst wird ein StringBuilder initialisiert dann
|
||||
// wird die lokale Var geladen. Sonst wird zuerst die lokale Var geladen.
|
||||
System.out.println(localVar.name);
|
||||
|
||||
mv.visitVarInsn(Opcodes.ALOAD, paramsAndLocals.get(localVar.name));
|
||||
|
||||
|
||||
if (isBinaryExp) {
|
||||
doUnboxing(getResolvedType(localVar.getType()));
|
||||
}
|
||||
@ -247,12 +167,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
doBoxing(binaryType);
|
||||
isBinaryExp = false;
|
||||
}
|
||||
|
||||
System.out.println("ASSIGN TYPE R: " + getResolvedType(assign.rightSide.getType()));
|
||||
String typeOfRightSide = getResolvedType(assign.rightSide.getType());
|
||||
if(typeOfRightSide.contains("<")) {
|
||||
mv.visitTypeInsn(Opcodes.CHECKCAST, typeOfRightSide.substring(0, typeOfRightSide.indexOf('<')));
|
||||
}
|
||||
assign.lefSide.accept(this);
|
||||
|
||||
statement = null;
|
||||
@ -260,13 +174,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(BinaryExpr binary) {
|
||||
isParentBinary = true;
|
||||
|
||||
String lexpType = getResolvedType(binary.lexpr.getType());
|
||||
String rexpType = getResolvedType(binary.rexpr.getType());
|
||||
|
||||
String largerType = getLargerType(lexpType, rexpType);
|
||||
String typeOfBinary = getResolvedType(binary.getType());
|
||||
|
||||
|
||||
if (typeOfBinary.equals(Type.getInternalName(String.class))) {
|
||||
mv.visitTypeInsn(Opcodes.NEW, Type.getInternalName(StringBuilder.class));
|
||||
mv.visitInsn(Opcodes.DUP);
|
||||
@ -275,30 +189,22 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
}
|
||||
|
||||
Label endLabel = new Label();
|
||||
// this case for while loops and If statements
|
||||
// this case for while loops
|
||||
if (statement instanceof LoopStmt)
|
||||
mv.visitLabel(endLabel);
|
||||
|
||||
if(binary.lexpr instanceof UnaryExpr)
|
||||
needDUP = true;
|
||||
|
||||
|
||||
binary.lexpr.accept(this);
|
||||
|
||||
if (!lexpType.equals(rexpType) && !lexpType.equals(largerType))
|
||||
doCast(lexpType, largerType);
|
||||
|
||||
if(binary.rexpr instanceof UnaryExpr)
|
||||
needDUP = true;
|
||||
|
||||
|
||||
binary.rexpr.accept(this);
|
||||
|
||||
isParentBinary = false;
|
||||
|
||||
|
||||
if (!lexpType.equals(rexpType) && !rexpType.equals(largerType))
|
||||
doCast(rexpType, largerType);
|
||||
|
||||
Operator op = binary.operation;
|
||||
|
||||
|
||||
switch (op) {
|
||||
case ADD:
|
||||
doVisitAddOpInsn(largerType);
|
||||
@ -324,8 +230,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
case LESSEQUAL:
|
||||
case BIGGERTHAN:
|
||||
case BIGGEREQUAL:
|
||||
case EQUAL:
|
||||
case NOTEQUAL:
|
||||
Label branchLabel = new Label();
|
||||
doVisitRelOpInsn(op, largerType, branchLabel, endLabel);
|
||||
break;
|
||||
@ -333,8 +237,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Diese Methode wird nicht mehr gebraucht, da es jetzt nicht möglich ist, dass
|
||||
* solche Fälle: Integer -> Integer (OP) Short ,... usw, nicht vorkommen!
|
||||
*/
|
||||
private String getLargerType(String lexpType, String rexpType) {
|
||||
if (lexpType.equals(Type.getInternalName(String.class))
|
||||
|| rexpType.equals(Type.getInternalName(String.class))) {
|
||||
@ -398,7 +307,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
}
|
||||
|
||||
private void doVisitRelOpInsn(Operator op, String typeOfBinary, Label branchLabel, Label endLabel) {
|
||||
System.out.println("TypeOfBinary: " + typeOfBinary);
|
||||
|
||||
switch (typeOfBinary) {
|
||||
case "java/lang/Long":
|
||||
mv.visitInsn(Opcodes.LCMP);
|
||||
@ -426,12 +335,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
case BIGGEREQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IF_ICMPLT, branchLabel);
|
||||
break;
|
||||
case EQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IF_ICMPNE, branchLabel);
|
||||
break;
|
||||
case NOTEQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IFEQ, branchLabel);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -457,12 +360,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
case BIGGEREQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IFLT, branchLabel);
|
||||
break;
|
||||
case EQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IFNE, branchLabel);
|
||||
break;
|
||||
case NOTEQUAL:
|
||||
mv.visitJumpInsn(Opcodes.IFEQ, branchLabel);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -567,19 +464,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
this.lamCounter++;
|
||||
|
||||
String typeErasure = "(";
|
||||
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
||||
while (itr.hasNext()) {
|
||||
itr.next();
|
||||
typeErasure += "L" + Type.getInternalName(Object.class) + ";";
|
||||
}
|
||||
|
||||
typeErasure += ")L" + Type.getInternalName(Object.class) + ";";
|
||||
|
||||
generateBCForFunN(lambdaExpression, typeErasure);
|
||||
|
||||
|
||||
Lambda lam = new Lambda(lambdaExpression);
|
||||
String lamDesc = lam.accept(new DescriptorToString(resultSet));
|
||||
// Call site, which, when invoked, returns an instance of the functional
|
||||
@ -595,63 +480,54 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
// Für die Parameter-Typen und Return-Typ braucht man die Bounds (für die
|
||||
// Typlöschung)
|
||||
|
||||
String typeErasure = "(";
|
||||
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
||||
while (itr.hasNext()) {
|
||||
itr.next();
|
||||
typeErasure += "L" + Type.getInternalName(Object.class) + ";";
|
||||
}
|
||||
|
||||
typeErasure += ")L" + Type.getInternalName(Object.class) + ";";
|
||||
// Type erasure
|
||||
Type arg1 = Type.getMethodType(typeErasure);
|
||||
// Type arg1 = Type.getMethodType(lamDesc);
|
||||
// real Type
|
||||
Type arg3 = Type.getMethodType(lamDesc);
|
||||
|
||||
|
||||
int staticOrSpecial = 0;
|
||||
int staticOrInstance = 0;
|
||||
int indexOfFirstParamLam = 0;
|
||||
this.kindOfLambda = new KindOfLambda(lambdaExpression);
|
||||
|
||||
if (kindOfLambda.isInstanceCapturingLambda()) {
|
||||
// if(!kindOfLambda.getArgumentList().contains(BytecodeGen.THISTYPE))
|
||||
// kindOfLambda.getArgumentList().add(0, BytecodeGen.THISTYPE);
|
||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
for(String v : kindOfLambda.getUsedVars()) {
|
||||
mv.visitVarInsn(Opcodes.ALOAD, paramsAndLocals.get(v));
|
||||
}
|
||||
staticOrSpecial = Opcodes.H_INVOKESPECIAL;
|
||||
indexOfFirstParamLam = 1;
|
||||
} else {
|
||||
staticOrSpecial = Opcodes.H_INVOKESTATIC;
|
||||
staticOrInstance = Opcodes.ACC_STATIC;
|
||||
}
|
||||
String newDesc = "(";
|
||||
int pos = 0;
|
||||
if(kindOfLambda.isHasThis()) {
|
||||
pos = 1;
|
||||
}
|
||||
|
||||
for(int i=pos;i<kindOfLambda.getArgumentList().size();i++) {
|
||||
String t = "L" + getResolvedType(kindOfLambda.getArgumentList().get(i)) + ";";
|
||||
newDesc += t;
|
||||
}
|
||||
newDesc += lamDesc.substring(1);
|
||||
|
||||
// first check if capturing lambda then invokestatic or invokespecial
|
||||
Handle arg2 = new Handle(staticOrSpecial, this.className, methodName, newDesc, false);
|
||||
Handle arg2 = new Handle(staticOrSpecial, this.className, methodName, arg3.toString(), false);
|
||||
// Descriptor of functional interface methode
|
||||
SamMethod samMethod = new SamMethod(kindOfLambda.getArgumentList(), lambdaExpression.getType());
|
||||
// Desc: (this/nothing)TargetType
|
||||
String fiMethodDesc = samMethod.accept(new DescriptorToString(resultSet));
|
||||
mv.visitInvokeDynamicInsn("apply", fiMethodDesc, bootstrap, arg1, arg2, arg3);
|
||||
if(constructorPos<2) {
|
||||
MethodVisitor mvLambdaBody = cw.visitMethod(Opcodes.ACC_PRIVATE + staticOrInstance + Opcodes.ACC_SYNTHETIC,
|
||||
methodName, newDesc, null, null);
|
||||
|
||||
ArrayList<String> usedVars = kindOfLambda.getUsedVars();
|
||||
|
||||
new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
||||
classFiles,this.path, lamCounter, sf);
|
||||
|
||||
mvLambdaBody.visitMaxs(0, 0);
|
||||
mvLambdaBody.visitEnd();
|
||||
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
|
||||
Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL);
|
||||
}
|
||||
// generateBCForFunN(lambdaExpression, typeErasure);
|
||||
|
||||
MethodVisitor mvLambdaBody = cw.visitMethod(Opcodes.ACC_PRIVATE + staticOrInstance + Opcodes.ACC_SYNTHETIC,
|
||||
methodName, arg3.toString(), null, null);
|
||||
|
||||
new BytecodeGenMethod(lambdaExpression, this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
||||
classFiles);
|
||||
|
||||
mvLambdaBody.visitMaxs(0, 0);
|
||||
mvLambdaBody.visitEnd();
|
||||
cw.visitInnerClass("java/lang/invoke/MethodHandles$Lookup", "java/lang/invoke/MethodHandles", "Lookup",
|
||||
Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL);
|
||||
|
||||
generateBCForFunN(lambdaExpression, typeErasure);
|
||||
}
|
||||
|
||||
private void generateBCForFunN(LambdaExpression lambdaExpression, String methDesc) {
|
||||
@ -672,7 +548,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
// ")"+lam.getReturn.getBounds
|
||||
Signature sig = new Signature(lambdaExpression, numberOfParams);
|
||||
String name = "Fun" + numberOfParams + "$$";
|
||||
classWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC+Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT, name, sig.toString(),
|
||||
classWriter.visit(Opcodes.V1_8, Opcodes.ACC_INTERFACE + Opcodes.ACC_ABSTRACT, name, sig.toString(),
|
||||
Type.getInternalName(Object.class), null);
|
||||
MethodVisitor mvApply = classWriter.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "apply", methDesc,
|
||||
methSig.toString(), null);
|
||||
@ -685,7 +561,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
try {
|
||||
System.out.println("generating " + name + ".class file...");
|
||||
output = new FileOutputStream(
|
||||
new File(path + name + ".class"));
|
||||
new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" + name + ".class"));
|
||||
output.write(bytecode);
|
||||
output.close();
|
||||
System.out.println(name + ".class file generated");
|
||||
@ -699,6 +575,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@ -710,24 +587,16 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
|
||||
fieldName = fieldVar.fieldVarName;
|
||||
fieldDesc = "L";
|
||||
if(resultSet.resolveType(fieldVar.getType()).resolvedType instanceof TypePlaceholder) {
|
||||
fieldDesc += Type.getInternalName(Object.class);
|
||||
} else {
|
||||
fieldDesc += resultSet.resolveType(fieldVar.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
}
|
||||
fieldDesc +=";";
|
||||
fieldDesc = "L" + getResolvedType(fieldVar.getType()) + ";";
|
||||
|
||||
fieldVar.receiver.accept(this);
|
||||
// test (if)
|
||||
if (!fieldVar.receiver.getClass().equals(StaticClassName.class)) {
|
||||
mv.visitFieldInsn(Opcodes.GETFIELD, getResolvedType(fieldVar.receiver.getType()), fieldName, fieldDesc);
|
||||
}
|
||||
|
||||
if (isBinaryExp) {
|
||||
doUnboxing(getResolvedType(fieldVar.getType()));
|
||||
}
|
||||
|
||||
// mv.visitFieldInsn(Opcodes.GETSTATIC,
|
||||
// fieldVar.receiver.getType().toString().replace(".", "/"),
|
||||
// fieldVar.fieldVarName, fieldVar.getType().toString());
|
||||
@ -741,262 +610,37 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
statement = new IfStatement(ifStmt.expr, ifStmt.then_block, ifStmt.else_block);
|
||||
isBinaryExp = statement.isExprBinary();
|
||||
ifStmt.expr.accept(this);
|
||||
statement = null;
|
||||
System.out.println("If");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
boolean parentBinary = isParentBinary;
|
||||
System.out.println("In MethodCall = " + methodCall.name);
|
||||
String receiverName = getResolvedType(methodCall.receiver.getType());
|
||||
System.out.println("Methods of " + receiverName + " ");
|
||||
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
||||
// This will be used if the class is not standard class (not in API)
|
||||
ClassLoader cLoader2;
|
||||
java.lang.reflect.Method methodRefl = null;
|
||||
String clazz = receiverName.replace("/", ".");
|
||||
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
||||
try {
|
||||
if(receiverName.contains("<")) {
|
||||
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
||||
}
|
||||
|
||||
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
||||
System.out.println("Methods of " + receiverName + " ");
|
||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
||||
|
||||
} catch (Exception e) {
|
||||
// try {
|
||||
// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
||||
// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||
// System.out.println("Methods of " + receiverName + " ");
|
||||
// for(int i = 0; i<methods.length; i++) {
|
||||
// System.out.println(methods[i]);
|
||||
// }
|
||||
// methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||
// }catch (Exception e2) {
|
||||
String superClass = "";
|
||||
// TODO: Test SubMatrix.jav
|
||||
while(true) {
|
||||
for(ClassOrInterface cl : sf.getClasses()) {
|
||||
if(receiverName.equals(cl.getClassName().toString())) {
|
||||
superClass = cl.getSuperClass().getName().toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println(superClass);
|
||||
|
||||
if(superClass.equals(""))
|
||||
break;
|
||||
|
||||
try {
|
||||
String superClazz = superClass.replace("/", ".");
|
||||
if(superClass.contains("<")) {
|
||||
superClazz = superClazz.substring(0, superClass.indexOf("<"));
|
||||
}
|
||||
java.lang.reflect.Method[] methods = cLoader.loadClass(superClazz).getMethods();
|
||||
System.out.println("Methods of " + superClass + " ");
|
||||
|
||||
for(java.lang.reflect.Method m : methods) {
|
||||
if(methodCall.name.equals(m.getName())) {
|
||||
methodRefl = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} catch (Exception e3) {
|
||||
receiverName = superClass;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
if(methodRefl == null) {
|
||||
try {
|
||||
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
||||
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||
System.out.println("Methods of " + receiverName + " ");
|
||||
for(int i = 0; i<methods.length; i++) {
|
||||
System.out.println(methods[i]);
|
||||
}
|
||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||
}
|
||||
catch (Exception e2) {
|
||||
System.out.println("");
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
|
||||
methodCall.receiver.accept(this);
|
||||
|
||||
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
||||
String mDesc = "";
|
||||
List<Boolean> argListMethCall = new LinkedList<>();
|
||||
String receiverRefl="";
|
||||
if(methodRefl == null) {
|
||||
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
|
||||
receiverName, genericsAndBoundsMethod, genericsAndBounds);
|
||||
mDesc = method.accept(new DescriptorToString(resultSet));
|
||||
methodCall.arglist.accept(this);
|
||||
} else {
|
||||
receiverRefl = methodRefl.getAnnotatedReceiverType().getType().toString();
|
||||
for(Parameter p:methodRefl.getParameters()) {
|
||||
System.out.println(p.getName() + " und is Primitive = " + p.getType().isPrimitive());
|
||||
argListMethCall.add(p.getType().isPrimitive());
|
||||
}
|
||||
System.out.println("Receiver = " + methodRefl.getAnnotatedReceiverType().getType().toString());
|
||||
mDesc = getMethodDesc(methodRefl);
|
||||
for (Expression al : methodCall.arglist.getArguments()) {
|
||||
statement = new ArgumentExpr(al);
|
||||
ArgumentVisitor argV = new ArgumentVisitor(argListMethCall,this);
|
||||
al.accept(argV);
|
||||
statement = null;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Methodcall Desc : " + mDesc);
|
||||
|
||||
|
||||
// methodCall.arglist.accept(this);
|
||||
|
||||
methodCall.arglist.accept(this);
|
||||
|
||||
MethodFromMethodCall method = new MethodFromMethodCall(methodCall.arglist, methodCall.getType(),
|
||||
genericsAndBoundsMethod, genericsAndBounds);
|
||||
String mDesc = method.accept(new DescriptorToString(resultSet));
|
||||
|
||||
// is methodCall.receiver functional Interface)?
|
||||
if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface"))) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, clazz.replace(".", "/"), methodCall.name,
|
||||
mDesc, true);
|
||||
if (varsFunInterface.contains(methodCall.receiver.getType())) {
|
||||
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, getResolvedType(methodCall.receiver.getType()), methodCall.name,
|
||||
mDesc, false);
|
||||
} else {
|
||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, clazz.replace(".", "/"), methodCall.name,
|
||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getResolvedType(methodCall.receiver.getType()), methodCall.name,
|
||||
mDesc, isInterface);
|
||||
}
|
||||
|
||||
if(methodRefl != null && !methodRefl.getReturnType().isPrimitive()) {
|
||||
if(methodRefl.getReturnType().equals(Object.class)) {
|
||||
String checkCast = getResolvedType(methodCall.getType());
|
||||
if(!checkCast.contains("TPH ")) {
|
||||
int pos = checkCast.length();
|
||||
if(checkCast.contains("<"))
|
||||
pos = checkCast.indexOf("<");
|
||||
mv.visitTypeInsn(Opcodes.CHECKCAST,checkCast.substring(0,pos));
|
||||
}
|
||||
}
|
||||
if(isBinaryExp)
|
||||
doUnboxing(getResolvedType(methodCall.getType()));
|
||||
}
|
||||
System.out.println("ISParent Binary = "+isParentBinary +" -> " + parentBinary);
|
||||
if(methodRefl == null && (parentBinary || !isReturnStmt)) {
|
||||
if(isBinaryExp)
|
||||
doUnboxing(getResolvedType(methodCall.getType()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String[] getTypes(List<Expression> arguments) {
|
||||
String[] types = new String[arguments.size()];
|
||||
for(int i = 0; i<arguments.size(); ++i) {
|
||||
String t = getResolvedType(arguments.get(i).getType());
|
||||
types[i] = t;
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* For API methods
|
||||
* @param name name of a method
|
||||
* @param i number of parameters
|
||||
* @param methods all methods of a class
|
||||
* @return the method in the class file which its name equals the given methode name
|
||||
*/
|
||||
private java.lang.reflect.Method getMethod(String name, int i, java.lang.reflect.Method[] methods) {
|
||||
for(java.lang.reflect.Method m : methods) {
|
||||
if(name.equals(m.getName()) && i == m.getParameterCount()) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of a method
|
||||
* @param i number of parameters
|
||||
* @param methCallType return type of method
|
||||
* @param typesOfParams
|
||||
* @param methods all methods of a class
|
||||
* @return the method in the class file which its name equals the given methode name
|
||||
*/
|
||||
private java.lang.reflect.Method getMethod(String name, int i, String methCallType, String[] typesOfParams, java.lang.reflect.Method[] methods) {
|
||||
// if(methCallType.equals("void")) {
|
||||
// methCallType = "V";
|
||||
// } else {
|
||||
// methCallType = "L"+methCallType+";";
|
||||
// }
|
||||
for(java.lang.reflect.Method m : methods) {
|
||||
if(name.equals(m.getName()) && i == m.getParameterCount() &&
|
||||
(methCallType.equals(m.getReturnType().getName().replace(".", "/")) ||
|
||||
m.getReturnType().getName().replace(".", "/").equals(Type.getInternalName(Object.class)))) {
|
||||
boolean typesEqual = true;
|
||||
Class<?>[] pTypes = m.getParameterTypes();
|
||||
for(int j = 0; j<typesOfParams.length; ++j) {
|
||||
if(!typesOfParams[j].equals(pTypes[j].getName().replaceAll(".", "/")) && !pTypes[j].getName().replace(".", "/").equals(Type.getInternalName(Object.class))) {
|
||||
typesEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(typesEqual)
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getMethodDesc(java.lang.reflect.Method methodRefl) {
|
||||
StringBuilder sb = new StringBuilder("(");
|
||||
|
||||
for(final Class c:(methodRefl.getParameterTypes()))
|
||||
sb= sb.append(getDescriptorForClass(c));
|
||||
|
||||
sb.append(')');
|
||||
sb.append(getDescriptorForClass(methodRefl.getReturnType()));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getDescriptorForClass(final Class c) {
|
||||
if(c.isPrimitive())
|
||||
{
|
||||
if(c==byte.class)
|
||||
return "B";
|
||||
if(c==char.class)
|
||||
return "C";
|
||||
if(c==double.class)
|
||||
return "D";
|
||||
if(c==float.class)
|
||||
return "F";
|
||||
if(c==int.class)
|
||||
return "I";
|
||||
if(c==long.class)
|
||||
return "J";
|
||||
if(c==short.class)
|
||||
return "S";
|
||||
if(c==boolean.class)
|
||||
return "Z";
|
||||
if(c==void.class)
|
||||
return "V";
|
||||
|
||||
}
|
||||
if(c.isArray())
|
||||
return c.getName().replace('.', '/');
|
||||
|
||||
return ('L'+c.getName()+';').replace('.', '/');
|
||||
// test
|
||||
// if(!methodCall.getType().toString().equals("V")) {
|
||||
// mv.visitInsn(Opcodes.POP);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1064,10 +708,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
// das wird später gemacht, da bytecode für cast noch nicht erzeugt wird
|
||||
|
||||
if (isIncOrDec && (unaryExpr.expr instanceof LocalVar)) {
|
||||
if(needDUP) {
|
||||
mv.visitInsn(Opcodes.DUP);
|
||||
needDUP = false;
|
||||
}
|
||||
LocalVar local = (LocalVar) unaryExpr.expr;
|
||||
mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.get(local.name));
|
||||
}
|
||||
@ -1115,22 +755,17 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
statement = new ReturnStmt(aReturn.retexpr);
|
||||
isReturnStmt = true;
|
||||
isBinaryExp = statement.isExprBinary();
|
||||
boolean isBinary = isBinaryExp;
|
||||
if(aReturn.retexpr instanceof UnaryExpr)
|
||||
needDUP = true;
|
||||
|
||||
|
||||
aReturn.retexpr.accept(this);
|
||||
|
||||
if (isBinary) {
|
||||
if (isBinaryExp) {
|
||||
BinaryExpr binary = (BinaryExpr) aReturn.retexpr;
|
||||
doBoxing(getResolvedType(binary.getType()));
|
||||
// isBinaryExp = false;
|
||||
isBinaryExp = false;
|
||||
}
|
||||
|
||||
|
||||
mv.visitInsn(Opcodes.ARETURN);
|
||||
isReturnStmt = false;
|
||||
statement = null;
|
||||
}
|
||||
|
||||
@ -1156,10 +791,6 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
|
||||
if(BytecodeGen.THISTYPE == null)
|
||||
BytecodeGen.THISTYPE = aThis.getType();
|
||||
|
||||
mv.visitVarInsn(Opcodes.ALOAD, 0);
|
||||
}
|
||||
|
||||
@ -1168,7 +799,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
statement = new LoopStmt(whileStmt.expr, whileStmt.loopBlock);
|
||||
isBinaryExp = statement.isExprBinary();
|
||||
whileStmt.expr.accept(this);
|
||||
// isBinaryExp = false;
|
||||
isBinaryExp = false;
|
||||
statement = null;
|
||||
}
|
||||
|
||||
@ -1182,14 +813,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
public void visit(Literal literal) {
|
||||
Object value = literal.value;
|
||||
String typeOfLiteral = getResolvedType(literal.getType());
|
||||
System.out.println("typeOfLiteral :=> "+ typeOfLiteral);
|
||||
// Der Wert des Literals wird auf den Stack geladen und
|
||||
// geboxt, wenn es nötig ist.
|
||||
loadValue(typeOfLiteral, value, false);
|
||||
}
|
||||
|
||||
// Unboxing: RefType -> prim
|
||||
public void doUnboxing(String type) {
|
||||
private void doUnboxing(String type) {
|
||||
switch (type) {
|
||||
case "java/lang/String":
|
||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(StringBuilder.class), "append",
|
||||
@ -1241,23 +871,16 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
break;
|
||||
case "java/lang/Integer":
|
||||
// zweite Argument isLong
|
||||
// visitIntegerLiteral(((Double) value).intValue(), false);
|
||||
if(value instanceof Double)
|
||||
visitIntegerLiteral(((Double) value).intValue(), false);
|
||||
if(value instanceof Integer)
|
||||
visitIntegerLiteral(((Integer) value).intValue(), false);
|
||||
visitIntegerLiteral(((Double) value).intValue(), false);
|
||||
break;
|
||||
case "java/lang/Long":
|
||||
visitLongLiteral(((Integer) value).longValue(), true);
|
||||
visitLongLiteral(((Double) value).longValue(), true);
|
||||
break;
|
||||
case "java/lang/Float":
|
||||
visitFloatLiteral(((Double) value).floatValue());
|
||||
break;
|
||||
case "java/lang/Double":
|
||||
if(value instanceof Double)
|
||||
visitDoubleLiteral((Double) value);
|
||||
if(value instanceof Integer)
|
||||
visitDoubleLiteral(((Integer) value).doubleValue());
|
||||
visitDoubleLiteral((Double) value);
|
||||
break;
|
||||
case "java/lang/Character":
|
||||
visitCharLiteral((Character) value);
|
||||
@ -1277,7 +900,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
}
|
||||
|
||||
// Boxing: prim -> RefType
|
||||
public void doBoxing(String type) {
|
||||
private void doBoxing(String type) {
|
||||
switch (type) {
|
||||
case "java/lang/String":
|
||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;",
|
||||
@ -1338,10 +961,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
}
|
||||
|
||||
private void visitLongLiteral(Long value, boolean isLong) {
|
||||
if (value == 0) {
|
||||
mv.visitInsn(Opcodes.LCONST_0);
|
||||
} else if (value == 1) {
|
||||
mv.visitInsn(Opcodes.LCONST_1);
|
||||
if (value < Math.pow(2, 15) || (value >= -Math.pow(2, 15)) && value < -128) {
|
||||
visitShortLiteral(value.shortValue(), isLong);
|
||||
} else {
|
||||
mv.visitLdcInsn(value);
|
||||
}
|
||||
@ -1392,16 +1013,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
public void visit(ArgumentList argumentList) {
|
||||
for (Expression al : argumentList.getArguments()) {
|
||||
statement = new ArgumentExpr(al);
|
||||
isBinaryExp = statement.isExprBinary();
|
||||
if(al instanceof UnaryExpr)
|
||||
needDUP = true;
|
||||
al.accept(this);
|
||||
//TODO: teste, ob man das für unary braucht
|
||||
if (isBinaryExp) {
|
||||
BinaryExpr binary = (BinaryExpr) al;
|
||||
String binaryType = getResolvedType(binary.getType());
|
||||
doBoxing(binaryType);
|
||||
}
|
||||
statement = null;
|
||||
}
|
||||
}
|
||||
@ -1416,18 +1028,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
// array slot onto the top of the operand stack.
|
||||
assignLeftSide.field.receiver.accept(this);
|
||||
this.rightSideTemp.accept(this);
|
||||
String fDesc = "L";
|
||||
if(resultSet.resolveType(assignLeftSide.field.getType()).resolvedType instanceof TypePlaceholder) {
|
||||
fDesc += Type.getInternalName(Object.class);
|
||||
} else {
|
||||
fDesc += resultSet.resolveType(assignLeftSide.field.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
}
|
||||
fDesc +=";";
|
||||
|
||||
|
||||
System.out.println("Receiver = " + getResolvedType(assignLeftSide.field.receiver.getType()));
|
||||
mv.visitFieldInsn(Opcodes.PUTFIELD, getResolvedType(assignLeftSide.field.receiver.getType()),
|
||||
assignLeftSide.field.fieldVarName, fDesc);
|
||||
assignLeftSide.field.fieldVarName, getResolvedType(assignLeftSide.field.getType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1438,9 +1040,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
String var = assignLeftSide.localVar.name;
|
||||
if (!paramsAndLocals.containsKey(var)) {
|
||||
paramsAndLocals.put(var, index + 1);
|
||||
}
|
||||
|
||||
mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.get(var));
|
||||
} else {
|
||||
paramsAndLocals.put(var, index);
|
||||
}
|
||||
|
||||
mv.visitVarInsn(Opcodes.ASTORE, paramsAndLocals.size());
|
||||
// Debug:::
|
||||
|
||||
}
|
||||
|
||||
}
|
1
src/main/java/de/dhbwstuttgart/bytecode/LoopStmt.java → src/de/dhbwstuttgart/bytecode/LoopStmt.java
1
src/main/java/de/dhbwstuttgart/bytecode/LoopStmt.java → src/de/dhbwstuttgart/bytecode/LoopStmt.java
@ -18,7 +18,6 @@ public class LoopStmt extends AStatement {
|
||||
|
||||
@Override
|
||||
public void genBCForRelOp(MethodVisitor mv,Label branchLabel, Label endLabel, BytecodeGenMethod bytecodeGenMethod) {
|
||||
bytecodeGenMethod.isBinary(false);
|
||||
this.loopBlock.accept(bytecodeGenMethod);
|
||||
mv.visitJumpInsn(Opcodes.GOTO, endLabel);
|
||||
mv.visitLabel(branchLabel);
|
@ -2,8 +2,6 @@ package de.dhbwstuttgart.bytecode.descriptor;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.signature.TypeToSignature;
|
||||
import de.dhbwstuttgart.bytecode.utilities.Lambda;
|
||||
import de.dhbwstuttgart.bytecode.utilities.MethodFromMethodCall;
|
||||
@ -51,8 +49,7 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
// desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
String resType = resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
if(resType.subSequence(0, 4).equals("TPH ")) {
|
||||
// Bound ist immer Object
|
||||
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||
desc += "L"+method.getGenericsAndBoundsMethod().get(resType.substring(4)+"$")+ ";";
|
||||
} else {
|
||||
desc += "L"+resType+ ";";
|
||||
}
|
||||
@ -79,8 +76,7 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
}else {
|
||||
String resType = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
if(resType.subSequence(0, 4).equals("TPH ")) {
|
||||
// desc += ")" + "L"+method.getGenericsAndBoundsMethod().get(resType.substring(4)+"$")+ ";";
|
||||
desc += ")" + "L"+Type.getInternalName(Object.class)+ ";";
|
||||
desc += ")" + "L"+method.getGenericsAndBoundsMethod().get(resType.substring(4)+"$")+ ";";
|
||||
} else {
|
||||
desc += ")" + "L"+resType+ ";";
|
||||
}
|
||||
@ -106,17 +102,10 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
if(constructor.getGenericsAndBounds().containsKey(fpDesc)){
|
||||
desc += "L"+constructor.getGenericsAndBounds().get(fpDesc)+ ";";
|
||||
}else {
|
||||
// desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
String resType = resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
if(resType.subSequence(0, 4).equals("TPH ")) {
|
||||
// Bound ist immer Object
|
||||
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||
} else {
|
||||
desc += "L"+resType+ ";";
|
||||
}
|
||||
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
}
|
||||
}else {
|
||||
// System.out.println("Cons has NO Gens");
|
||||
// System.out.println("Cons has NOT Gens");
|
||||
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
}
|
||||
}
|
||||
@ -130,21 +119,9 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
Iterator<FormalParameter> itr = lambdaExpression.getParams().iterator();
|
||||
while(itr.hasNext()) {
|
||||
FormalParameter fp = itr.next();
|
||||
String d = resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
if(d.substring(0, 4).equals("TPH ") ||d.contains("<")) {
|
||||
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||
}else {
|
||||
desc = desc + "L"+ d + ";";
|
||||
}
|
||||
}
|
||||
|
||||
String retType = resultSet.resolveType(lambdaExpression.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
|
||||
if(retType.substring(0, 4).equals("TPH ")|| retType.contains("<")){
|
||||
desc += ")L"+Type.getInternalName(Object.class)+ ";";
|
||||
}else {
|
||||
desc = desc + ")"+"L"+retType+";";
|
||||
desc = desc + "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor()) + ";";
|
||||
}
|
||||
desc = addReturnType(desc, lambdaExpression.getReturnType(), resultSet);
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -154,22 +131,9 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> itr = samMethod.getArgumentList().iterator();
|
||||
while(itr.hasNext()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric rt = itr.next();
|
||||
String d = resultSet.resolveType(rt).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
|
||||
if(d.substring(0, 4).equals("TPH ") ||d.contains("<")) {
|
||||
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||
}else {
|
||||
desc += "L"+ d + ";";
|
||||
|
||||
}
|
||||
}
|
||||
String retType = resultSet.resolveType(samMethod.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
|
||||
if(retType.substring(0, 4).equals("TPH ")|| retType.contains("<")){
|
||||
desc += ")L"+Type.getInternalName(Object.class)+ ";";
|
||||
}else {
|
||||
desc = desc + ")"+"L"+retType+";";
|
||||
desc = desc + "L"+resultSet.resolveType(rt).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
||||
}
|
||||
desc = desc + ")"+"L"+resultSet.resolveType(samMethod.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+";";
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -177,34 +141,26 @@ public class DescriptorToString implements DescriptorVisitor{
|
||||
public String visit(MethodFromMethodCall methodFromMethodCall) {
|
||||
String desc = "(";
|
||||
for(Expression e : methodFromMethodCall.getArgList().getArguments()) {
|
||||
String d = resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
|
||||
if(d.substring(0, 4).equals("TPH ") ||d.contains("<") || methodFromMethodCall.getReceiverName().contains("$$")) {
|
||||
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||
String d = e.getType().acceptTV(new TypeToDescriptor());
|
||||
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(d)) {
|
||||
desc += "L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(d)+ ";";
|
||||
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(d)) {
|
||||
desc += "L"+methodFromMethodCall.getGenericsAndBounds().get(d)+ ";";
|
||||
}else {
|
||||
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(d)) {
|
||||
desc += "L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(d)+ ";";
|
||||
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(d)) {
|
||||
desc += "L"+methodFromMethodCall.getGenericsAndBounds().get(d)+ ";";
|
||||
}else {
|
||||
desc += "L"+resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
}
|
||||
desc += "L"+resultSet.resolveType(e.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
}
|
||||
|
||||
}
|
||||
String retType = resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
System.out.println("DescriptorToString retType = " + retType);
|
||||
if(retType.equals("void")) {
|
||||
|
||||
if(resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.toString().equals("void")) {
|
||||
desc += ")V";
|
||||
}else if(retType.substring(0, 4).equals("TPH ")|| retType.contains("<") || methodFromMethodCall.getReceiverName().contains("$$")){
|
||||
desc += ")L"+Type.getInternalName(Object.class)+ ";";
|
||||
}else {
|
||||
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(retType)) {
|
||||
desc += ")L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(retType)+ ";";
|
||||
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(retType)){
|
||||
desc += ")L"+methodFromMethodCall.getGenericsAndBounds().get(retType)+ ";";
|
||||
String ret = resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||
if(methodFromMethodCall.getGenericsAndBoundsMethod().containsKey(ret)) {
|
||||
desc += ")L"+methodFromMethodCall.getGenericsAndBoundsMethod().get(ret)+ ";";
|
||||
}else if(methodFromMethodCall.getGenericsAndBounds().containsKey(ret)){
|
||||
desc += ")L"+methodFromMethodCall.getGenericsAndBounds().get(ret)+ ";";
|
||||
}else {
|
||||
desc += ")" + "L"+retType+ ";";
|
||||
desc += ")" + "L"+resultSet.resolveType(methodFromMethodCall.getReturnType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||
}
|
||||
}
|
||||
// desc = addReturnType(desc, methodFromMethodCall.getReturnType(), resultSet);
|
@ -19,9 +19,7 @@ public class TypeToDescriptor implements TypeVisitor<String>{
|
||||
|
||||
@Override
|
||||
public String visit(SuperWildcardType superWildcardType) {
|
||||
System.out.println("\nWILDCARD ="+superWildcardType.getInnerType().toString().replace(".", "/"));
|
||||
return superWildcardType.getInnerType().toString().replace(".", "/");
|
||||
//throw new NotImplementedException();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,7 +29,6 @@ public class TypeToDescriptor implements TypeVisitor<String>{
|
||||
|
||||
@Override
|
||||
public String visit(ExtendsWildcardType extendsWildcardType) {
|
||||
System.out.println("\nWILDCARD extends ="+extendsWildcardType.getInnerType().toString().replace(".", "/"));
|
||||
return extendsWildcardType.getInnerType().toString().replace(".", "/");
|
||||
//throw new NotImplementedException();
|
||||
}
|
225
src/de/dhbwstuttgart/bytecode/signature/Signature.java
Normal file
225
src/de/dhbwstuttgart/bytecode/signature/Signature.java
Normal file
@ -0,0 +1,225 @@
|
||||
package de.dhbwstuttgart.bytecode.signature;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.signature.SignatureVisitor;
|
||||
import org.objectweb.asm.signature.SignatureWriter;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
public class Signature {
|
||||
private ClassOrInterface classOrInterface;
|
||||
private HashMap<String, String> genericsAndBounds;
|
||||
private HashMap<String, String> genericsAndBoundsMethod;
|
||||
private SignatureWriter sw;
|
||||
private Constructor constructor;
|
||||
private Method method;
|
||||
private HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes;
|
||||
private ResultSet resultSet;
|
||||
|
||||
public Signature(ClassOrInterface classOrInterface, HashMap<String, String> genericsAndBounds) {
|
||||
this.classOrInterface = classOrInterface;
|
||||
this.genericsAndBounds = genericsAndBounds;
|
||||
sw = new SignatureWriter();
|
||||
createSignatureForClassOrInterface();
|
||||
}
|
||||
|
||||
public Signature(Constructor constructor, HashMap<String, String> genericsAndBounds, HashMap<String,RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes) {
|
||||
this.constructor = constructor;
|
||||
this.genericsAndBounds = genericsAndBounds;
|
||||
this.methodParamsAndTypes = methodParamsAndTypes;
|
||||
sw = new SignatureWriter();
|
||||
createSignatureForConsOrMethod(this.constructor,true);
|
||||
}
|
||||
|
||||
public Signature(Method method, HashMap<String, String> genericsAndBoundsMethod,
|
||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> methodParamsAndTypes, ResultSet resultSet) {
|
||||
this.method = method;
|
||||
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||
this.methodParamsAndTypes = methodParamsAndTypes;
|
||||
this.resultSet = resultSet;
|
||||
sw = new SignatureWriter();
|
||||
createSignatureForConsOrMethod(this.method,false);
|
||||
}
|
||||
|
||||
public Signature(LambdaExpression lambdaExpression,int numberOfParams) {
|
||||
sw = new SignatureWriter();
|
||||
createSignatureForFunN(lambdaExpression, numberOfParams);
|
||||
}
|
||||
|
||||
private void createSignatureForFunN(LambdaExpression lambdaExpression, int numberOfParams) {
|
||||
|
||||
// sw.visitClassBound().visitEnd();
|
||||
for(int i = 0;i<numberOfParams;i++) {
|
||||
int j = i+1;
|
||||
sw.visitFormalTypeParameter("T"+ j);
|
||||
// getBounds von Params
|
||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
||||
sw.visitClassBound().visitEnd();
|
||||
}
|
||||
|
||||
sw.visitFormalTypeParameter("R");
|
||||
// getBounds vom Return-Type
|
||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
||||
sw.visitClassBound().visitEnd();
|
||||
// TODO: prüfe ob Return-Type = void,
|
||||
sw.visitSuperclass().visitClassType(Type.getInternalName(Object.class));;
|
||||
sw.visitEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates signature for a method or constructor with @see {@link SignatureWriter}
|
||||
* Signature looks like:
|
||||
* <typevaliables (K:Ljava/lang/Object "Bounds")>(params L.. OR T.. Or basistape)ReturnType
|
||||
*
|
||||
* @param method method or constructor
|
||||
* @param isConstructor true if constructor
|
||||
*/
|
||||
private void createSignatureForConsOrMethod(Method method, boolean isConstructor) {
|
||||
Iterator<? extends GenericTypeVar> itr = method.getGenerics().iterator();
|
||||
// visits all formal type parameter and visits their bounds <T:...;B:...;...>
|
||||
while(itr.hasNext()) {
|
||||
GenericTypeVar g = itr.next();
|
||||
getBoundsOfTypeVar(g,genericsAndBoundsMethod);
|
||||
}
|
||||
// Wenn die RückgabeType eine TPH ist, wird als generic behandelt
|
||||
// z.B: Type = TPH K => wird eine Formal Type Parameter K$ erzeugt und Bound = Object
|
||||
String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
||||
if(ret.substring(0,4).equals("TPH ")) {
|
||||
String g = ret.substring(4)+"$";
|
||||
sw.visitFormalTypeParameter(g);
|
||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
||||
genericsAndBoundsMethod.put(g, Type.getInternalName(Object.class));
|
||||
sw.visitClassBound().visitEnd();
|
||||
}
|
||||
|
||||
for(String paramName : methodParamsAndTypes.keySet()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
|
||||
String pT = t.acceptTV(new TypeToSignature());
|
||||
// S.o
|
||||
if(pT.substring(0,4).equals("TPH ") && !genericsAndBoundsMethod.containsKey(pT)) {
|
||||
String gP = pT.substring(4)+"$";
|
||||
sw.visitFormalTypeParameter(gP);
|
||||
sw.visitClassBound().visitClassType(Type.getInternalName(Object.class));
|
||||
genericsAndBoundsMethod.put(gP, Type.getInternalName(Object.class));
|
||||
sw.visitClassBound().visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// visit each method-parameter to create the signature
|
||||
for(String paramName : methodParamsAndTypes.keySet()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric t = methodParamsAndTypes.get(paramName);
|
||||
// parameter type deswegen ist true
|
||||
doVisitParamsOrReturn(t,true);
|
||||
}
|
||||
if(isConstructor) {
|
||||
sw.visitReturnType().visitBaseType('V');
|
||||
}else {
|
||||
// String ret = resultSet.resolveType(method.getReturnType()).resolvedType.acceptTV(new TypeToSignature());
|
||||
// if(ret.substring(0,4).equals("TPH ")) {
|
||||
// String g = ret.substring(4);
|
||||
// if(!genericsAndBoundsMethod.containsKey(g)) {
|
||||
// genericsAndBoundsMethod.put(g, Type.getInternalName(Object.class));
|
||||
// } else {
|
||||
// genericsAndBoundsMethod.put(g+"_", Type.getInternalName(Object.class));
|
||||
// }
|
||||
// }
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType = method.getReturnType();
|
||||
// return type deswegen ist false
|
||||
doVisitParamsOrReturn(returnType, false);
|
||||
}
|
||||
// sw.visitEnd();
|
||||
}
|
||||
/**
|
||||
* Visits parameter type or return type with {@link SignatureVisitor} to create
|
||||
* the method signature
|
||||
* @param t type of parameter or return type
|
||||
* @param isParameterType true if t is type of parameter
|
||||
*/
|
||||
private void doVisitParamsOrReturn(RefTypeOrTPHOrWildcardOrGeneric t, boolean isParameterType) {
|
||||
String type = t.acceptTV(new TypeToString());
|
||||
SignatureVisitor sv;
|
||||
if(isParameterType) {
|
||||
sv = sw.visitParameterType();
|
||||
}
|
||||
else {
|
||||
sv = sw.visitReturnType();
|
||||
}
|
||||
switch (type) {
|
||||
case "RT":
|
||||
sv.visitClassType(t.acceptTV(new TypeToSignature()));
|
||||
break;
|
||||
case "GRT":
|
||||
GenericRefType g = (GenericRefType) t;
|
||||
sv.visitTypeVariable(g.acceptTV(new TypeToSignature()));
|
||||
break;
|
||||
case "TPH":
|
||||
RefTypeOrTPHOrWildcardOrGeneric r = resultSet.resolveType(t).resolvedType;
|
||||
// der Fall wenn die Type eine Interface ist, muss betrachtet werden
|
||||
// Deswegen muss in ResutSet noch enthalten werden, ob die Type eine
|
||||
// Interface oder eine Klasse ist.
|
||||
if(!r.acceptTV(new TypeToSignature()).substring(0, 4).equals("TPH ")) {
|
||||
// sv.visitInterface().visitClassType(r.acceptTV(new TypeToSignature()));
|
||||
sv.visitClassType(r.acceptTV(new TypeToSignature()));
|
||||
} else {
|
||||
System.out.println(r.getClass()+" Signature TPH: "+r.acceptTV(new TypeToSignature()));
|
||||
sv.visitTypeVariable(r.acceptTV(new TypeToSignature()).substring(4)+"$");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(!isParameterType)
|
||||
sv.visitBaseType('V');
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates signature for class or interface with {@link SignatureWriter}
|
||||
* Signature looks like:
|
||||
* <typevaliables (K:Ljava/lang/Object "Bounds")>superclass
|
||||
*/
|
||||
private void createSignatureForClassOrInterface() {
|
||||
Iterator<GenericTypeVar> itr = classOrInterface.getGenerics().iterator();
|
||||
|
||||
while(itr.hasNext()) {
|
||||
GenericTypeVar g = itr.next();
|
||||
getBoundsOfTypeVar(g,genericsAndBounds);
|
||||
}
|
||||
|
||||
sw.visitSuperclass().visitClassType(classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor()));;
|
||||
sw.visitEnd();
|
||||
}
|
||||
/**
|
||||
* Get bounds of type variable
|
||||
* @param g type variable
|
||||
* @param genAndBounds
|
||||
*/
|
||||
private void getBoundsOfTypeVar(GenericTypeVar g, HashMap<String, String> genAndBounds) {
|
||||
sw.visitFormalTypeParameter(g.getName());
|
||||
|
||||
Iterator<? extends RefTypeOrTPHOrWildcardOrGeneric> bItr = g.getBounds().iterator();
|
||||
while(bItr.hasNext()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric b =bItr.next();
|
||||
String boundDesc = b.acceptTV(new TypeToDescriptor());
|
||||
// System.out.println("GetBounds: " + boundDesc);
|
||||
// Ensure that <...> extends java.lang.Object OR ...
|
||||
sw.visitClassBound().visitClassType(boundDesc);
|
||||
genAndBounds.put(g.getName(), boundDesc);
|
||||
}
|
||||
sw.visitClassBound().visitEnd();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
}
|
@ -15,8 +15,6 @@ public class TypeToSignature implements TypeVisitor<String> {
|
||||
|
||||
@Override
|
||||
public String visit(RefType refType) {
|
||||
if(refType.getName().toString().equals("void"))
|
||||
return "V";
|
||||
// return refType.toString().replace(".", "/");
|
||||
String params = "";
|
||||
if(refType.getParaList().size()>0){
|
||||
@ -24,49 +22,29 @@ public class TypeToSignature implements TypeVisitor<String> {
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> it = refType.getParaList().iterator();
|
||||
while(it.hasNext()){
|
||||
RefTypeOrTPHOrWildcardOrGeneric param = it.next();
|
||||
// if(param instanceof TypePlaceholder) {
|
||||
// params += "T" + ((TypePlaceholder) param).getName() + "$";
|
||||
// } else if(param instanceof ExtendsWildcardType) {
|
||||
// params += "+" + ((ExtendsWildcardType) param).getInnerType().acceptTV(new TypeToSignature());
|
||||
// } else if(param instanceof SuperWildcardType) {
|
||||
// params += "-" + ((SuperWildcardType) param).getInnerType().acceptTV(new TypeToSignature());
|
||||
// } else {
|
||||
// params += "L"+param.toString().replace(".", "/");
|
||||
// }
|
||||
params += param.acceptTV(new TypeToSignature());
|
||||
|
||||
if(param instanceof TypePlaceholder)
|
||||
params += ";";
|
||||
params += "L"+param.toString().replace(".", "/");
|
||||
if(it.hasNext())params += ";";
|
||||
}
|
||||
params += ">";
|
||||
params += ";>";
|
||||
}
|
||||
// String t = refType.getName().toString().replace(".", "/");
|
||||
// return t.equals("Fun1")?t+"$$"+params+";":t+params+";";
|
||||
return "L"+refType.getName().toString().replace(".", "/") + params+";";
|
||||
return refType.getName().toString().replace(".", "/") + params+";";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(SuperWildcardType superWildcardType) {
|
||||
// throw new NotImplementedException();
|
||||
String sig = "-" + superWildcardType.getInnerType().acceptTV(new TypeToSignature());
|
||||
if(superWildcardType.getInnerType() instanceof TypePlaceholder)
|
||||
sig += ";";
|
||||
return sig;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(TypePlaceholder typePlaceholder) {
|
||||
// return typePlaceholder.toString().replace(".", "/");
|
||||
return "T" + typePlaceholder.getName() + "$";
|
||||
return typePlaceholder.toString().replace(".", "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visit(ExtendsWildcardType extendsWildcardType) {
|
||||
// throw new NotImplementedException();
|
||||
String sig = "+" + extendsWildcardType.getInnerType().acceptTV(new TypeToSignature());
|
||||
if(extendsWildcardType.getInnerType() instanceof TypePlaceholder)
|
||||
sig += ";";
|
||||
return sig;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
@ -17,7 +17,7 @@ public class TypeToString implements TypeVisitor<String>{
|
||||
|
||||
@Override
|
||||
public String visit(SuperWildcardType superWildcardType) {
|
||||
return "SWC";
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,7 +27,7 @@ public class TypeToString implements TypeVisitor<String>{
|
||||
|
||||
@Override
|
||||
public String visit(ExtendsWildcardType extendsWildcardType) {
|
||||
return "EWC";
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
@ -4,34 +4,22 @@ import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Literal;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
public class KindOfLambda implements StatementVisitor{
|
||||
private ParameterList params;
|
||||
private boolean isInstanceCapturingLambda = false;
|
||||
private List<RefTypeOrTPHOrWildcardOrGeneric> argumentList = new ArrayList<>();
|
||||
private ArrayList<String> usedVars = new ArrayList<>();
|
||||
private boolean hasThis = false;
|
||||
private ArrayList<String> definedLocals = new ArrayList<>();
|
||||
|
||||
public KindOfLambda(LambdaExpression lambdaExpression) {
|
||||
this.params = lambdaExpression.params;
|
||||
lambdaExpression.methodBody.accept(this);
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> getUsedVars() {
|
||||
return usedVars;
|
||||
}
|
||||
|
||||
public boolean isInstanceCapturingLambda() {
|
||||
return this.isInstanceCapturingLambda;
|
||||
}
|
||||
@ -40,10 +28,6 @@ public class KindOfLambda implements StatementVisitor{
|
||||
return argumentList;
|
||||
}
|
||||
|
||||
public boolean isHasThis() {
|
||||
return hasThis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
// TODO Auto-generated method stub
|
||||
@ -62,8 +46,8 @@ public class KindOfLambda implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(BinaryExpr binary) {
|
||||
binary.lexpr.accept(this);
|
||||
binary.rexpr.accept(this);
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,9 +82,8 @@ public class KindOfLambda implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
ifStmt.expr.accept(this);
|
||||
ifStmt.then_block.accept(this);
|
||||
ifStmt.else_block.accept(this);
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,31 +94,14 @@ public class KindOfLambda implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
if(!contain(params, localVar.name) && !definedLocals.contains(localVar.name)) {
|
||||
argumentList.add(localVar.getType());
|
||||
if(hasThis) {
|
||||
usedVars.add(1, localVar.name);
|
||||
} else {
|
||||
usedVars.add(0, localVar.name);
|
||||
}
|
||||
if(!isInstanceCapturingLambda)
|
||||
isInstanceCapturingLambda=true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean contain(ParameterList params2, String name) {
|
||||
Iterator<FormalParameter> itr = params2.iterator();
|
||||
while(itr.hasNext()) {
|
||||
FormalParameter fp = itr.next();
|
||||
if(fp.getName().equals(name))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
definedLocals.add(localVarDecl.getName());
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,7 +128,7 @@ public class KindOfLambda implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,20 +156,13 @@ public class KindOfLambda implements StatementVisitor{
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
if(!hasThis) {
|
||||
hasThis = true;
|
||||
this.argumentList.add(0,aThis.getType());
|
||||
}
|
||||
if(!isInstanceCapturingLambda) {
|
||||
this.isInstanceCapturingLambda = true;
|
||||
|
||||
}
|
||||
this.isInstanceCapturingLambda = true;
|
||||
this.argumentList.add(aThis.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
whileStmt.expr.accept(this);
|
||||
whileStmt.loopBlock.accept(this);
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -9,16 +9,13 @@ import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
public class MethodFromMethodCall {
|
||||
private ArgumentList argList;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
private String receiverName;
|
||||
private HashMap<String, String> genericsAndBoundsMethod;
|
||||
private HashMap<String,String> genericsAndBounds;
|
||||
|
||||
public MethodFromMethodCall(ArgumentList argList,RefTypeOrTPHOrWildcardOrGeneric returnType,
|
||||
String receiverName, HashMap<String, String> genericsAndBoundsMethod,
|
||||
HashMap<String,String> genericsAndBounds) {
|
||||
public MethodFromMethodCall(ArgumentList argList,RefTypeOrTPHOrWildcardOrGeneric returnType,
|
||||
HashMap<String, String> genericsAndBoundsMethod,HashMap<String,String> genericsAndBounds) {
|
||||
this.argList = argList;
|
||||
this.returnType = returnType;
|
||||
this.receiverName = receiverName;
|
||||
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||
this.genericsAndBounds = genericsAndBounds;
|
||||
}
|
||||
@ -31,10 +28,6 @@ public class MethodFromMethodCall {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public String getReceiverName() {
|
||||
return receiverName;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getGenericsAndBoundsMethod(){
|
||||
return genericsAndBoundsMethod;
|
||||
}
|
180
src/de/dhbwstuttgart/core/JavaTXCompiler.java
Normal file
180
src/de/dhbwstuttgart/core/JavaTXCompiler.java
Normal file
@ -0,0 +1,180 @@
|
||||
package de.dhbwstuttgart.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.BytecodeGen;
|
||||
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||||
import de.dhbwstuttgart.parser.JavaTXParser;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext;
|
||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.strucTypes.Construct;
|
||||
import de.dhbwstuttgart.strucTypes.Solve;
|
||||
import de.dhbwstuttgart.strucTypes.StrucTYPE;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.exception.ImpossibleSubTypeException;
|
||||
import de.dhbwstuttgart.strucTypes.exception.InconsistentConstraintsException;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.model.SolvedClass;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typeAlgo.TYPE;
|
||||
import de.dhbwstuttgart.typeinference.unify.RuleSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class JavaTXCompiler {
|
||||
|
||||
final CompilationEnvironment environment;
|
||||
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
|
||||
|
||||
public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException {
|
||||
this(Arrays.asList(sourceFile));
|
||||
}
|
||||
|
||||
public JavaTXCompiler(List<File> sources) throws IOException, ClassNotFoundException {
|
||||
environment = new CompilationEnvironment(sources);
|
||||
for (File s : sources) {
|
||||
sourceFiles.put(s, parse(s));
|
||||
}
|
||||
}
|
||||
|
||||
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||
for (SourceFile sf : sourceFiles.values()) {
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
List<ClassOrInterface> importedClasses = new ArrayList<>();
|
||||
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins
|
||||
// FC
|
||||
for (File forSourceFile : sourceFiles.keySet())
|
||||
for (JavaClassName name : sourceFiles.get(forSourceFile).getImports()) {
|
||||
// TODO: Hier werden imports von eigenen (.jav) Klassen nicht
|
||||
// beachtet
|
||||
ClassOrInterface importedClass = ASTFactory
|
||||
.createClass(ClassLoader.getSystemClassLoader().loadClass(name.toString()));
|
||||
importedClasses.add(importedClass);
|
||||
}
|
||||
allClasses.addAll(importedClasses);
|
||||
|
||||
return new TYPE(sourceFiles.values(), allClasses).getConstraints();
|
||||
}
|
||||
|
||||
public List<ClassOrInterface> getAvailableClasses(SourceFile forSourceFile) throws ClassNotFoundException {
|
||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||
for (SourceFile sf : sourceFiles.values()) {
|
||||
allClasses.addAll(sf.getClasses());
|
||||
}
|
||||
List<ClassOrInterface> importedClasses = new ArrayList<>();
|
||||
for (JavaClassName name : forSourceFile.getImports()) {
|
||||
// TODO: Hier werden imports von eigenen (.jav) Klassen nicht
|
||||
// beachtet
|
||||
ClassOrInterface importedClass = ASTFactory
|
||||
.createClass(ClassLoader.getSystemClassLoader().loadClass(name.toString()));
|
||||
importedClasses.add(importedClass);
|
||||
allClasses.addAll(importedClasses);
|
||||
}
|
||||
return allClasses;
|
||||
}
|
||||
|
||||
public List<SolvedClass> strucTypeInference()
|
||||
throws ImpossibleSubTypeException, ClassNotFoundException, InconsistentConstraintsException {
|
||||
List<SolvedClass> solvedClasses = new ArrayList<>();
|
||||
for (SourceFile sourceFile : sourceFiles.values()) {
|
||||
ClassOrInterface clsA = sourceFile.getClasses().get(0);
|
||||
|
||||
StrucTYPE strucTYPE = new StrucTYPE(clsA);
|
||||
ConstraintsSet strucTypeConstraints = strucTYPE.getConstraints();
|
||||
InferredTypes inferredTypes = strucTYPE.getInferredTypes();
|
||||
|
||||
Construct construct = new Construct(strucTypeConstraints, inferredTypes);
|
||||
List<ClassOrInterface> constructedInterfaces = construct.getConstructedInterfaces();
|
||||
Set<SubTypeConstraint> subTypeConstraints = construct.getSubTypeConstraints();
|
||||
inferredTypes = construct.getInferredTypes();
|
||||
|
||||
IFiniteClosure fc = UnifyTypeFactory.generateFC(this.getAvailableClasses(sourceFile));
|
||||
Solve solve = new Solve(subTypeConstraints, clsA, fc, inferredTypes, constructedInterfaces);
|
||||
SolvedClass solvedClass = solve.getSolvedClass();
|
||||
solvedClasses.add(solvedClass);
|
||||
}
|
||||
return solvedClasses;
|
||||
}
|
||||
|
||||
public List<ResultSet> typeInference() 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<>();
|
||||
for (List<Constraint<UnifyPair>> xCons : unifyCons.cartesianProduct()) {
|
||||
Set<UnifyPair> xConsSet = new HashSet<>();
|
||||
for (Constraint<UnifyPair> constraint : xCons) {
|
||||
xConsSet.addAll(constraint);
|
||||
}
|
||||
|
||||
System.out.println(xConsSet);
|
||||
Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||
System.out.println("RESULT: " + result.size());
|
||||
results.addAll(result);
|
||||
}
|
||||
return results.stream()
|
||||
.map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons)))))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Map<String, TypePlaceholder> generateTPHMap(ConstraintSet<Pair> constraints) {
|
||||
HashMap<String, TypePlaceholder> ret = new HashMap<>();
|
||||
constraints.map((Pair p) -> {
|
||||
if (p.TA1 instanceof TypePlaceholder) {
|
||||
ret.put(((TypePlaceholder) p.TA1).getName(), (TypePlaceholder) p.TA1);
|
||||
}
|
||||
if (p.TA2 instanceof TypePlaceholder) {
|
||||
ret.put(((TypePlaceholder) p.TA2).getName(), (TypePlaceholder) p.TA2);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
|
||||
CompilationUnitContext tree = JavaTXParser.parse(sourceFile);
|
||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(environment.getRegistry(sourceFile),
|
||||
new GenericsRegistry(null));
|
||||
SourceFile ret = generator.convert(tree, environment.packageCrawler);
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.visitor.ASTReturnVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignLeftSide;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
||||
@ -17,4 +18,9 @@ public class AssignToLocal extends AssignLeftSide {
|
||||
public void accept(StatementVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssignToLocal accept(ASTReturnVisitor visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
}
|
@ -13,8 +13,6 @@ import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class FCGenerator {
|
||||
/**
|
||||
* Baut die FiniteClosure aus availableClasses.
|
||||
@ -28,18 +26,11 @@ public class FCGenerator {
|
||||
|
||||
public static Set<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
|
||||
HashSet<Pair> pairs = new HashSet<>();
|
||||
//PL 2018-09-18: gtvs vor die for-Schleife gezogen, damit immer die gleichen Typeplaceholder eingesetzt werden.
|
||||
HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs = new HashMap<>();
|
||||
for(ClassOrInterface cly : availableClasses){
|
||||
pairs.addAll(getSuperTypes(cly, availableClasses, gtvs));
|
||||
pairs.addAll(getSuperTypes(cly, availableClasses));
|
||||
}
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bildet eine Kette vom übergebenen Typ bis hin zum höchsten bekannten Typ
|
@ -21,14 +21,13 @@ import java.util.*;
|
||||
public class StatementGenerator {
|
||||
|
||||
private JavaClassRegistry reg;
|
||||
private Map<String, RefTypeOrTPHOrWildcardOrGeneric> fields; //PL 2018-11-01 fields eingefuegt, damit die fields immer die gleiche TPH bekommen
|
||||
private Map<String, RefTypeOrTPHOrWildcardOrGeneric> localVars;
|
||||
private GenericsRegistry generics;
|
||||
private String VAR_KEYWORD = "var";
|
||||
|
||||
public StatementGenerator(JavaClassRegistry reg, GenericsRegistry generics, Map<String, RefTypeOrTPHOrWildcardOrGeneric> fields, Map<String, RefTypeOrTPHOrWildcardOrGeneric> localVars){
|
||||
public StatementGenerator(JavaClassRegistry reg, GenericsRegistry generics, Map<String, RefTypeOrTPHOrWildcardOrGeneric> localVars){
|
||||
this.reg = reg;
|
||||
this.generics = generics;
|
||||
this.fields = fields;
|
||||
this.localVars = localVars;
|
||||
}
|
||||
|
||||
@ -240,14 +239,9 @@ public class StatementGenerator {
|
||||
if(localVars.get(expression) != null){
|
||||
return new LocalVar(expression, localVars.get(expression), offset);
|
||||
}else{
|
||||
if(fields.get(expression) != null){//PL 2018-11-01 fields eingefuegt, damit die fields immer die gleiche TPH bekommen
|
||||
return new FieldVar(new This(offset), expression, fields.get(expression), offset);
|
||||
|
||||
} else {
|
||||
//kann eigentlich nicht vorkommen
|
||||
//Dann Muss es ein Feld sein!
|
||||
return new FieldVar(new This(offset), expression, TypePlaceholder.fresh(offset), offset);
|
||||
}}
|
||||
}
|
||||
}
|
||||
return generateFieldVarOrClassname(expression, offset);
|
||||
}
|
||||
@ -412,7 +406,7 @@ public class StatementGenerator {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
RefTypeOrTPHOrWildcardOrGeneric type;
|
||||
if(declaration.unannTypeOrAuto().unannType() == null){
|
||||
if(declaration.unannTypeOrAuto().unannType().getText().equals(VAR_KEYWORD)){
|
||||
type = TypePlaceholder.fresh(declaration.getStart());
|
||||
}else{
|
||||
type = TypeGenerator.convert(declaration.unannTypeOrAuto().unannType(), reg, generics);
|
||||
@ -452,7 +446,7 @@ public class StatementGenerator {
|
||||
}
|
||||
return (new Assign(new AssignToField(
|
||||
new FieldVar(new This(varDecl.getStart()), name.getText(),
|
||||
type, varDecl.getStart())),
|
||||
new Void(varDecl.getStart()), varDecl.getStart())),
|
||||
initValue, name.getSymbol()));
|
||||
}
|
||||
|
||||
@ -590,10 +584,7 @@ public class StatementGenerator {
|
||||
if(expression.equalityExpression() == null){
|
||||
return convert(expression.relationalExpression());
|
||||
}else{
|
||||
String operator = expression.getChild(1).getText();
|
||||
Expression leftSide = convert(expression.equalityExpression());
|
||||
Expression rightSide = convert(expression.relationalExpression());
|
||||
return new BinaryExpr(convertBinaryOperator(operator), TypePlaceholder.fresh(expression.getStart()), leftSide, rightSide, expression.getStart());
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -629,12 +620,8 @@ public class StatementGenerator {
|
||||
return BinaryExpr.Operator.BIGGERTHAN;
|
||||
}else if(operator.equals(">=")) {
|
||||
return BinaryExpr.Operator.BIGGEREQUAL;
|
||||
} else if(operator.equals("<=")) {
|
||||
return BinaryExpr.Operator.LESSEQUAL;
|
||||
} else if(operator.equals("==")) {
|
||||
return BinaryExpr.Operator.EQUAL;
|
||||
} else if(operator.equals("!=")) {
|
||||
return BinaryExpr.Operator.NOTEQUAL;
|
||||
} else if(operator.equals("<=")) {
|
||||
return BinaryExpr.Operator.LESSEQUAL;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@ -758,7 +745,6 @@ public class StatementGenerator {
|
||||
if(e.classInstanceCreationExpression_lf_primary() != null){
|
||||
throw new NotImplementedException();
|
||||
}else if(e.fieldAccess_lf_primary() != null){
|
||||
|
||||
throw new NotImplementedException();
|
||||
}else if(e.arrayAccess_lf_primary() != null){
|
||||
throw new NotImplementedException();
|
||||
@ -813,6 +799,8 @@ public class StatementGenerator {
|
||||
if(newExpression.typeArgumentsOrDiamond()!= null){
|
||||
if(newExpression.typeArgumentsOrDiamond().typeArguments()!=null){
|
||||
genericArgs = newExpression.typeArgumentsOrDiamond().typeArguments();
|
||||
}else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
if(newExpression.typeArguments()!= null)throw new NotImplementedException();
|
||||
@ -825,12 +813,8 @@ public class StatementGenerator {
|
||||
}
|
||||
|
||||
private Expression convert(Java8Parser.LiteralContext literal) {
|
||||
if(literal.IntegerLiteral() != null){
|
||||
Number value = Integer.parseInt(literal.IntegerLiteral().getText());
|
||||
return new Literal(TypePlaceholder.fresh(literal.getStart()),
|
||||
value, literal.getStart());
|
||||
} else if(literal.FloatingPointLiteral()!= null){
|
||||
Number value = Double.parseDouble(literal.FloatingPointLiteral().getText());
|
||||
if(literal.IntegerLiteral() != null || literal.FloatingPointLiteral()!= null){
|
||||
Number value = Double.parseDouble(literal.IntegerLiteral().getText());
|
||||
return new Literal(TypePlaceholder.fresh(literal.getStart()),
|
||||
value, literal.getStart());
|
||||
}else if(literal.BooleanLiteral() != null){
|
||||
@ -903,7 +887,7 @@ public class StatementGenerator {
|
||||
for(FormalParameter param : params.getFormalparalist()){
|
||||
lambdaLocals.put(param.getName(), param.getType());
|
||||
}
|
||||
StatementGenerator lambdaGenerator = new StatementGenerator(reg, generics, fields, lambdaLocals);
|
||||
StatementGenerator lambdaGenerator = new StatementGenerator(reg, generics, lambdaLocals);
|
||||
|
||||
Block block;
|
||||
if(expression.lambdaBody().expression() != null){
|
@ -5,7 +5,6 @@ import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import java.lang.ClassNotFoundException;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import de.dhbwstuttgart.parser.scope.GatherNames;
|
||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||
@ -33,7 +32,6 @@ public class SyntaxTreeGenerator{
|
||||
private final GenericsRegistry globalGenerics;
|
||||
private String pkgName = "";
|
||||
Set<JavaClassName> imports = new HashSet();
|
||||
private Map<String, RefTypeOrTPHOrWildcardOrGeneric> fields = new HashMap<>(); //PL 2018-11-01 fields eingefuegt, damit die fields immer die gleiche TPH bekommen
|
||||
|
||||
List<Statement> fieldInitializations = new ArrayList<>();
|
||||
|
||||
@ -123,7 +121,7 @@ public class SyntaxTreeGenerator{
|
||||
private Method convert(int modifiers, Java8Parser.MethodHeaderContext header, Java8Parser.MethodBodyContext body,
|
||||
JavaClassName parentClass, RefType superClass, GenericsRegistry localGenerics) {
|
||||
|
||||
StatementGenerator stmtGen = new StatementGenerator(reg, localGenerics, fields, new HashMap<>());
|
||||
StatementGenerator stmtGen = new StatementGenerator(reg, localGenerics, new HashMap<>());
|
||||
|
||||
String name = header.methodDeclarator().Identifier().getText();
|
||||
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), header.getStart());
|
||||
@ -151,7 +149,7 @@ public class SyntaxTreeGenerator{
|
||||
block = stmtGen.convert(body.block(),true);
|
||||
}
|
||||
if(parentClass.equals(new JavaClassName(name))){
|
||||
return new Constructor(modifiers, name, retType, parameterList, block, gtvDeclarations, header.getStart() /*, fieldInitializations geloescht PL 2018-11-24 */);
|
||||
return new Constructor(modifiers, name, retType, parameterList, block, gtvDeclarations, header.getStart(), fieldInitializations);
|
||||
}else{
|
||||
return new Method(modifiers, name, retType, parameterList,block, gtvDeclarations, header.getStart());
|
||||
}
|
||||
@ -197,19 +195,14 @@ public class SyntaxTreeGenerator{
|
||||
superClass = new RefType(ASTFactory.createObjectClass().getClassName(), ctx.getStart());
|
||||
}
|
||||
List<Field> fielddecl = convertFields(ctx.classBody(), generics);
|
||||
//fieldInitializations = generateFieldInitializations(ctx.classBody(), generics);
|
||||
List<Method> methodsAndConstructors = convertMethods(ctx.classBody(), name, superClass, generics);
|
||||
List<Method> methods = new ArrayList<>();
|
||||
List<Method> methods = convertMethods(ctx.classBody(), name, superClass, generics);
|
||||
List<Constructor> konstruktoren = new ArrayList<>();
|
||||
//int noOfMethods = methods.size();
|
||||
for(int i = 0; i < methodsAndConstructors.size(); i++){
|
||||
Method m = methodsAndConstructors.get(i);
|
||||
for(int i = 0; i<methods.size();i++){
|
||||
Method m = methods.get(i);
|
||||
if(m instanceof Constructor){
|
||||
methods.remove(i);
|
||||
konstruktoren.add((Constructor) m);
|
||||
}
|
||||
else {
|
||||
methods.add(m);
|
||||
}
|
||||
}
|
||||
if(konstruktoren.size()<1){//Standardkonstruktor anfügen:
|
||||
konstruktoren.add(
|
||||
@ -221,39 +214,10 @@ public class SyntaxTreeGenerator{
|
||||
|
||||
Boolean isInterface = false;
|
||||
List<RefType> implementedInterfaces = convert(ctx.superinterfaces(), generics);
|
||||
|
||||
return new ClassOrInterface(modifiers, name, fielddecl,
|
||||
Optional.of(this.generatePseudoConstructor(ctx.Identifier().getText(), name, superClass, genericClassParameters, offset)),
|
||||
methods, konstruktoren, genericClassParameters, superClass,
|
||||
return new ClassOrInterface(modifiers, name, fielddecl, methods, konstruktoren, genericClassParameters, superClass,
|
||||
isInterface, implementedInterfaces, offset);
|
||||
}
|
||||
|
||||
/*
|
||||
private List<Statement> generateFieldInitializations(Java8Parser.ClassBodyContext classBodyContext, GenericsRegistry generics) {
|
||||
List<Statement> ret = new ArrayList<>();
|
||||
for(Java8Parser.ClassBodyDeclarationContext classMember : classBodyContext.classBodyDeclaration()){
|
||||
if(classMember.classMemberDeclaration() != null){
|
||||
Java8Parser.ClassMemberDeclarationContext classMemberDeclarationContext = classMember.classMemberDeclaration();
|
||||
if(classMemberDeclarationContext.fieldDeclaration() != null
|
||||
&& classMemberDeclarationContext.fieldDeclaration().variableDeclaratorList() != null){
|
||||
for(Java8Parser.VariableDeclaratorContext ctx : classMemberDeclarationContext.fieldDeclaration().variableDeclaratorList().variableDeclarator()) {
|
||||
String fieldName = ctx.variableDeclaratorId().Identifier().getText();
|
||||
if(ctx.variableDeclaratorId().dims() != null)throw new NotImplementedException();
|
||||
Token offset = ctx.getStart();
|
||||
RefTypeOrTPHOrWildcardOrGeneric fieldType;
|
||||
for(Field f : fields)
|
||||
AssignToField leftSide = new AssignToField(new FieldVar(new This(offset), fieldName, ));
|
||||
ret.addAll();
|
||||
}
|
||||
}else if(classMemberDeclarationContext.methodDeclaration()!= null){
|
||||
//Do nothing!
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
private List<RefType> convert(Java8Parser.SuperinterfacesContext ctx, GenericsRegistry generics) {
|
||||
if(ctx == null)return new ArrayList<>();
|
||||
return convert(ctx.interfaceTypeList(), generics);
|
||||
@ -274,16 +238,8 @@ public class SyntaxTreeGenerator{
|
||||
RefType classType = ClassOrInterface.generateTypeOfClass(reg.getName(className), classGenerics, offset);
|
||||
ParameterList params = new ParameterList(new ArrayList<>(), offset);
|
||||
Block block = new Block(new ArrayList<>(), offset);
|
||||
return new Constructor(Modifier.PUBLIC, className, classType, params, block, classGenerics, offset /*, fieldInitializations geloescht PL 2018-11-24 */);
|
||||
return new Constructor(Modifier.PUBLIC, className, classType, params, block, classGenerics, offset, fieldInitializations);
|
||||
}
|
||||
|
||||
/* fieldInitializations werden in einem Psedokonstruktor in der abstrakten Syntax gespeichert */
|
||||
private Constructor generatePseudoConstructor(String className, JavaClassName parentClass, RefType superClass, GenericDeclarationList classGenerics, Token offset){
|
||||
RefType classType = ClassOrInterface.generateTypeOfClass(reg.getName(className), classGenerics, offset);
|
||||
ParameterList params = new ParameterList(new ArrayList<>(), offset);
|
||||
Block block = new Block(new ArrayList<>(fieldInitializations), offset);
|
||||
return new Constructor(Modifier.PUBLIC, className, classType, params, block, classGenerics, offset /*, fieldInitializations geloescht PL 2018-11-24 */);
|
||||
}
|
||||
|
||||
private RefType convert(Java8Parser.SuperclassContext superclass) {
|
||||
if(superclass.classType().classOrInterfaceType() != null){
|
||||
@ -354,19 +310,19 @@ public class SyntaxTreeGenerator{
|
||||
modifiers+=(convert(fieldModifierContext));
|
||||
}
|
||||
RefTypeOrTPHOrWildcardOrGeneric fieldType;
|
||||
if(fieldDeclarationContext.unannTypeOrAuto() != null
|
||||
&& fieldDeclarationContext.unannTypeOrAuto().unannType() != null){
|
||||
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannTypeOrAuto().unannType(), reg, generics);
|
||||
if(fieldDeclarationContext.unannType() != null){
|
||||
fieldType = TypeGenerator.convert(fieldDeclarationContext.unannType(), reg, generics);
|
||||
}else{
|
||||
fieldType = TypePlaceholder.fresh(fieldDeclarationContext.getStart());
|
||||
}
|
||||
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
|
||||
String fieldName = convert(varCtx.variableDeclaratorId());
|
||||
fields.put(fieldName, fieldType);
|
||||
if(varCtx.variableInitializer() != null){
|
||||
initializeField(varCtx, fieldType, generics);
|
||||
}
|
||||
ret.add(new Field(fieldName,fieldType,modifiers,varCtx.getStart()));
|
||||
else{
|
||||
ret.add(new Field(fieldName,fieldType,modifiers,varCtx.getStart()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -377,7 +333,7 @@ public class SyntaxTreeGenerator{
|
||||
|
||||
// Initialize a field by creating implicit constructor.
|
||||
private void initializeField(Java8Parser.VariableDeclaratorContext ctx, RefTypeOrTPHOrWildcardOrGeneric typeOfField, GenericsRegistry generics){
|
||||
StatementGenerator statementGenerator = new StatementGenerator(reg, generics, fields, new HashMap<>());
|
||||
StatementGenerator statementGenerator = new StatementGenerator(reg, generics, new HashMap<>());
|
||||
fieldInitializations.add(statementGenerator.generateFieldAssignment(ctx, typeOfField));
|
||||
}
|
||||
|
||||
@ -456,7 +412,7 @@ public class SyntaxTreeGenerator{
|
||||
|
||||
List<RefType> extendedInterfaces = convert(ctx.extendsInterfaces(), generics);
|
||||
|
||||
return new ClassOrInterface(modifiers, name, fields, Optional.empty(), methods, new ArrayList<>(),
|
||||
return new ClassOrInterface(modifiers, name, fields, methods, new ArrayList<>(),
|
||||
genericParams, superClass, true, extendedInterfaces, ctx.getStart());
|
||||
}
|
||||
|
@ -3,37 +3,31 @@ package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.exceptions.TypeinferenceException;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||
import de.dhbwstuttgart.parser.antlr.Java8Parser.UnannClassType_lfno_unannClassOrInterfaceTypeContext;
|
||||
import de.dhbwstuttgart.parser.scope.GenericsRegistry;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassRegistry;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
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 org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TypeGenerator {
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.UnannClassOrInterfaceTypeContext unannClassOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
||||
Java8Parser.TypeArgumentsContext arguments=null;
|
||||
/* PL 2019-03-19 auskommentiert ANFANG
|
||||
Java8Parser.TypeArgumentsContext arguments;
|
||||
if(unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType() != null){
|
||||
arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||
}else{// if(unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType() != null){
|
||||
arguments = unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||
}
|
||||
PL 2019-03-19 auskommentiert ENDE */
|
||||
/**
|
||||
* Problem sind hier die verschachtelten Typen mit verschachtelten Typargumenten
|
||||
* Beispiel: Typ<String>.InnererTyp<Integer>
|
||||
@ -41,28 +35,6 @@ public class TypeGenerator {
|
||||
String name = unannClassOrInterfaceTypeContext.getText();
|
||||
if(name.contains("<")){
|
||||
name = name.split("<")[0]; //Der Typ ist alles vor den ersten Argumenten
|
||||
/* Fuer Debug-Zwecke
|
||||
unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType();
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().getText();
|
||||
//unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||
//UnannClassType_lfno_unannClassOrInterfaceTypeContext
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(0);
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(0).getText();
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(1);
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(1).getText();
|
||||
unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().getText();
|
||||
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType();
|
||||
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType(0).getText();
|
||||
//unannClassOrInterfaceTypeContext.unannInterfaceType_lf_unannClassOrInterfaceType(1).getText();
|
||||
//unannClassOrInterfaceTypeContext.unannInterfaceType_lfno_unannClassOrInterfaceType().getText();
|
||||
*/
|
||||
int lastElement = new ArrayList<>(unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType()).size()-1;
|
||||
if (lastElement >=0) {//qualifizierter Name z.B.: java.util.Vector
|
||||
arguments = unannClassOrInterfaceTypeContext.unannClassType_lf_unannClassOrInterfaceType(lastElement).typeArguments();
|
||||
}
|
||||
else { //unqualifizierter Name z.B.: Vector
|
||||
arguments = unannClassOrInterfaceTypeContext.unannClassType_lfno_unannClassOrInterfaceType().typeArguments();
|
||||
}
|
||||
}
|
||||
return convertTypeName(name, arguments, unannClassOrInterfaceTypeContext.getStart(), reg, generics);
|
||||
}
|
||||
@ -132,17 +104,7 @@ public class TypeGenerator {
|
||||
|
||||
private static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.ClassOrInterfaceTypeContext classOrInterfaceTypeContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
||||
Java8Parser.ClassType_lfno_classOrInterfaceTypeContext ctx = classOrInterfaceTypeContext.classType_lfno_classOrInterfaceType();
|
||||
if(ctx.typeArguments() != null &&
|
||||
classOrInterfaceTypeContext.classType_lf_classOrInterfaceType().size() > 0)
|
||||
throw new NotImplementedException();
|
||||
String typeName = ctx.Identifier().toString();
|
||||
Java8Parser.ClassType_lf_classOrInterfaceTypeContext nextCtx = null;
|
||||
for(Java8Parser.ClassType_lf_classOrInterfaceTypeContext forEachCtx : classOrInterfaceTypeContext.classType_lf_classOrInterfaceType()){
|
||||
nextCtx = forEachCtx;
|
||||
typeName += "." + forEachCtx.Identifier().toString();
|
||||
}
|
||||
Java8Parser.TypeArgumentsContext arguments = nextCtx!=null?nextCtx.typeArguments():ctx.typeArguments();
|
||||
return convertTypeName(typeName, arguments, classOrInterfaceTypeContext.getStart(), reg, generics);
|
||||
return convertTypeName(ctx.Identifier().toString(), ctx.typeArguments(),classOrInterfaceTypeContext.getStart(), reg, generics);
|
||||
}
|
||||
|
||||
private static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.InterfaceTypeContext interfaceTypeContext) {
|
||||
@ -160,18 +122,6 @@ public class TypeGenerator {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric convert(Java8Parser.WildcardContext wildcardContext, JavaClassRegistry reg, GenericsRegistry generics) {
|
||||
if(wildcardContext.wildcardBounds() != null){
|
||||
if(wildcardContext.wildcardBounds().getText().substring(0, 7).equals("extends")){
|
||||
return new ExtendsWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart());
|
||||
}else{
|
||||
return new SuperWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart());
|
||||
}
|
||||
}else{
|
||||
throw new NotImplementedException(); //Wildcard ohne Bound
|
||||
}
|
||||
}
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric convertTypeName(String name, Token offset, JavaClassRegistry reg, GenericsRegistry generics){
|
||||
return convertTypeName(name, null, offset, reg, generics);
|
||||
@ -179,17 +129,12 @@ public class TypeGenerator {
|
||||
|
||||
public static RefTypeOrTPHOrWildcardOrGeneric convertTypeName(
|
||||
String name, Java8Parser.TypeArgumentsContext typeArguments, Token offset, JavaClassRegistry reg, GenericsRegistry generics){
|
||||
if(!reg.contains(name)){ //Dann könnte es ein generischer Type oder ein FunN$$-Type sein
|
||||
if(!reg.contains(name)){ //Dann könnte es ein Generische Type sein
|
||||
if(generics.contains(name)){
|
||||
return new GenericRefType(name, offset);
|
||||
}else{
|
||||
Pattern p = Pattern.compile("Fun(\\d+)[$][$]");
|
||||
Matcher m = p.matcher(name);
|
||||
if (m.matches()) {//es ist FunN$$-Type
|
||||
return new RefType(new JavaClassName(name), convert(typeArguments, reg, generics), offset);
|
||||
} else {
|
||||
throw new TypeinferenceException("Der Typ "+ name + " ist nicht vorhanden",offset);
|
||||
}}
|
||||
}
|
||||
}
|
||||
if(typeArguments == null){
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
@ -207,7 +152,7 @@ public class TypeGenerator {
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> ret = new ArrayList<>();
|
||||
for(Java8Parser.TypeArgumentContext arg : typeArguments.typeArgumentList().typeArgument()){
|
||||
if(arg.wildcard() != null){
|
||||
ret.add(convert(arg.wildcard(), reg, generics));
|
||||
throw new NotImplementedException();
|
||||
}else{
|
||||
ret.add(convert(arg.referenceType(), reg, generics));
|
||||
}
|
@ -109,6 +109,7 @@ classOrInterfaceType
|
||||
| interfaceType_lfno_classOrInterfaceType
|
||||
)
|
||||
( classType_lf_classOrInterfaceType
|
||||
| interfaceType_lf_classOrInterfaceType
|
||||
)*
|
||||
;
|
||||
|
||||
@ -332,7 +333,7 @@ classMemberDeclaration
|
||||
;
|
||||
|
||||
fieldDeclaration
|
||||
: fieldModifier* unannTypeOrAuto? variableDeclaratorList ';'
|
||||
: fieldModifier* unannType? variableDeclaratorList ';'
|
||||
;
|
||||
|
||||
fieldModifier
|
||||
@ -731,7 +732,6 @@ localVariableDeclarationStatement
|
||||
|
||||
unannTypeOrAuto
|
||||
: unannType
|
||||
| 'var'
|
||||
;
|
||||
|
||||
localVariableDeclaration
|
205
src/de/dhbwstuttgart/parser/antlr/Java8.tokens
Normal file
205
src/de/dhbwstuttgart/parser/antlr/Java8.tokens
Normal file
@ -0,0 +1,205 @@
|
||||
ABSTRACT=1
|
||||
ASSERT=2
|
||||
BOOLEAN=3
|
||||
BREAK=4
|
||||
BYTE=5
|
||||
CASE=6
|
||||
CATCH=7
|
||||
CHAR=8
|
||||
CLASS=9
|
||||
CONST=10
|
||||
CONTINUE=11
|
||||
DEFAULT=12
|
||||
DO=13
|
||||
DOUBLE=14
|
||||
ELSE=15
|
||||
ENUM=16
|
||||
EXTENDS=17
|
||||
FINAL=18
|
||||
FINALLY=19
|
||||
FLOAT=20
|
||||
FOR=21
|
||||
IF=22
|
||||
GOTO=23
|
||||
IMPLEMENTS=24
|
||||
IMPORT=25
|
||||
INSTANCEOF=26
|
||||
INT=27
|
||||
INTERFACE=28
|
||||
LONG=29
|
||||
NATIVE=30
|
||||
NEW=31
|
||||
PACKAGE=32
|
||||
PRIVATE=33
|
||||
PROTECTED=34
|
||||
PUBLIC=35
|
||||
RETURN=36
|
||||
SHORT=37
|
||||
STATIC=38
|
||||
STRICTFP=39
|
||||
SUPER=40
|
||||
SWITCH=41
|
||||
SYNCHRONIZED=42
|
||||
THIS=43
|
||||
THROW=44
|
||||
THROWS=45
|
||||
TRANSIENT=46
|
||||
TRY=47
|
||||
VOID=48
|
||||
VOLATILE=49
|
||||
WHILE=50
|
||||
IntegerLiteral=51
|
||||
FloatingPointLiteral=52
|
||||
BooleanLiteral=53
|
||||
CharacterLiteral=54
|
||||
StringLiteral=55
|
||||
NullLiteral=56
|
||||
LPAREN=57
|
||||
RPAREN=58
|
||||
LBRACE=59
|
||||
RBRACE=60
|
||||
LBRACK=61
|
||||
RBRACK=62
|
||||
SEMI=63
|
||||
COMMA=64
|
||||
DOT=65
|
||||
ASSIGN=66
|
||||
GT=67
|
||||
LT=68
|
||||
BANG=69
|
||||
TILDE=70
|
||||
QUESTION=71
|
||||
COLON=72
|
||||
EQUAL=73
|
||||
LE=74
|
||||
GE=75
|
||||
NOTEQUAL=76
|
||||
AND=77
|
||||
OR=78
|
||||
INC=79
|
||||
DEC=80
|
||||
ADD=81
|
||||
SUB=82
|
||||
MUL=83
|
||||
DIV=84
|
||||
BITAND=85
|
||||
BITOR=86
|
||||
CARET=87
|
||||
MOD=88
|
||||
ARROW=89
|
||||
COLONCOLON=90
|
||||
ADD_ASSIGN=91
|
||||
SUB_ASSIGN=92
|
||||
MUL_ASSIGN=93
|
||||
DIV_ASSIGN=94
|
||||
AND_ASSIGN=95
|
||||
OR_ASSIGN=96
|
||||
XOR_ASSIGN=97
|
||||
MOD_ASSIGN=98
|
||||
LSHIFT_ASSIGN=99
|
||||
RSHIFT_ASSIGN=100
|
||||
URSHIFT_ASSIGN=101
|
||||
Identifier=102
|
||||
AT=103
|
||||
ELLIPSIS=104
|
||||
WS=105
|
||||
COMMENT=106
|
||||
LINE_COMMENT=107
|
||||
'abstract'=1
|
||||
'assert'=2
|
||||
'boolean'=3
|
||||
'break'=4
|
||||
'byte'=5
|
||||
'case'=6
|
||||
'catch'=7
|
||||
'char'=8
|
||||
'class'=9
|
||||
'const'=10
|
||||
'continue'=11
|
||||
'default'=12
|
||||
'do'=13
|
||||
'double'=14
|
||||
'else'=15
|
||||
'enum'=16
|
||||
'extends'=17
|
||||
'final'=18
|
||||
'finally'=19
|
||||
'float'=20
|
||||
'for'=21
|
||||
'if'=22
|
||||
'goto'=23
|
||||
'implements'=24
|
||||
'import'=25
|
||||
'instanceof'=26
|
||||
'int'=27
|
||||
'interface'=28
|
||||
'long'=29
|
||||
'native'=30
|
||||
'new'=31
|
||||
'package'=32
|
||||
'private'=33
|
||||
'protected'=34
|
||||
'public'=35
|
||||
'return'=36
|
||||
'short'=37
|
||||
'static'=38
|
||||
'strictfp'=39
|
||||
'super'=40
|
||||
'switch'=41
|
||||
'synchronized'=42
|
||||
'this'=43
|
||||
'throw'=44
|
||||
'throws'=45
|
||||
'transient'=46
|
||||
'try'=47
|
||||
'void'=48
|
||||
'volatile'=49
|
||||
'while'=50
|
||||
'null'=56
|
||||
'('=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
|
||||
'@'=103
|
||||
'...'=104
|
2895
src/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java
Normal file
2895
src/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java
Normal file
File diff suppressed because it is too large
Load Diff
591
src/de/dhbwstuttgart/parser/antlr/Java8Lexer.java
Normal file
591
src/de/dhbwstuttgart/parser/antlr/Java8Lexer.java
Normal file
@ -0,0 +1,591 @@
|
||||
// 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
|
||||
ABSTRACT=1, ASSERT=2, BOOLEAN=3, BREAK=4, BYTE=5, CASE=6, CATCH=7, CHAR=8,
|
||||
CLASS=9, CONST=10, CONTINUE=11, DEFAULT=12, DO=13, DOUBLE=14, ELSE=15,
|
||||
ENUM=16, EXTENDS=17, FINAL=18, FINALLY=19, FLOAT=20, FOR=21, IF=22, GOTO=23,
|
||||
IMPLEMENTS=24, IMPORT=25, INSTANCEOF=26, INT=27, INTERFACE=28, LONG=29,
|
||||
NATIVE=30, NEW=31, PACKAGE=32, PRIVATE=33, PROTECTED=34, PUBLIC=35, RETURN=36,
|
||||
SHORT=37, STATIC=38, STRICTFP=39, SUPER=40, SWITCH=41, SYNCHRONIZED=42,
|
||||
THIS=43, THROW=44, THROWS=45, TRANSIENT=46, TRY=47, VOID=48, VOLATILE=49,
|
||||
WHILE=50, IntegerLiteral=51, FloatingPointLiteral=52, BooleanLiteral=53,
|
||||
CharacterLiteral=54, StringLiteral=55, NullLiteral=56, LPAREN=57, RPAREN=58,
|
||||
LBRACE=59, RBRACE=60, LBRACK=61, RBRACK=62, SEMI=63, COMMA=64, DOT=65,
|
||||
ASSIGN=66, GT=67, LT=68, BANG=69, TILDE=70, QUESTION=71, COLON=72, EQUAL=73,
|
||||
LE=74, GE=75, NOTEQUAL=76, AND=77, OR=78, INC=79, DEC=80, ADD=81, SUB=82,
|
||||
MUL=83, DIV=84, BITAND=85, BITOR=86, CARET=87, MOD=88, ARROW=89, COLONCOLON=90,
|
||||
ADD_ASSIGN=91, SUB_ASSIGN=92, MUL_ASSIGN=93, DIV_ASSIGN=94, AND_ASSIGN=95,
|
||||
OR_ASSIGN=96, XOR_ASSIGN=97, MOD_ASSIGN=98, LSHIFT_ASSIGN=99, RSHIFT_ASSIGN=100,
|
||||
URSHIFT_ASSIGN=101, Identifier=102, AT=103, ELLIPSIS=104, WS=105, COMMENT=106,
|
||||
LINE_COMMENT=107;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
public static final String[] ruleNames = {
|
||||
"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, "'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, "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 146:
|
||||
return JavaLetter_sempred((RuleContext)_localctx, predIndex);
|
||||
case 147:
|
||||
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\2m\u0448\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\3\2\3\2\3\2\3"+
|
||||
"\2\3\2\3\2\3\2\3\2\3\2\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\4\3\5\3\5\3\5\3\5\3\5\3\5\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\b\3\t\3\t\3\t\3\t\3\t\3\n\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\f\3\f\3\f"+
|
||||
"\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3"+
|
||||
"\17\3\17\3\17\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\22\3\22\3\22\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\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3"+
|
||||
"\26\3\26\3\26\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3"+
|
||||
"\31\3\31\3\31\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\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3"+
|
||||
"\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3"+
|
||||
"\36\3\36\3\36\3\37\3\37\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"+
|
||||
"/\3/\3/\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3"+
|
||||
"\62\3\62\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\63\3\64\3\64\3"+
|
||||
"\64\3\64\5\64\u028d\n\64\3\65\3\65\5\65\u0291\n\65\3\66\3\66\5\66\u0295"+
|
||||
"\n\66\3\67\3\67\5\67\u0299\n\67\38\38\58\u029d\n8\39\39\3:\3:\3:\5:\u02a4"+
|
||||
"\n:\3:\3:\3:\5:\u02a9\n:\5:\u02ab\n:\3;\3;\5;\u02af\n;\3;\5;\u02b2\n;"+
|
||||
"\3<\3<\5<\u02b6\n<\3=\3=\3>\6>\u02bb\n>\r>\16>\u02bc\3?\3?\5?\u02c1\n"+
|
||||
"?\3@\6@\u02c4\n@\r@\16@\u02c5\3A\3A\3A\3A\3B\3B\5B\u02ce\nB\3B\5B\u02d1"+
|
||||
"\nB\3C\3C\3D\6D\u02d6\nD\rD\16D\u02d7\3E\3E\5E\u02dc\nE\3F\3F\5F\u02e0"+
|
||||
"\nF\3F\3F\3G\3G\5G\u02e6\nG\3G\5G\u02e9\nG\3H\3H\3I\6I\u02ee\nI\rI\16"+
|
||||
"I\u02ef\3J\3J\5J\u02f4\nJ\3K\3K\3K\3K\3L\3L\5L\u02fc\nL\3L\5L\u02ff\n"+
|
||||
"L\3M\3M\3N\6N\u0304\nN\rN\16N\u0305\3O\3O\5O\u030a\nO\3P\3P\5P\u030e\n"+
|
||||
"P\3Q\3Q\3Q\5Q\u0313\nQ\3Q\5Q\u0316\nQ\3Q\5Q\u0319\nQ\3Q\3Q\3Q\5Q\u031e"+
|
||||
"\nQ\3Q\5Q\u0321\nQ\3Q\3Q\3Q\5Q\u0326\nQ\3Q\3Q\3Q\5Q\u032b\nQ\3R\3R\3R"+
|
||||
"\3S\3S\3T\5T\u0333\nT\3T\3T\3U\3U\3V\3V\3W\3W\3W\5W\u033e\nW\3X\3X\5X"+
|
||||
"\u0342\nX\3X\3X\3X\5X\u0347\nX\3X\3X\5X\u034b\nX\3Y\3Y\3Y\3Z\3Z\3[\3["+
|
||||
"\3[\3[\3[\3[\3[\3[\3[\5[\u035b\n[\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3\\\5\\"+
|
||||
"\u0365\n\\\3]\3]\3^\3^\5^\u036b\n^\3^\3^\3_\6_\u0370\n_\r_\16_\u0371\3"+
|
||||
"`\3`\5`\u0376\n`\3a\3a\3a\3a\5a\u037c\na\3b\3b\3b\3b\3b\3b\3b\3b\3b\3"+
|
||||
"b\3b\5b\u0389\nb\3c\3c\3d\3d\3d\3d\3d\3d\3d\3e\3e\3e\3e\3e\3f\3f\3g\3"+
|
||||
"g\3h\3h\3i\3i\3j\3j\3k\3k\3l\3l\3m\3m\3n\3n\3o\3o\3p\3p\3q\3q\3r\3r\3"+
|
||||
"s\3s\3t\3t\3u\3u\3v\3v\3v\3w\3w\3w\3x\3x\3x\3y\3y\3y\3z\3z\3z\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\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\u0090\3\u0091\3\u0091\3\u0091"+
|
||||
"\3\u0091\3\u0092\3\u0092\3\u0092\3\u0092\3\u0092\3\u0093\3\u0093\7\u0093"+
|
||||
"\u040e\n\u0093\f\u0093\16\u0093\u0411\13\u0093\3\u0094\3\u0094\3\u0094"+
|
||||
"\3\u0094\3\u0094\3\u0094\5\u0094\u0419\n\u0094\3\u0095\3\u0095\3\u0095"+
|
||||
"\3\u0095\3\u0095\3\u0095\5\u0095\u0421\n\u0095\3\u0096\3\u0096\3\u0097"+
|
||||
"\3\u0097\3\u0097\3\u0097\3\u0098\6\u0098\u042a\n\u0098\r\u0098\16\u0098"+
|
||||
"\u042b\3\u0098\3\u0098\3\u0099\3\u0099\3\u0099\3\u0099\7\u0099\u0434\n"+
|
||||
"\u0099\f\u0099\16\u0099\u0437\13\u0099\3\u0099\3\u0099\3\u0099\3\u0099"+
|
||||
"\3\u0099\3\u009a\3\u009a\3\u009a\3\u009a\7\u009a\u0442\n\u009a\f\u009a"+
|
||||
"\16\u009a\u0445\13\u009a\3\u009a\3\u009a\3\u0435\2\u009b\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\62c\63e\64g\65i\2k\2m\2o\2q\2s\2u\2w\2"+
|
||||
"y\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"+
|
||||
"\66\u00a1\2\u00a3\2\u00a5\2\u00a7\2\u00a9\2\u00ab\2\u00ad\2\u00af\2\u00b1"+
|
||||
"\2\u00b3\2\u00b5\67\u00b78\u00b9\2\u00bb9\u00bd\2\u00bf\2\u00c1\2\u00c3"+
|
||||
"\2\u00c5\2\u00c7\2\u00c9:\u00cb;\u00cd<\u00cf=\u00d1>\u00d3?\u00d5@\u00d7"+
|
||||
"A\u00d9B\u00dbC\u00ddD\u00dfE\u00e1F\u00e3G\u00e5H\u00e7I\u00e9J\u00eb"+
|
||||
"K\u00edL\u00efM\u00f1N\u00f3O\u00f5P\u00f7Q\u00f9R\u00fbS\u00fdT\u00ff"+
|
||||
"U\u0101V\u0103W\u0105X\u0107Y\u0109Z\u010b[\u010d\\\u010f]\u0111^\u0113"+
|
||||
"_\u0115`\u0117a\u0119b\u011bc\u011dd\u011fe\u0121f\u0123g\u0125h\u0127"+
|
||||
"\2\u0129\2\u012bi\u012dj\u012fk\u0131l\u0133m\3\2\30\4\2NNnn\3\2\63;\4"+
|
||||
"\2ZZzz\5\2\62;CHch\3\2\629\4\2DDdd\3\2\62\63\4\2GGgg\4\2--//\6\2FFHHf"+
|
||||
"fhh\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\u0456\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\2\u009f\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2\2\2\u00bb"+
|
||||
"\3\2\2\2\2\u00c9\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\u012b\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\3\u0135\3\2\2\2\5\u013e"+
|
||||
"\3\2\2\2\7\u0145\3\2\2\2\t\u014d\3\2\2\2\13\u0153\3\2\2\2\r\u0158\3\2"+
|
||||
"\2\2\17\u015d\3\2\2\2\21\u0163\3\2\2\2\23\u0168\3\2\2\2\25\u016e\3\2\2"+
|
||||
"\2\27\u0174\3\2\2\2\31\u017d\3\2\2\2\33\u0185\3\2\2\2\35\u0188\3\2\2\2"+
|
||||
"\37\u018f\3\2\2\2!\u0194\3\2\2\2#\u0199\3\2\2\2%\u01a1\3\2\2\2\'\u01a7"+
|
||||
"\3\2\2\2)\u01af\3\2\2\2+\u01b5\3\2\2\2-\u01b9\3\2\2\2/\u01bc\3\2\2\2\61"+
|
||||
"\u01c1\3\2\2\2\63\u01cc\3\2\2\2\65\u01d3\3\2\2\2\67\u01de\3\2\2\29\u01e2"+
|
||||
"\3\2\2\2;\u01ec\3\2\2\2=\u01f1\3\2\2\2?\u01f8\3\2\2\2A\u01fc\3\2\2\2C"+
|
||||
"\u0204\3\2\2\2E\u020c\3\2\2\2G\u0216\3\2\2\2I\u021d\3\2\2\2K\u0224\3\2"+
|
||||
"\2\2M\u022a\3\2\2\2O\u0231\3\2\2\2Q\u023a\3\2\2\2S\u0240\3\2\2\2U\u0247"+
|
||||
"\3\2\2\2W\u0254\3\2\2\2Y\u0259\3\2\2\2[\u025f\3\2\2\2]\u0266\3\2\2\2_"+
|
||||
"\u0270\3\2\2\2a\u0274\3\2\2\2c\u0279\3\2\2\2e\u0282\3\2\2\2g\u028c\3\2"+
|
||||
"\2\2i\u028e\3\2\2\2k\u0292\3\2\2\2m\u0296\3\2\2\2o\u029a\3\2\2\2q\u029e"+
|
||||
"\3\2\2\2s\u02aa\3\2\2\2u\u02ac\3\2\2\2w\u02b5\3\2\2\2y\u02b7\3\2\2\2{"+
|
||||
"\u02ba\3\2\2\2}\u02c0\3\2\2\2\177\u02c3\3\2\2\2\u0081\u02c7\3\2\2\2\u0083"+
|
||||
"\u02cb\3\2\2\2\u0085\u02d2\3\2\2\2\u0087\u02d5\3\2\2\2\u0089\u02db\3\2"+
|
||||
"\2\2\u008b\u02dd\3\2\2\2\u008d\u02e3\3\2\2\2\u008f\u02ea\3\2\2\2\u0091"+
|
||||
"\u02ed\3\2\2\2\u0093\u02f3\3\2\2\2\u0095\u02f5\3\2\2\2\u0097\u02f9\3\2"+
|
||||
"\2\2\u0099\u0300\3\2\2\2\u009b\u0303\3\2\2\2\u009d\u0309\3\2\2\2\u009f"+
|
||||
"\u030d\3\2\2\2\u00a1\u032a\3\2\2\2\u00a3\u032c\3\2\2\2\u00a5\u032f\3\2"+
|
||||
"\2\2\u00a7\u0332\3\2\2\2\u00a9\u0336\3\2\2\2\u00ab\u0338\3\2\2\2\u00ad"+
|
||||
"\u033a\3\2\2\2\u00af\u034a\3\2\2\2\u00b1\u034c\3\2\2\2\u00b3\u034f\3\2"+
|
||||
"\2\2\u00b5\u035a\3\2\2\2\u00b7\u0364\3\2\2\2\u00b9\u0366\3\2\2\2\u00bb"+
|
||||
"\u0368\3\2\2\2\u00bd\u036f\3\2\2\2\u00bf\u0375\3\2\2\2\u00c1\u037b\3\2"+
|
||||
"\2\2\u00c3\u0388\3\2\2\2\u00c5\u038a\3\2\2\2\u00c7\u038c\3\2\2\2\u00c9"+
|
||||
"\u0393\3\2\2\2\u00cb\u0398\3\2\2\2\u00cd\u039a\3\2\2\2\u00cf\u039c\3\2"+
|
||||
"\2\2\u00d1\u039e\3\2\2\2\u00d3\u03a0\3\2\2\2\u00d5\u03a2\3\2\2\2\u00d7"+
|
||||
"\u03a4\3\2\2\2\u00d9\u03a6\3\2\2\2\u00db\u03a8\3\2\2\2\u00dd\u03aa\3\2"+
|
||||
"\2\2\u00df\u03ac\3\2\2\2\u00e1\u03ae\3\2\2\2\u00e3\u03b0\3\2\2\2\u00e5"+
|
||||
"\u03b2\3\2\2\2\u00e7\u03b4\3\2\2\2\u00e9\u03b6\3\2\2\2\u00eb\u03b8\3\2"+
|
||||
"\2\2\u00ed\u03bb\3\2\2\2\u00ef\u03be\3\2\2\2\u00f1\u03c1\3\2\2\2\u00f3"+
|
||||
"\u03c4\3\2\2\2\u00f5\u03c7\3\2\2\2\u00f7\u03ca\3\2\2\2\u00f9\u03cd\3\2"+
|
||||
"\2\2\u00fb\u03d0\3\2\2\2\u00fd\u03d2\3\2\2\2\u00ff\u03d4\3\2\2\2\u0101"+
|
||||
"\u03d6\3\2\2\2\u0103\u03d8\3\2\2\2\u0105\u03da\3\2\2\2\u0107\u03dc\3\2"+
|
||||
"\2\2\u0109\u03de\3\2\2\2\u010b\u03e0\3\2\2\2\u010d\u03e3\3\2\2\2\u010f"+
|
||||
"\u03e6\3\2\2\2\u0111\u03e9\3\2\2\2\u0113\u03ec\3\2\2\2\u0115\u03ef\3\2"+
|
||||
"\2\2\u0117\u03f2\3\2\2\2\u0119\u03f5\3\2\2\2\u011b\u03f8\3\2\2\2\u011d"+
|
||||
"\u03fb\3\2\2\2\u011f\u03fe\3\2\2\2\u0121\u0402\3\2\2\2\u0123\u0406\3\2"+
|
||||
"\2\2\u0125\u040b\3\2\2\2\u0127\u0418\3\2\2\2\u0129\u0420\3\2\2\2\u012b"+
|
||||
"\u0422\3\2\2\2\u012d\u0424\3\2\2\2\u012f\u0429\3\2\2\2\u0131\u042f\3\2"+
|
||||
"\2\2\u0133\u043d\3\2\2\2\u0135\u0136\7c\2\2\u0136\u0137\7d\2\2\u0137\u0138"+
|
||||
"\7u\2\2\u0138\u0139\7v\2\2\u0139\u013a\7t\2\2\u013a\u013b\7c\2\2\u013b"+
|
||||
"\u013c\7e\2\2\u013c\u013d\7v\2\2\u013d\4\3\2\2\2\u013e\u013f\7c\2\2\u013f"+
|
||||
"\u0140\7u\2\2\u0140\u0141\7u\2\2\u0141\u0142\7g\2\2\u0142\u0143\7t\2\2"+
|
||||
"\u0143\u0144\7v\2\2\u0144\6\3\2\2\2\u0145\u0146\7d\2\2\u0146\u0147\7q"+
|
||||
"\2\2\u0147\u0148\7q\2\2\u0148\u0149\7n\2\2\u0149\u014a\7g\2\2\u014a\u014b"+
|
||||
"\7c\2\2\u014b\u014c\7p\2\2\u014c\b\3\2\2\2\u014d\u014e\7d\2\2\u014e\u014f"+
|
||||
"\7t\2\2\u014f\u0150\7g\2\2\u0150\u0151\7c\2\2\u0151\u0152\7m\2\2\u0152"+
|
||||
"\n\3\2\2\2\u0153\u0154\7d\2\2\u0154\u0155\7{\2\2\u0155\u0156\7v\2\2\u0156"+
|
||||
"\u0157\7g\2\2\u0157\f\3\2\2\2\u0158\u0159\7e\2\2\u0159\u015a\7c\2\2\u015a"+
|
||||
"\u015b\7u\2\2\u015b\u015c\7g\2\2\u015c\16\3\2\2\2\u015d\u015e\7e\2\2\u015e"+
|
||||
"\u015f\7c\2\2\u015f\u0160\7v\2\2\u0160\u0161\7e\2\2\u0161\u0162\7j\2\2"+
|
||||
"\u0162\20\3\2\2\2\u0163\u0164\7e\2\2\u0164\u0165\7j\2\2\u0165\u0166\7"+
|
||||
"c\2\2\u0166\u0167\7t\2\2\u0167\22\3\2\2\2\u0168\u0169\7e\2\2\u0169\u016a"+
|
||||
"\7n\2\2\u016a\u016b\7c\2\2\u016b\u016c\7u\2\2\u016c\u016d\7u\2\2\u016d"+
|
||||
"\24\3\2\2\2\u016e\u016f\7e\2\2\u016f\u0170\7q\2\2\u0170\u0171\7p\2\2\u0171"+
|
||||
"\u0172\7u\2\2\u0172\u0173\7v\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\7v\2\2\u0178\u0179\7k\2\2"+
|
||||
"\u0179\u017a\7p\2\2\u017a\u017b\7w\2\2\u017b\u017c\7g\2\2\u017c\30\3\2"+
|
||||
"\2\2\u017d\u017e\7f\2\2\u017e\u017f\7g\2\2\u017f\u0180\7h\2\2\u0180\u0181"+
|
||||
"\7c\2\2\u0181\u0182\7w\2\2\u0182\u0183\7n\2\2\u0183\u0184\7v\2\2\u0184"+
|
||||
"\32\3\2\2\2\u0185\u0186\7f\2\2\u0186\u0187\7q\2\2\u0187\34\3\2\2\2\u0188"+
|
||||
"\u0189\7f\2\2\u0189\u018a\7q\2\2\u018a\u018b\7w\2\2\u018b\u018c\7d\2\2"+
|
||||
"\u018c\u018d\7n\2\2\u018d\u018e\7g\2\2\u018e\36\3\2\2\2\u018f\u0190\7"+
|
||||
"g\2\2\u0190\u0191\7n\2\2\u0191\u0192\7u\2\2\u0192\u0193\7g\2\2\u0193 "+
|
||||
"\3\2\2\2\u0194\u0195\7g\2\2\u0195\u0196\7p\2\2\u0196\u0197\7w\2\2\u0197"+
|
||||
"\u0198\7o\2\2\u0198\"\3\2\2\2\u0199\u019a\7g\2\2\u019a\u019b\7z\2\2\u019b"+
|
||||
"\u019c\7v\2\2\u019c\u019d\7g\2\2\u019d\u019e\7p\2\2\u019e\u019f\7f\2\2"+
|
||||
"\u019f\u01a0\7u\2\2\u01a0$\3\2\2\2\u01a1\u01a2\7h\2\2\u01a2\u01a3\7k\2"+
|
||||
"\2\u01a3\u01a4\7p\2\2\u01a4\u01a5\7c\2\2\u01a5\u01a6\7n\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\u01ad\7n\2\2\u01ad\u01ae\7{\2\2\u01ae"+
|
||||
"(\3\2\2\2\u01af\u01b0\7h\2\2\u01b0\u01b1\7n\2\2\u01b1\u01b2\7q\2\2\u01b2"+
|
||||
"\u01b3\7c\2\2\u01b3\u01b4\7v\2\2\u01b4*\3\2\2\2\u01b5\u01b6\7h\2\2\u01b6"+
|
||||
"\u01b7\7q\2\2\u01b7\u01b8\7t\2\2\u01b8,\3\2\2\2\u01b9\u01ba\7k\2\2\u01ba"+
|
||||
"\u01bb\7h\2\2\u01bb.\3\2\2\2\u01bc\u01bd\7i\2\2\u01bd\u01be\7q\2\2\u01be"+
|
||||
"\u01bf\7v\2\2\u01bf\u01c0\7q\2\2\u01c0\60\3\2\2\2\u01c1\u01c2\7k\2\2\u01c2"+
|
||||
"\u01c3\7o\2\2\u01c3\u01c4\7r\2\2\u01c4\u01c5\7n\2\2\u01c5\u01c6\7g\2\2"+
|
||||
"\u01c6\u01c7\7o\2\2\u01c7\u01c8\7g\2\2\u01c8\u01c9\7p\2\2\u01c9\u01ca"+
|
||||
"\7v\2\2\u01ca\u01cb\7u\2\2\u01cb\62\3\2\2\2\u01cc\u01cd\7k\2\2\u01cd\u01ce"+
|
||||
"\7o\2\2\u01ce\u01cf\7r\2\2\u01cf\u01d0\7q\2\2\u01d0\u01d1\7t\2\2\u01d1"+
|
||||
"\u01d2\7v\2\2\u01d2\64\3\2\2\2\u01d3\u01d4\7k\2\2\u01d4\u01d5\7p\2\2\u01d5"+
|
||||
"\u01d6\7u\2\2\u01d6\u01d7\7v\2\2\u01d7\u01d8\7c\2\2\u01d8\u01d9\7p\2\2"+
|
||||
"\u01d9\u01da\7e\2\2\u01da\u01db\7g\2\2\u01db\u01dc\7q\2\2\u01dc\u01dd"+
|
||||
"\7h\2\2\u01dd\66\3\2\2\2\u01de\u01df\7k\2\2\u01df\u01e0\7p\2\2\u01e0\u01e1"+
|
||||
"\7v\2\2\u01e18\3\2\2\2\u01e2\u01e3\7k\2\2\u01e3\u01e4\7p\2\2\u01e4\u01e5"+
|
||||
"\7v\2\2\u01e5\u01e6\7g\2\2\u01e6\u01e7\7t\2\2\u01e7\u01e8\7h\2\2\u01e8"+
|
||||
"\u01e9\7c\2\2\u01e9\u01ea\7e\2\2\u01ea\u01eb\7g\2\2\u01eb:\3\2\2\2\u01ec"+
|
||||
"\u01ed\7n\2\2\u01ed\u01ee\7q\2\2\u01ee\u01ef\7p\2\2\u01ef\u01f0\7i\2\2"+
|
||||
"\u01f0<\3\2\2\2\u01f1\u01f2\7p\2\2\u01f2\u01f3\7c\2\2\u01f3\u01f4\7v\2"+
|
||||
"\2\u01f4\u01f5\7k\2\2\u01f5\u01f6\7x\2\2\u01f6\u01f7\7g\2\2\u01f7>\3\2"+
|
||||
"\2\2\u01f8\u01f9\7p\2\2\u01f9\u01fa\7g\2\2\u01fa\u01fb\7y\2\2\u01fb@\3"+
|
||||
"\2\2\2\u01fc\u01fd\7r\2\2\u01fd\u01fe\7c\2\2\u01fe\u01ff\7e\2\2\u01ff"+
|
||||
"\u0200\7m\2\2\u0200\u0201\7c\2\2\u0201\u0202\7i\2\2\u0202\u0203\7g\2\2"+
|
||||
"\u0203B\3\2\2\2\u0204\u0205\7r\2\2\u0205\u0206\7t\2\2\u0206\u0207\7k\2"+
|
||||
"\2\u0207\u0208\7x\2\2\u0208\u0209\7c\2\2\u0209\u020a\7v\2\2\u020a\u020b"+
|
||||
"\7g\2\2\u020bD\3\2\2\2\u020c\u020d\7r\2\2\u020d\u020e\7t\2\2\u020e\u020f"+
|
||||
"\7q\2\2\u020f\u0210\7v\2\2\u0210\u0211\7g\2\2\u0211\u0212\7e\2\2\u0212"+
|
||||
"\u0213\7v\2\2\u0213\u0214\7g\2\2\u0214\u0215\7f\2\2\u0215F\3\2\2\2\u0216"+
|
||||
"\u0217\7r\2\2\u0217\u0218\7w\2\2\u0218\u0219\7d\2\2\u0219\u021a\7n\2\2"+
|
||||
"\u021a\u021b\7k\2\2\u021b\u021c\7e\2\2\u021cH\3\2\2\2\u021d\u021e\7t\2"+
|
||||
"\2\u021e\u021f\7g\2\2\u021f\u0220\7v\2\2\u0220\u0221\7w\2\2\u0221\u0222"+
|
||||
"\7t\2\2\u0222\u0223\7p\2\2\u0223J\3\2\2\2\u0224\u0225\7u\2\2\u0225\u0226"+
|
||||
"\7j\2\2\u0226\u0227\7q\2\2\u0227\u0228\7t\2\2\u0228\u0229\7v\2\2\u0229"+
|
||||
"L\3\2\2\2\u022a\u022b\7u\2\2\u022b\u022c\7v\2\2\u022c\u022d\7c\2\2\u022d"+
|
||||
"\u022e\7v\2\2\u022e\u022f\7k\2\2\u022f\u0230\7e\2\2\u0230N\3\2\2\2\u0231"+
|
||||
"\u0232\7u\2\2\u0232\u0233\7v\2\2\u0233\u0234\7t\2\2\u0234\u0235\7k\2\2"+
|
||||
"\u0235\u0236\7e\2\2\u0236\u0237\7v\2\2\u0237\u0238\7h\2\2\u0238\u0239"+
|
||||
"\7r\2\2\u0239P\3\2\2\2\u023a\u023b\7u\2\2\u023b\u023c\7w\2\2\u023c\u023d"+
|
||||
"\7r\2\2\u023d\u023e\7g\2\2\u023e\u023f\7t\2\2\u023fR\3\2\2\2\u0240\u0241"+
|
||||
"\7u\2\2\u0241\u0242\7y\2\2\u0242\u0243\7k\2\2\u0243\u0244\7v\2\2\u0244"+
|
||||
"\u0245\7e\2\2\u0245\u0246\7j\2\2\u0246T\3\2\2\2\u0247\u0248\7u\2\2\u0248"+
|
||||
"\u0249\7{\2\2\u0249\u024a\7p\2\2\u024a\u024b\7e\2\2\u024b\u024c\7j\2\2"+
|
||||
"\u024c\u024d\7t\2\2\u024d\u024e\7q\2\2\u024e\u024f\7p\2\2\u024f\u0250"+
|
||||
"\7k\2\2\u0250\u0251\7|\2\2\u0251\u0252\7g\2\2\u0252\u0253\7f\2\2\u0253"+
|
||||
"V\3\2\2\2\u0254\u0255\7v\2\2\u0255\u0256\7j\2\2\u0256\u0257\7k\2\2\u0257"+
|
||||
"\u0258\7u\2\2\u0258X\3\2\2\2\u0259\u025a\7v\2\2\u025a\u025b\7j\2\2\u025b"+
|
||||
"\u025c\7t\2\2\u025c\u025d\7q\2\2\u025d\u025e\7y\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\u0265\7u\2\2\u0265\\\3\2\2\2\u0266\u0267\7v"+
|
||||
"\2\2\u0267\u0268\7t\2\2\u0268\u0269\7c\2\2\u0269\u026a\7p\2\2\u026a\u026b"+
|
||||
"\7u\2\2\u026b\u026c\7k\2\2\u026c\u026d\7g\2\2\u026d\u026e\7p\2\2\u026e"+
|
||||
"\u026f\7v\2\2\u026f^\3\2\2\2\u0270\u0271\7v\2\2\u0271\u0272\7t\2\2\u0272"+
|
||||
"\u0273\7{\2\2\u0273`\3\2\2\2\u0274\u0275\7x\2\2\u0275\u0276\7q\2\2\u0276"+
|
||||
"\u0277\7k\2\2\u0277\u0278\7f\2\2\u0278b\3\2\2\2\u0279\u027a\7x\2\2\u027a"+
|
||||
"\u027b\7q\2\2\u027b\u027c\7n\2\2\u027c\u027d\7c\2\2\u027d\u027e\7v\2\2"+
|
||||
"\u027e\u027f\7k\2\2\u027f\u0280\7n\2\2\u0280\u0281\7g\2\2\u0281d\3\2\2"+
|
||||
"\2\u0282\u0283\7y\2\2\u0283\u0284\7j\2\2\u0284\u0285\7k\2\2\u0285\u0286"+
|
||||
"\7n\2\2\u0286\u0287\7g\2\2\u0287f\3\2\2\2\u0288\u028d\5i\65\2\u0289\u028d"+
|
||||
"\5k\66\2\u028a\u028d\5m\67\2\u028b\u028d\5o8\2\u028c\u0288\3\2\2\2\u028c"+
|
||||
"\u0289\3\2\2\2\u028c\u028a\3\2\2\2\u028c\u028b\3\2\2\2\u028dh\3\2\2\2"+
|
||||
"\u028e\u0290\5s:\2\u028f\u0291\5q9\2\u0290\u028f\3\2\2\2\u0290\u0291\3"+
|
||||
"\2\2\2\u0291j\3\2\2\2\u0292\u0294\5\u0081A\2\u0293\u0295\5q9\2\u0294\u0293"+
|
||||
"\3\2\2\2\u0294\u0295\3\2\2\2\u0295l\3\2\2\2\u0296\u0298\5\u008bF\2\u0297"+
|
||||
"\u0299\5q9\2\u0298\u0297\3\2\2\2\u0298\u0299\3\2\2\2\u0299n\3\2\2\2\u029a"+
|
||||
"\u029c\5\u0095K\2\u029b\u029d\5q9\2\u029c\u029b\3\2\2\2\u029c\u029d\3"+
|
||||
"\2\2\2\u029dp\3\2\2\2\u029e\u029f\t\2\2\2\u029fr\3\2\2\2\u02a0\u02ab\7"+
|
||||
"\62\2\2\u02a1\u02a8\5y=\2\u02a2\u02a4\5u;\2\u02a3\u02a2\3\2\2\2\u02a3"+
|
||||
"\u02a4\3\2\2\2\u02a4\u02a9\3\2\2\2\u02a5\u02a6\5\177@\2\u02a6\u02a7\5"+
|
||||
"u;\2\u02a7\u02a9\3\2\2\2\u02a8\u02a3\3\2\2\2\u02a8\u02a5\3\2\2\2\u02a9"+
|
||||
"\u02ab\3\2\2\2\u02aa\u02a0\3\2\2\2\u02aa\u02a1\3\2\2\2\u02abt\3\2\2\2"+
|
||||
"\u02ac\u02b1\5w<\2\u02ad\u02af\5{>\2\u02ae\u02ad\3\2\2\2\u02ae\u02af\3"+
|
||||
"\2\2\2\u02af\u02b0\3\2\2\2\u02b0\u02b2\5w<\2\u02b1\u02ae\3\2\2\2\u02b1"+
|
||||
"\u02b2\3\2\2\2\u02b2v\3\2\2\2\u02b3\u02b6\7\62\2\2\u02b4\u02b6\5y=\2\u02b5"+
|
||||
"\u02b3\3\2\2\2\u02b5\u02b4\3\2\2\2\u02b6x\3\2\2\2\u02b7\u02b8\t\3\2\2"+
|
||||
"\u02b8z\3\2\2\2\u02b9\u02bb\5}?\2\u02ba\u02b9\3\2\2\2\u02bb\u02bc\3\2"+
|
||||
"\2\2\u02bc\u02ba\3\2\2\2\u02bc\u02bd\3\2\2\2\u02bd|\3\2\2\2\u02be\u02c1"+
|
||||
"\5w<\2\u02bf\u02c1\7a\2\2\u02c0\u02be\3\2\2\2\u02c0\u02bf\3\2\2\2\u02c1"+
|
||||
"~\3\2\2\2\u02c2\u02c4\7a\2\2\u02c3\u02c2\3\2\2\2\u02c4\u02c5\3\2\2\2\u02c5"+
|
||||
"\u02c3\3\2\2\2\u02c5\u02c6\3\2\2\2\u02c6\u0080\3\2\2\2\u02c7\u02c8\7\62"+
|
||||
"\2\2\u02c8\u02c9\t\4\2\2\u02c9\u02ca\5\u0083B\2\u02ca\u0082\3\2\2\2\u02cb"+
|
||||
"\u02d0\5\u0085C\2\u02cc\u02ce\5\u0087D\2\u02cd\u02cc\3\2\2\2\u02cd\u02ce"+
|
||||
"\3\2\2\2\u02ce\u02cf\3\2\2\2\u02cf\u02d1\5\u0085C\2\u02d0\u02cd\3\2\2"+
|
||||
"\2\u02d0\u02d1\3\2\2\2\u02d1\u0084\3\2\2\2\u02d2\u02d3\t\5\2\2\u02d3\u0086"+
|
||||
"\3\2\2\2\u02d4\u02d6\5\u0089E\2\u02d5\u02d4\3\2\2\2\u02d6\u02d7\3\2\2"+
|
||||
"\2\u02d7\u02d5\3\2\2\2\u02d7\u02d8\3\2\2\2\u02d8\u0088\3\2\2\2\u02d9\u02dc"+
|
||||
"\5\u0085C\2\u02da\u02dc\7a\2\2\u02db\u02d9\3\2\2\2\u02db\u02da\3\2\2\2"+
|
||||
"\u02dc\u008a\3\2\2\2\u02dd\u02df\7\62\2\2\u02de\u02e0\5\177@\2\u02df\u02de"+
|
||||
"\3\2\2\2\u02df\u02e0\3\2\2\2\u02e0\u02e1\3\2\2\2\u02e1\u02e2\5\u008dG"+
|
||||
"\2\u02e2\u008c\3\2\2\2\u02e3\u02e8\5\u008fH\2\u02e4\u02e6\5\u0091I\2\u02e5"+
|
||||
"\u02e4\3\2\2\2\u02e5\u02e6\3\2\2\2\u02e6\u02e7\3\2\2\2\u02e7\u02e9\5\u008f"+
|
||||
"H\2\u02e8\u02e5\3\2\2\2\u02e8\u02e9\3\2\2\2\u02e9\u008e\3\2\2\2\u02ea"+
|
||||
"\u02eb\t\6\2\2\u02eb\u0090\3\2\2\2\u02ec\u02ee\5\u0093J\2\u02ed\u02ec"+
|
||||
"\3\2\2\2\u02ee\u02ef\3\2\2\2\u02ef\u02ed\3\2\2\2\u02ef\u02f0\3\2\2\2\u02f0"+
|
||||
"\u0092\3\2\2\2\u02f1\u02f4\5\u008fH\2\u02f2\u02f4\7a\2\2\u02f3\u02f1\3"+
|
||||
"\2\2\2\u02f3\u02f2\3\2\2\2\u02f4\u0094\3\2\2\2\u02f5\u02f6\7\62\2\2\u02f6"+
|
||||
"\u02f7\t\7\2\2\u02f7\u02f8\5\u0097L\2\u02f8\u0096\3\2\2\2\u02f9\u02fe"+
|
||||
"\5\u0099M\2\u02fa\u02fc\5\u009bN\2\u02fb\u02fa\3\2\2\2\u02fb\u02fc\3\2"+
|
||||
"\2\2\u02fc\u02fd\3\2\2\2\u02fd\u02ff\5\u0099M\2\u02fe\u02fb\3\2\2\2\u02fe"+
|
||||
"\u02ff\3\2\2\2\u02ff\u0098\3\2\2\2\u0300\u0301\t\b\2\2\u0301\u009a\3\2"+
|
||||
"\2\2\u0302\u0304\5\u009dO\2\u0303\u0302\3\2\2\2\u0304\u0305\3\2\2\2\u0305"+
|
||||
"\u0303\3\2\2\2\u0305\u0306\3\2\2\2\u0306\u009c\3\2\2\2\u0307\u030a\5\u0099"+
|
||||
"M\2\u0308\u030a\7a\2\2\u0309\u0307\3\2\2\2\u0309\u0308\3\2\2\2\u030a\u009e"+
|
||||
"\3\2\2\2\u030b\u030e\5\u00a1Q\2\u030c\u030e\5\u00adW\2\u030d\u030b\3\2"+
|
||||
"\2\2\u030d\u030c\3\2\2\2\u030e\u00a0\3\2\2\2\u030f\u0310\5u;\2\u0310\u0312"+
|
||||
"\7\60\2\2\u0311\u0313\5u;\2\u0312\u0311\3\2\2\2\u0312\u0313\3\2\2\2\u0313"+
|
||||
"\u0315\3\2\2\2\u0314\u0316\5\u00a3R\2\u0315\u0314\3\2\2\2\u0315\u0316"+
|
||||
"\3\2\2\2\u0316\u0318\3\2\2\2\u0317\u0319\5\u00abV\2\u0318\u0317\3\2\2"+
|
||||
"\2\u0318\u0319\3\2\2\2\u0319\u032b\3\2\2\2\u031a\u031b\7\60\2\2\u031b"+
|
||||
"\u031d\5u;\2\u031c\u031e\5\u00a3R\2\u031d\u031c\3\2\2\2\u031d\u031e\3"+
|
||||
"\2\2\2\u031e\u0320\3\2\2\2\u031f\u0321\5\u00abV\2\u0320\u031f\3\2\2\2"+
|
||||
"\u0320\u0321\3\2\2\2\u0321\u032b\3\2\2\2\u0322\u0323\5u;\2\u0323\u0325"+
|
||||
"\5\u00a3R\2\u0324\u0326\5\u00abV\2\u0325\u0324\3\2\2\2\u0325\u0326\3\2"+
|
||||
"\2\2\u0326\u032b\3\2\2\2\u0327\u0328\5u;\2\u0328\u0329\5\u00abV\2\u0329"+
|
||||
"\u032b\3\2\2\2\u032a\u030f\3\2\2\2\u032a\u031a\3\2\2\2\u032a\u0322\3\2"+
|
||||
"\2\2\u032a\u0327\3\2\2\2\u032b\u00a2\3\2\2\2\u032c\u032d\5\u00a5S\2\u032d"+
|
||||
"\u032e\5\u00a7T\2\u032e\u00a4\3\2\2\2\u032f\u0330\t\t\2\2\u0330\u00a6"+
|
||||
"\3\2\2\2\u0331\u0333\5\u00a9U\2\u0332\u0331\3\2\2\2\u0332\u0333\3\2\2"+
|
||||
"\2\u0333\u0334\3\2\2\2\u0334\u0335\5u;\2\u0335\u00a8\3\2\2\2\u0336\u0337"+
|
||||
"\t\n\2\2\u0337\u00aa\3\2\2\2\u0338\u0339\t\13\2\2\u0339\u00ac\3\2\2\2"+
|
||||
"\u033a\u033b\5\u00afX\2\u033b\u033d\5\u00b1Y\2\u033c\u033e\5\u00abV\2"+
|
||||
"\u033d\u033c\3\2\2\2\u033d\u033e\3\2\2\2\u033e\u00ae\3\2\2\2\u033f\u0341"+
|
||||
"\5\u0081A\2\u0340\u0342\7\60\2\2\u0341\u0340\3\2\2\2\u0341\u0342\3\2\2"+
|
||||
"\2\u0342\u034b\3\2\2\2\u0343\u0344\7\62\2\2\u0344\u0346\t\4\2\2\u0345"+
|
||||
"\u0347\5\u0083B\2\u0346\u0345\3\2\2\2\u0346\u0347\3\2\2\2\u0347\u0348"+
|
||||
"\3\2\2\2\u0348\u0349\7\60\2\2\u0349\u034b\5\u0083B\2\u034a\u033f\3\2\2"+
|
||||
"\2\u034a\u0343\3\2\2\2\u034b\u00b0\3\2\2\2\u034c\u034d\5\u00b3Z\2\u034d"+
|
||||
"\u034e\5\u00a7T\2\u034e\u00b2\3\2\2\2\u034f\u0350\t\f\2\2\u0350\u00b4"+
|
||||
"\3\2\2\2\u0351\u0352\7v\2\2\u0352\u0353\7t\2\2\u0353\u0354\7w\2\2\u0354"+
|
||||
"\u035b\7g\2\2\u0355\u0356\7h\2\2\u0356\u0357\7c\2\2\u0357\u0358\7n\2\2"+
|
||||
"\u0358\u0359\7u\2\2\u0359\u035b\7g\2\2\u035a\u0351\3\2\2\2\u035a\u0355"+
|
||||
"\3\2\2\2\u035b\u00b6\3\2\2\2\u035c\u035d\7)\2\2\u035d\u035e\5\u00b9]\2"+
|
||||
"\u035e\u035f\7)\2\2\u035f\u0365\3\2\2\2\u0360\u0361\7)\2\2\u0361\u0362"+
|
||||
"\5\u00c1a\2\u0362\u0363\7)\2\2\u0363\u0365\3\2\2\2\u0364\u035c\3\2\2\2"+
|
||||
"\u0364\u0360\3\2\2\2\u0365\u00b8\3\2\2\2\u0366\u0367\n\r\2\2\u0367\u00ba"+
|
||||
"\3\2\2\2\u0368\u036a\7$\2\2\u0369\u036b\5\u00bd_\2\u036a\u0369\3\2\2\2"+
|
||||
"\u036a\u036b\3\2\2\2\u036b\u036c\3\2\2\2\u036c\u036d\7$\2\2\u036d\u00bc"+
|
||||
"\3\2\2\2\u036e\u0370\5\u00bf`\2\u036f\u036e\3\2\2\2\u0370\u0371\3\2\2"+
|
||||
"\2\u0371\u036f\3\2\2\2\u0371\u0372\3\2\2\2\u0372\u00be\3\2\2\2\u0373\u0376"+
|
||||
"\n\16\2\2\u0374\u0376\5\u00c1a\2\u0375\u0373\3\2\2\2\u0375\u0374\3\2\2"+
|
||||
"\2\u0376\u00c0\3\2\2\2\u0377\u0378\7^\2\2\u0378\u037c\t\17\2\2\u0379\u037c"+
|
||||
"\5\u00c3b\2\u037a\u037c\5\u00c7d\2\u037b\u0377\3\2\2\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"+
|
||||
"\u0389\5\u008fH\2\u037f\u0380\7^\2\2\u0380\u0381\5\u008fH\2\u0381\u0382"+
|
||||
"\5\u008fH\2\u0382\u0389\3\2\2\2\u0383\u0384\7^\2\2\u0384\u0385\5\u00c5"+
|
||||
"c\2\u0385\u0386\5\u008fH\2\u0386\u0387\5\u008fH\2\u0387\u0389\3\2\2\2"+
|
||||
"\u0388\u037d\3\2\2\2\u0388\u037f\3\2\2\2\u0388\u0383\3\2\2\2\u0389\u00c4"+
|
||||
"\3\2\2\2\u038a\u038b\t\20\2\2\u038b\u00c6\3\2\2\2\u038c\u038d\7^\2\2\u038d"+
|
||||
"\u038e\7w\2\2\u038e\u038f\5\u0085C\2\u038f\u0390\5\u0085C\2\u0390\u0391"+
|
||||
"\5\u0085C\2\u0391\u0392\5\u0085C\2\u0392\u00c8\3\2\2\2\u0393\u0394\7p"+
|
||||
"\2\2\u0394\u0395\7w\2\2\u0395\u0396\7n\2\2\u0396\u0397\7n\2\2\u0397\u00ca"+
|
||||
"\3\2\2\2\u0398\u0399\7*\2\2\u0399\u00cc\3\2\2\2\u039a\u039b\7+\2\2\u039b"+
|
||||
"\u00ce\3\2\2\2\u039c\u039d\7}\2\2\u039d\u00d0\3\2\2\2\u039e\u039f\7\177"+
|
||||
"\2\2\u039f\u00d2\3\2\2\2\u03a0\u03a1\7]\2\2\u03a1\u00d4\3\2\2\2\u03a2"+
|
||||
"\u03a3\7_\2\2\u03a3\u00d6\3\2\2\2\u03a4\u03a5\7=\2\2\u03a5\u00d8\3\2\2"+
|
||||
"\2\u03a6\u03a7\7.\2\2\u03a7\u00da\3\2\2\2\u03a8\u03a9\7\60\2\2\u03a9\u00dc"+
|
||||
"\3\2\2\2\u03aa\u03ab\7?\2\2\u03ab\u00de\3\2\2\2\u03ac\u03ad\7@\2\2\u03ad"+
|
||||
"\u00e0\3\2\2\2\u03ae\u03af\7>\2\2\u03af\u00e2\3\2\2\2\u03b0\u03b1\7#\2"+
|
||||
"\2\u03b1\u00e4\3\2\2\2\u03b2\u03b3\7\u0080\2\2\u03b3\u00e6\3\2\2\2\u03b4"+
|
||||
"\u03b5\7A\2\2\u03b5\u00e8\3\2\2\2\u03b6\u03b7\7<\2\2\u03b7\u00ea\3\2\2"+
|
||||
"\2\u03b8\u03b9\7?\2\2\u03b9\u03ba\7?\2\2\u03ba\u00ec\3\2\2\2\u03bb\u03bc"+
|
||||
"\7>\2\2\u03bc\u03bd\7?\2\2\u03bd\u00ee\3\2\2\2\u03be\u03bf\7@\2\2\u03bf"+
|
||||
"\u03c0\7?\2\2\u03c0\u00f0\3\2\2\2\u03c1\u03c2\7#\2\2\u03c2\u03c3\7?\2"+
|
||||
"\2\u03c3\u00f2\3\2\2\2\u03c4\u03c5\7(\2\2\u03c5\u03c6\7(\2\2\u03c6\u00f4"+
|
||||
"\3\2\2\2\u03c7\u03c8\7~\2\2\u03c8\u03c9\7~\2\2\u03c9\u00f6\3\2\2\2\u03ca"+
|
||||
"\u03cb\7-\2\2\u03cb\u03cc\7-\2\2\u03cc\u00f8\3\2\2\2\u03cd\u03ce\7/\2"+
|
||||
"\2\u03ce\u03cf\7/\2\2\u03cf\u00fa\3\2\2\2\u03d0\u03d1\7-\2\2\u03d1\u00fc"+
|
||||
"\3\2\2\2\u03d2\u03d3\7/\2\2\u03d3\u00fe\3\2\2\2\u03d4\u03d5\7,\2\2\u03d5"+
|
||||
"\u0100\3\2\2\2\u03d6\u03d7\7\61\2\2\u03d7\u0102\3\2\2\2\u03d8\u03d9\7"+
|
||||
"(\2\2\u03d9\u0104\3\2\2\2\u03da\u03db\7~\2\2\u03db\u0106\3\2\2\2\u03dc"+
|
||||
"\u03dd\7`\2\2\u03dd\u0108\3\2\2\2\u03de\u03df\7\'\2\2\u03df\u010a\3\2"+
|
||||
"\2\2\u03e0\u03e1\7/\2\2\u03e1\u03e2\7@\2\2\u03e2\u010c\3\2\2\2\u03e3\u03e4"+
|
||||
"\7<\2\2\u03e4\u03e5\7<\2\2\u03e5\u010e\3\2\2\2\u03e6\u03e7\7-\2\2\u03e7"+
|
||||
"\u03e8\7?\2\2\u03e8\u0110\3\2\2\2\u03e9\u03ea\7/\2\2\u03ea\u03eb\7?\2"+
|
||||
"\2\u03eb\u0112\3\2\2\2\u03ec\u03ed\7,\2\2\u03ed\u03ee\7?\2\2\u03ee\u0114"+
|
||||
"\3\2\2\2\u03ef\u03f0\7\61\2\2\u03f0\u03f1\7?\2\2\u03f1\u0116\3\2\2\2\u03f2"+
|
||||
"\u03f3\7(\2\2\u03f3\u03f4\7?\2\2\u03f4\u0118\3\2\2\2\u03f5\u03f6\7~\2"+
|
||||
"\2\u03f6\u03f7\7?\2\2\u03f7\u011a\3\2\2\2\u03f8\u03f9\7`\2\2\u03f9\u03fa"+
|
||||
"\7?\2\2\u03fa\u011c\3\2\2\2\u03fb\u03fc\7\'\2\2\u03fc\u03fd\7?\2\2\u03fd"+
|
||||
"\u011e\3\2\2\2\u03fe\u03ff\7>\2\2\u03ff\u0400\7>\2\2\u0400\u0401\7?\2"+
|
||||
"\2\u0401\u0120\3\2\2\2\u0402\u0403\7@\2\2\u0403\u0404\7@\2\2\u0404\u0405"+
|
||||
"\7?\2\2\u0405\u0122\3\2\2\2\u0406\u0407\7@\2\2\u0407\u0408\7@\2\2\u0408"+
|
||||
"\u0409\7@\2\2\u0409\u040a\7?\2\2\u040a\u0124\3\2\2\2\u040b\u040f\5\u0127"+
|
||||
"\u0094\2\u040c\u040e\5\u0129\u0095\2\u040d\u040c\3\2\2\2\u040e\u0411\3"+
|
||||
"\2\2\2\u040f\u040d\3\2\2\2\u040f\u0410\3\2\2\2\u0410\u0126\3\2\2\2\u0411"+
|
||||
"\u040f\3\2\2\2\u0412\u0419\t\21\2\2\u0413\u0414\n\22\2\2\u0414\u0419\6"+
|
||||
"\u0094\2\2\u0415\u0416\t\23\2\2\u0416\u0417\t\24\2\2\u0417\u0419\6\u0094"+
|
||||
"\3\2\u0418\u0412\3\2\2\2\u0418\u0413\3\2\2\2\u0418\u0415\3\2\2\2\u0419"+
|
||||
"\u0128\3\2\2\2\u041a\u0421\t\25\2\2\u041b\u041c\n\22\2\2\u041c\u0421\6"+
|
||||
"\u0095\4\2\u041d\u041e\t\23\2\2\u041e\u041f\t\24\2\2\u041f\u0421\6\u0095"+
|
||||
"\5\2\u0420\u041a\3\2\2\2\u0420\u041b\3\2\2\2\u0420\u041d\3\2\2\2\u0421"+
|
||||
"\u012a\3\2\2\2\u0422\u0423\7B\2\2\u0423\u012c\3\2\2\2\u0424\u0425\7\60"+
|
||||
"\2\2\u0425\u0426\7\60\2\2\u0426\u0427\7\60\2\2\u0427\u012e\3\2\2\2\u0428"+
|
||||
"\u042a\t\26\2\2\u0429\u0428\3\2\2\2\u042a\u042b\3\2\2\2\u042b\u0429\3"+
|
||||
"\2\2\2\u042b\u042c\3\2\2\2\u042c\u042d\3\2\2\2\u042d\u042e\b\u0098\2\2"+
|
||||
"\u042e\u0130\3\2\2\2\u042f\u0430\7\61\2\2\u0430\u0431\7,\2\2\u0431\u0435"+
|
||||
"\3\2\2\2\u0432\u0434\13\2\2\2\u0433\u0432\3\2\2\2\u0434\u0437\3\2\2\2"+
|
||||
"\u0435\u0436\3\2\2\2\u0435\u0433\3\2\2\2\u0436\u0438\3\2\2\2\u0437\u0435"+
|
||||
"\3\2\2\2\u0438\u0439\7,\2\2\u0439\u043a\7\61\2\2\u043a\u043b\3\2\2\2\u043b"+
|
||||
"\u043c\b\u0099\2\2\u043c\u0132\3\2\2\2\u043d\u043e\7\61\2\2\u043e\u043f"+
|
||||
"\7\61\2\2\u043f\u0443\3\2\2\2\u0440\u0442\n\27\2\2\u0441\u0440\3\2\2\2"+
|
||||
"\u0442\u0445\3\2\2\2\u0443\u0441\3\2\2\2\u0443\u0444\3\2\2\2\u0444\u0446"+
|
||||
"\3\2\2\2\u0445\u0443\3\2\2\2\u0446\u0447\b\u009a\2\2\u0447\u0134\3\2\2"+
|
||||
"\28\2\u028c\u0290\u0294\u0298\u029c\u02a3\u02a8\u02aa\u02ae\u02b1\u02b5"+
|
||||
"\u02bc\u02c0\u02c5\u02cd\u02d0\u02d7\u02db\u02df\u02e5\u02e8\u02ef\u02f3"+
|
||||
"\u02fb\u02fe\u0305\u0309\u030d\u0312\u0315\u0318\u031d\u0320\u0325\u032a"+
|
||||
"\u0332\u033d\u0341\u0346\u034a\u035a\u0364\u036a\u0371\u0375\u037b\u0388"+
|
||||
"\u040f\u0418\u0420\u042b\u0435\u0443\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);
|
||||
}
|
||||
}
|
||||
}
|
205
src/de/dhbwstuttgart/parser/antlr/Java8Lexer.tokens
Normal file
205
src/de/dhbwstuttgart/parser/antlr/Java8Lexer.tokens
Normal file
@ -0,0 +1,205 @@
|
||||
ABSTRACT=1
|
||||
ASSERT=2
|
||||
BOOLEAN=3
|
||||
BREAK=4
|
||||
BYTE=5
|
||||
CASE=6
|
||||
CATCH=7
|
||||
CHAR=8
|
||||
CLASS=9
|
||||
CONST=10
|
||||
CONTINUE=11
|
||||
DEFAULT=12
|
||||
DO=13
|
||||
DOUBLE=14
|
||||
ELSE=15
|
||||
ENUM=16
|
||||
EXTENDS=17
|
||||
FINAL=18
|
||||
FINALLY=19
|
||||
FLOAT=20
|
||||
FOR=21
|
||||
IF=22
|
||||
GOTO=23
|
||||
IMPLEMENTS=24
|
||||
IMPORT=25
|
||||
INSTANCEOF=26
|
||||
INT=27
|
||||
INTERFACE=28
|
||||
LONG=29
|
||||
NATIVE=30
|
||||
NEW=31
|
||||
PACKAGE=32
|
||||
PRIVATE=33
|
||||
PROTECTED=34
|
||||
PUBLIC=35
|
||||
RETURN=36
|
||||
SHORT=37
|
||||
STATIC=38
|
||||
STRICTFP=39
|
||||
SUPER=40
|
||||
SWITCH=41
|
||||
SYNCHRONIZED=42
|
||||
THIS=43
|
||||
THROW=44
|
||||
THROWS=45
|
||||
TRANSIENT=46
|
||||
TRY=47
|
||||
VOID=48
|
||||
VOLATILE=49
|
||||
WHILE=50
|
||||
IntegerLiteral=51
|
||||
FloatingPointLiteral=52
|
||||
BooleanLiteral=53
|
||||
CharacterLiteral=54
|
||||
StringLiteral=55
|
||||
NullLiteral=56
|
||||
LPAREN=57
|
||||
RPAREN=58
|
||||
LBRACE=59
|
||||
RBRACE=60
|
||||
LBRACK=61
|
||||
RBRACK=62
|
||||
SEMI=63
|
||||
COMMA=64
|
||||
DOT=65
|
||||
ASSIGN=66
|
||||
GT=67
|
||||
LT=68
|
||||
BANG=69
|
||||
TILDE=70
|
||||
QUESTION=71
|
||||
COLON=72
|
||||
EQUAL=73
|
||||
LE=74
|
||||
GE=75
|
||||
NOTEQUAL=76
|
||||
AND=77
|
||||
OR=78
|
||||
INC=79
|
||||
DEC=80
|
||||
ADD=81
|
||||
SUB=82
|
||||
MUL=83
|
||||
DIV=84
|
||||
BITAND=85
|
||||
BITOR=86
|
||||
CARET=87
|
||||
MOD=88
|
||||
ARROW=89
|
||||
COLONCOLON=90
|
||||
ADD_ASSIGN=91
|
||||
SUB_ASSIGN=92
|
||||
MUL_ASSIGN=93
|
||||
DIV_ASSIGN=94
|
||||
AND_ASSIGN=95
|
||||
OR_ASSIGN=96
|
||||
XOR_ASSIGN=97
|
||||
MOD_ASSIGN=98
|
||||
LSHIFT_ASSIGN=99
|
||||
RSHIFT_ASSIGN=100
|
||||
URSHIFT_ASSIGN=101
|
||||
Identifier=102
|
||||
AT=103
|
||||
ELLIPSIS=104
|
||||
WS=105
|
||||
COMMENT=106
|
||||
LINE_COMMENT=107
|
||||
'abstract'=1
|
||||
'assert'=2
|
||||
'boolean'=3
|
||||
'break'=4
|
||||
'byte'=5
|
||||
'case'=6
|
||||
'catch'=7
|
||||
'char'=8
|
||||
'class'=9
|
||||
'const'=10
|
||||
'continue'=11
|
||||
'default'=12
|
||||
'do'=13
|
||||
'double'=14
|
||||
'else'=15
|
||||
'enum'=16
|
||||
'extends'=17
|
||||
'final'=18
|
||||
'finally'=19
|
||||
'float'=20
|
||||
'for'=21
|
||||
'if'=22
|
||||
'goto'=23
|
||||
'implements'=24
|
||||
'import'=25
|
||||
'instanceof'=26
|
||||
'int'=27
|
||||
'interface'=28
|
||||
'long'=29
|
||||
'native'=30
|
||||
'new'=31
|
||||
'package'=32
|
||||
'private'=33
|
||||
'protected'=34
|
||||
'public'=35
|
||||
'return'=36
|
||||
'short'=37
|
||||
'static'=38
|
||||
'strictfp'=39
|
||||
'super'=40
|
||||
'switch'=41
|
||||
'synchronized'=42
|
||||
'this'=43
|
||||
'throw'=44
|
||||
'throws'=45
|
||||
'transient'=46
|
||||
'try'=47
|
||||
'void'=48
|
||||
'volatile'=49
|
||||
'while'=50
|
||||
'null'=56
|
||||
'('=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
|
||||
'@'=103
|
||||
'...'=104
|
2390
src/de/dhbwstuttgart/parser/antlr/Java8Listener.java
Normal file
2390
src/de/dhbwstuttgart/parser/antlr/Java8Listener.java
Normal file
File diff suppressed because it is too large
Load Diff
18759
src/de/dhbwstuttgart/parser/antlr/Java8Parser.java
Normal file
18759
src/de/dhbwstuttgart/parser/antlr/Java8Parser.java
Normal file
File diff suppressed because it is too large
Load Diff
0
src/main/java/de/dhbwstuttgart/parser/notes/questions → src/de/dhbwstuttgart/parser/notes/questions
0
src/main/java/de/dhbwstuttgart/parser/notes/questions → src/de/dhbwstuttgart/parser/notes/questions
@ -0,0 +1,159 @@
|
||||
// Generated from UnifyResult.g4 by ANTLR 4.7
|
||||
package de.dhbwstuttgart.sat.asp.parser.antlr;
|
||||
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
/**
|
||||
* This class provides an empty implementation of {@link UnifyResultListener},
|
||||
* which can be extended to create a listener which only needs to handle a subset
|
||||
* of the available methods.
|
||||
*/
|
||||
public class UnifyResultBaseListener implements UnifyResultListener {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterAnswer(UnifyResultParser.AnswerContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitAnswer(UnifyResultParser.AnswerContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterResultSetRule(UnifyResultParser.ResultSetRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitResultSetRule(UnifyResultParser.ResultSetRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterParameterList(UnifyResultParser.ParameterListContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitParameterList(UnifyResultParser.ParameterListContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterValue(UnifyResultParser.ValueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitValue(UnifyResultParser.ValueContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterParameter(UnifyResultParser.ParameterContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitParameter(UnifyResultParser.ParameterContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEquals(UnifyResultParser.EqualsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEquals(UnifyResultParser.EqualsContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterSmaller(UnifyResultParser.SmallerContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitSmaller(UnifyResultParser.SmallerContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterTypeVar(UnifyResultParser.TypeVarContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitTypeVar(UnifyResultParser.TypeVarContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterType(UnifyResultParser.TypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitType(UnifyResultParser.TypeContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterOtherRule(UnifyResultParser.OtherRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitOtherRule(UnifyResultParser.OtherRuleContext ctx) { }
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitTerminal(TerminalNode node) { }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation does nothing.</p>
|
||||
*/
|
||||
@Override public void visitErrorNode(ErrorNode node) { }
|
||||
}
|
134
src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.java
Normal file
134
src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultLexer.java
Normal file
@ -0,0 +1,134 @@
|
||||
// Generated from UnifyResult.g4 by ANTLR 4.7
|
||||
package de.dhbwstuttgart.sat.asp.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 UnifyResultLexer 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, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, EQUALS_NAME=7,
|
||||
SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
|
||||
public static String[] modeNames = {
|
||||
"DEFAULT_MODE"
|
||||
};
|
||||
|
||||
public static final String[] ruleNames = {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "PARAMLIST_NAME", "EQUALS_NAME",
|
||||
"SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT"
|
||||
};
|
||||
|
||||
private static final String[] _LITERAL_NAMES = {
|
||||
null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'",
|
||||
"'typeVar'", "'type'"
|
||||
};
|
||||
private static final String[] _SYMBOLIC_NAMES = {
|
||||
null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME",
|
||||
"TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "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 UnifyResultLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "UnifyResult.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; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\17c\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\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\4"+
|
||||
"\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3"+
|
||||
"\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13"+
|
||||
"\3\13\3\13\3\13\3\13\3\f\6\fP\n\f\r\f\16\fQ\3\r\6\rU\n\r\r\r\16\rV\3\r"+
|
||||
"\3\r\3\16\3\16\7\16]\n\16\f\16\16\16`\13\16\3\16\3\16\2\2\17\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\3\2\5\6\2\62;C\\"+
|
||||
"aac|\5\2\13\f\16\17\"\"\4\2\f\f\17\17\2e\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\3\35"+
|
||||
"\3\2\2\2\5$\3\2\2\2\7&\3\2\2\2\t(\3\2\2\2\13*\3\2\2\2\r,\3\2\2\2\17\62"+
|
||||
"\3\2\2\2\219\3\2\2\2\23A\3\2\2\2\25I\3\2\2\2\27O\3\2\2\2\31T\3\2\2\2\33"+
|
||||
"Z\3\2\2\2\35\36\7C\2\2\36\37\7P\2\2\37 \7U\2\2 !\7Y\2\2!\"\7G\2\2\"#\7"+
|
||||
"T\2\2#\4\3\2\2\2$%\7\60\2\2%\6\3\2\2\2&\'\7*\2\2\'\b\3\2\2\2()\7.\2\2"+
|
||||
")\n\3\2\2\2*+\7+\2\2+\f\3\2\2\2,-\7r\2\2-.\7c\2\2./\7t\2\2/\60\7c\2\2"+
|
||||
"\60\61\7o\2\2\61\16\3\2\2\2\62\63\7g\2\2\63\64\7s\2\2\64\65\7w\2\2\65"+
|
||||
"\66\7c\2\2\66\67\7n\2\2\678\7u\2\28\20\3\2\2\29:\7u\2\2:;\7o\2\2;<\7c"+
|
||||
"\2\2<=\7n\2\2=>\7n\2\2>?\7g\2\2?@\7t\2\2@\22\3\2\2\2AB\7v\2\2BC\7{\2\2"+
|
||||
"CD\7r\2\2DE\7g\2\2EF\7X\2\2FG\7c\2\2GH\7t\2\2H\24\3\2\2\2IJ\7v\2\2JK\7"+
|
||||
"{\2\2KL\7r\2\2LM\7g\2\2M\26\3\2\2\2NP\t\2\2\2ON\3\2\2\2PQ\3\2\2\2QO\3"+
|
||||
"\2\2\2QR\3\2\2\2R\30\3\2\2\2SU\t\3\2\2TS\3\2\2\2UV\3\2\2\2VT\3\2\2\2V"+
|
||||
"W\3\2\2\2WX\3\2\2\2XY\b\r\2\2Y\32\3\2\2\2Z^\7\'\2\2[]\n\4\2\2\\[\3\2\2"+
|
||||
"\2]`\3\2\2\2^\\\3\2\2\2^_\3\2\2\2_a\3\2\2\2`^\3\2\2\2ab\b\16\2\2b\34\3"+
|
||||
"\2\2\2\6\2QV^\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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
// Generated from UnifyResult.g4 by ANTLR 4.7
|
||||
package de.dhbwstuttgart.sat.asp.parser.antlr;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||
|
||||
/**
|
||||
* This interface defines a complete listener for a parse tree produced by
|
||||
* {@link UnifyResultParser}.
|
||||
*/
|
||||
public interface UnifyResultListener extends ParseTreeListener {
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#answer}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterAnswer(UnifyResultParser.AnswerContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#answer}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitAnswer(UnifyResultParser.AnswerContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#resultSetRule}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterResultSetRule(UnifyResultParser.ResultSetRuleContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#resultSetRule}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitResultSetRule(UnifyResultParser.ResultSetRuleContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterParameterList(UnifyResultParser.ParameterListContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#parameterList}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitParameterList(UnifyResultParser.ParameterListContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterValue(UnifyResultParser.ValueContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#value}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitValue(UnifyResultParser.ValueContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#parameter}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterParameter(UnifyResultParser.ParameterContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#parameter}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitParameter(UnifyResultParser.ParameterContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#equals}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterEquals(UnifyResultParser.EqualsContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#equals}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitEquals(UnifyResultParser.EqualsContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#smaller}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterSmaller(UnifyResultParser.SmallerContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#smaller}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitSmaller(UnifyResultParser.SmallerContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#typeVar}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterTypeVar(UnifyResultParser.TypeVarContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#typeVar}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitTypeVar(UnifyResultParser.TypeVarContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterType(UnifyResultParser.TypeContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#type}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitType(UnifyResultParser.TypeContext ctx);
|
||||
/**
|
||||
* Enter a parse tree produced by {@link UnifyResultParser#otherRule}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void enterOtherRule(UnifyResultParser.OtherRuleContext ctx);
|
||||
/**
|
||||
* Exit a parse tree produced by {@link UnifyResultParser#otherRule}.
|
||||
* @param ctx the parse tree
|
||||
*/
|
||||
void exitOtherRule(UnifyResultParser.OtherRuleContext ctx);
|
||||
}
|
639
src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultParser.java
Normal file
639
src/de/dhbwstuttgart/sat/asp/parser/antlr/UnifyResultParser.java
Normal file
@ -0,0 +1,639 @@
|
||||
// Generated from UnifyResult.g4 by ANTLR 4.7
|
||||
package de.dhbwstuttgart.sat.asp.parser.antlr;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
import org.antlr.v4.runtime.tree.*;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class UnifyResultParser extends Parser {
|
||||
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, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, EQUALS_NAME=7,
|
||||
SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13;
|
||||
public static final int
|
||||
RULE_answer = 0, RULE_resultSetRule = 1, RULE_parameterList = 2, RULE_value = 3,
|
||||
RULE_parameter = 4, RULE_equals = 5, RULE_smaller = 6, RULE_typeVar = 7,
|
||||
RULE_type = 8, RULE_otherRule = 9;
|
||||
public static final String[] ruleNames = {
|
||||
"answer", "resultSetRule", "parameterList", "value", "parameter", "equals",
|
||||
"smaller", "typeVar", "type", "otherRule"
|
||||
};
|
||||
|
||||
private static final String[] _LITERAL_NAMES = {
|
||||
null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'",
|
||||
"'typeVar'", "'type'"
|
||||
};
|
||||
private static final String[] _SYMBOLIC_NAMES = {
|
||||
null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME",
|
||||
"TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "UnifyResult.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public UnifyResultParser(TokenStream input) {
|
||||
super(input);
|
||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
public static class AnswerContext extends ParserRuleContext {
|
||||
public List<ResultSetRuleContext> resultSetRule() {
|
||||
return getRuleContexts(ResultSetRuleContext.class);
|
||||
}
|
||||
public ResultSetRuleContext resultSetRule(int i) {
|
||||
return getRuleContext(ResultSetRuleContext.class,i);
|
||||
}
|
||||
public AnswerContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_answer; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterAnswer(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitAnswer(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final AnswerContext answer() throws RecognitionException {
|
||||
AnswerContext _localctx = new AnswerContext(_ctx, getState());
|
||||
enterRule(_localctx, 0, RULE_answer);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(20);
|
||||
match(T__0);
|
||||
setState(26);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PARAMLIST_NAME) | (1L << EQUALS_NAME) | (1L << SMALLER_NAME) | (1L << TYPEVAR_NAME) | (1L << TYPE_NAME) | (1L << NAME))) != 0)) {
|
||||
{
|
||||
{
|
||||
setState(21);
|
||||
resultSetRule();
|
||||
setState(22);
|
||||
match(T__1);
|
||||
}
|
||||
}
|
||||
setState(28);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class ResultSetRuleContext extends ParserRuleContext {
|
||||
public ParameterContext parameter() {
|
||||
return getRuleContext(ParameterContext.class,0);
|
||||
}
|
||||
public EqualsContext equals() {
|
||||
return getRuleContext(EqualsContext.class,0);
|
||||
}
|
||||
public SmallerContext smaller() {
|
||||
return getRuleContext(SmallerContext.class,0);
|
||||
}
|
||||
public TypeVarContext typeVar() {
|
||||
return getRuleContext(TypeVarContext.class,0);
|
||||
}
|
||||
public TypeContext type() {
|
||||
return getRuleContext(TypeContext.class,0);
|
||||
}
|
||||
public OtherRuleContext otherRule() {
|
||||
return getRuleContext(OtherRuleContext.class,0);
|
||||
}
|
||||
public ResultSetRuleContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_resultSetRule; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterResultSetRule(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitResultSetRule(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final ResultSetRuleContext resultSetRule() throws RecognitionException {
|
||||
ResultSetRuleContext _localctx = new ResultSetRuleContext(_ctx, getState());
|
||||
enterRule(_localctx, 2, RULE_resultSetRule);
|
||||
try {
|
||||
setState(35);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
case PARAMLIST_NAME:
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(29);
|
||||
parameter();
|
||||
}
|
||||
break;
|
||||
case EQUALS_NAME:
|
||||
enterOuterAlt(_localctx, 2);
|
||||
{
|
||||
setState(30);
|
||||
equals();
|
||||
}
|
||||
break;
|
||||
case SMALLER_NAME:
|
||||
enterOuterAlt(_localctx, 3);
|
||||
{
|
||||
setState(31);
|
||||
smaller();
|
||||
}
|
||||
break;
|
||||
case TYPEVAR_NAME:
|
||||
enterOuterAlt(_localctx, 4);
|
||||
{
|
||||
setState(32);
|
||||
typeVar();
|
||||
}
|
||||
break;
|
||||
case TYPE_NAME:
|
||||
enterOuterAlt(_localctx, 5);
|
||||
{
|
||||
setState(33);
|
||||
type();
|
||||
}
|
||||
break;
|
||||
case NAME:
|
||||
enterOuterAlt(_localctx, 6);
|
||||
{
|
||||
setState(34);
|
||||
otherRule();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NoViableAltException(this);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class ParameterListContext extends ParserRuleContext {
|
||||
public List<ValueContext> value() {
|
||||
return getRuleContexts(ValueContext.class);
|
||||
}
|
||||
public ValueContext value(int i) {
|
||||
return getRuleContext(ValueContext.class,i);
|
||||
}
|
||||
public ParameterListContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_parameterList; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterParameterList(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitParameterList(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final ParameterListContext parameterList() throws RecognitionException {
|
||||
ParameterListContext _localctx = new ParameterListContext(_ctx, getState());
|
||||
enterRule(_localctx, 4, RULE_parameterList);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(37);
|
||||
match(T__2);
|
||||
setState(38);
|
||||
value();
|
||||
setState(43);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la==T__3) {
|
||||
{
|
||||
{
|
||||
setState(39);
|
||||
match(T__3);
|
||||
setState(40);
|
||||
value();
|
||||
}
|
||||
}
|
||||
setState(45);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
setState(46);
|
||||
match(T__4);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class ValueContext extends ParserRuleContext {
|
||||
public TerminalNode NAME() { return getToken(UnifyResultParser.NAME, 0); }
|
||||
public ResultSetRuleContext resultSetRule() {
|
||||
return getRuleContext(ResultSetRuleContext.class,0);
|
||||
}
|
||||
public ValueContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_value; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterValue(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitValue(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final ValueContext value() throws RecognitionException {
|
||||
ValueContext _localctx = new ValueContext(_ctx, getState());
|
||||
enterRule(_localctx, 6, RULE_value);
|
||||
try {
|
||||
setState(50);
|
||||
_errHandler.sync(this);
|
||||
switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
|
||||
case 1:
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(48);
|
||||
match(NAME);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
enterOuterAlt(_localctx, 2);
|
||||
{
|
||||
setState(49);
|
||||
resultSetRule();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class ParameterContext extends ParserRuleContext {
|
||||
public TerminalNode PARAMLIST_NAME() { return getToken(UnifyResultParser.PARAMLIST_NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public ParameterContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_parameter; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterParameter(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitParameter(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final ParameterContext parameter() throws RecognitionException {
|
||||
ParameterContext _localctx = new ParameterContext(_ctx, getState());
|
||||
enterRule(_localctx, 8, RULE_parameter);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(52);
|
||||
match(PARAMLIST_NAME);
|
||||
setState(53);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class EqualsContext extends ParserRuleContext {
|
||||
public TerminalNode EQUALS_NAME() { return getToken(UnifyResultParser.EQUALS_NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public EqualsContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_equals; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterEquals(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitEquals(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final EqualsContext equals() throws RecognitionException {
|
||||
EqualsContext _localctx = new EqualsContext(_ctx, getState());
|
||||
enterRule(_localctx, 10, RULE_equals);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(55);
|
||||
match(EQUALS_NAME);
|
||||
setState(56);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class SmallerContext extends ParserRuleContext {
|
||||
public TerminalNode SMALLER_NAME() { return getToken(UnifyResultParser.SMALLER_NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public SmallerContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_smaller; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterSmaller(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitSmaller(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final SmallerContext smaller() throws RecognitionException {
|
||||
SmallerContext _localctx = new SmallerContext(_ctx, getState());
|
||||
enterRule(_localctx, 12, RULE_smaller);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(58);
|
||||
match(SMALLER_NAME);
|
||||
setState(59);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class TypeVarContext extends ParserRuleContext {
|
||||
public TerminalNode TYPEVAR_NAME() { return getToken(UnifyResultParser.TYPEVAR_NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public TypeVarContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_typeVar; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterTypeVar(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitTypeVar(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final TypeVarContext typeVar() throws RecognitionException {
|
||||
TypeVarContext _localctx = new TypeVarContext(_ctx, getState());
|
||||
enterRule(_localctx, 14, RULE_typeVar);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(61);
|
||||
match(TYPEVAR_NAME);
|
||||
setState(62);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class TypeContext extends ParserRuleContext {
|
||||
public TerminalNode TYPE_NAME() { return getToken(UnifyResultParser.TYPE_NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public TypeContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_type; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterType(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitType(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final TypeContext type() throws RecognitionException {
|
||||
TypeContext _localctx = new TypeContext(_ctx, getState());
|
||||
enterRule(_localctx, 16, RULE_type);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(64);
|
||||
match(TYPE_NAME);
|
||||
setState(65);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static class OtherRuleContext extends ParserRuleContext {
|
||||
public TerminalNode NAME() { return getToken(UnifyResultParser.NAME, 0); }
|
||||
public ParameterListContext parameterList() {
|
||||
return getRuleContext(ParameterListContext.class,0);
|
||||
}
|
||||
public OtherRuleContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_otherRule; }
|
||||
@Override
|
||||
public void enterRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterOtherRule(this);
|
||||
}
|
||||
@Override
|
||||
public void exitRule(ParseTreeListener listener) {
|
||||
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitOtherRule(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final OtherRuleContext otherRule() throws RecognitionException {
|
||||
OtherRuleContext _localctx = new OtherRuleContext(_ctx, getState());
|
||||
enterRule(_localctx, 18, RULE_otherRule);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(67);
|
||||
match(NAME);
|
||||
setState(68);
|
||||
parameterList();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\17I\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\3"+
|
||||
"\2\3\2\3\2\3\2\7\2\33\n\2\f\2\16\2\36\13\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3"+
|
||||
"&\n\3\3\4\3\4\3\4\3\4\7\4,\n\4\f\4\16\4/\13\4\3\4\3\4\3\5\3\5\5\5\65\n"+
|
||||
"\5\3\6\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\13\3"+
|
||||
"\13\3\13\3\13\2\2\f\2\4\6\b\n\f\16\20\22\24\2\2\2F\2\26\3\2\2\2\4%\3\2"+
|
||||
"\2\2\6\'\3\2\2\2\b\64\3\2\2\2\n\66\3\2\2\2\f9\3\2\2\2\16<\3\2\2\2\20?"+
|
||||
"\3\2\2\2\22B\3\2\2\2\24E\3\2\2\2\26\34\7\3\2\2\27\30\5\4\3\2\30\31\7\4"+
|
||||
"\2\2\31\33\3\2\2\2\32\27\3\2\2\2\33\36\3\2\2\2\34\32\3\2\2\2\34\35\3\2"+
|
||||
"\2\2\35\3\3\2\2\2\36\34\3\2\2\2\37&\5\n\6\2 &\5\f\7\2!&\5\16\b\2\"&\5"+
|
||||
"\20\t\2#&\5\22\n\2$&\5\24\13\2%\37\3\2\2\2% \3\2\2\2%!\3\2\2\2%\"\3\2"+
|
||||
"\2\2%#\3\2\2\2%$\3\2\2\2&\5\3\2\2\2\'(\7\5\2\2(-\5\b\5\2)*\7\6\2\2*,\5"+
|
||||
"\b\5\2+)\3\2\2\2,/\3\2\2\2-+\3\2\2\2-.\3\2\2\2.\60\3\2\2\2/-\3\2\2\2\60"+
|
||||
"\61\7\7\2\2\61\7\3\2\2\2\62\65\7\r\2\2\63\65\5\4\3\2\64\62\3\2\2\2\64"+
|
||||
"\63\3\2\2\2\65\t\3\2\2\2\66\67\7\b\2\2\678\5\6\4\28\13\3\2\2\29:\7\t\2"+
|
||||
"\2:;\5\6\4\2;\r\3\2\2\2<=\7\n\2\2=>\5\6\4\2>\17\3\2\2\2?@\7\13\2\2@A\5"+
|
||||
"\6\4\2A\21\3\2\2\2BC\7\f\2\2CD\5\6\4\2D\23\3\2\2\2EF\7\r\2\2FG\5\6\4\2"+
|
||||
"G\25\3\2\2\2\6\34%-\64";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
158
src/de/dhbwstuttgart/strucTypes/Construct.java
Normal file
158
src/de/dhbwstuttgart/strucTypes/Construct.java
Normal file
@ -0,0 +1,158 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.exception.IllegalInterfaceTypeException;
|
||||
import de.dhbwstuttgart.strucTypes.exception.ImpossibleSubTypeException;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.DefaultASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class Construct extends DefaultASTVisitor {
|
||||
|
||||
private Set<SubTypeConstraint> subTypeConstraints = new HashSet<>();
|
||||
private ConstraintsSet constraintsSet = new ConstraintsSet();
|
||||
private Set<RefTypeOrTPHOrWildcardOrGeneric> newInterf = new HashSet<>();
|
||||
private InferredTypes inferredTypes = new InferredTypes();
|
||||
private List<ClassOrInterface> constructedInterfaces = new ArrayList<>();
|
||||
|
||||
public Construct(ConstraintsSet constraintsSet, InferredTypes inferredTypes) throws ImpossibleSubTypeException {
|
||||
this.constraintsSet = constraintsSet;
|
||||
this.inferredTypes = inferredTypes;
|
||||
this.gatherSubTypeConstraints(constraintsSet);
|
||||
for (SubTypeConstraint constraint : this.subTypeConstraints) {
|
||||
constraint.checkConstraintPossible();
|
||||
}
|
||||
}
|
||||
|
||||
public List<ClassOrInterface> getConstructedInterfaces() {
|
||||
this.newInterf.forEach(i -> i.accept(this));
|
||||
return constructedInterfaces;
|
||||
}
|
||||
|
||||
public InferredTypes getInferredTypes() {
|
||||
return inferredTypes;
|
||||
}
|
||||
|
||||
public Set<SubTypeConstraint> getSubTypeConstraints() {
|
||||
this.subTypeConstraints.forEach(sc -> sc.inferTypes(this.inferredTypes));
|
||||
return subTypeConstraints;
|
||||
}
|
||||
|
||||
// public Set<UnifyPair> getSubTypeConstraintsAsUnifyPairs() {
|
||||
// return subTypeConstraints.stream().map(SubTypeConstraint::getAsUnifyPair).collect(Collectors.toSet());
|
||||
// }
|
||||
|
||||
private void gatherSubTypeConstraints(ConstraintsSet constraintsSet) {
|
||||
this.subTypeConstraints.addAll(constraintsSet.getSubTypeConstraints());
|
||||
constraintsSet.getFieldConstraints().forEach(fc -> this.newInterf.add(fc.getClassType()));
|
||||
constraintsSet.getMethodConstraints().forEach(mc -> {
|
||||
this.subTypeConstraints.addAll(mc.getArguments());
|
||||
this.newInterf.add(mc.getClassType());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
JavaClassName name = new JavaClassName( typePlaceholder.getName());
|
||||
this.constructedInterfaces.add(this.constructInterface(typePlaceholder, name));
|
||||
}
|
||||
|
||||
// check nur TPH in newInterf
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
throw new IllegalInterfaceTypeException(
|
||||
String.format("%s is not a valid type to generate an interface for.", refType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
System.out.println(String.format("%s is not a valid type to generate an interface for.", genericRefType));
|
||||
}
|
||||
|
||||
private ClassOrInterface constructInterface(TypePlaceholder i, JavaClassName name) {
|
||||
List<Field> fielddecl = new ArrayList<>();
|
||||
List<Method> methods = new ArrayList<>();
|
||||
List<GenericTypeVar> generics = new ArrayList<>();
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> parameterInhTyterm = new ArrayList<>();
|
||||
final Token offset = new NullToken();
|
||||
|
||||
// Schleife <20>ber alle FieldConstraints mit ClassType i
|
||||
this.constraintsSet.getFieldConstraints().stream().filter(fc -> fc.getClassType().equals(i)).forEach(fc -> {
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
// Typ f<>r field: GenericRefType
|
||||
GenericRefType grt = new GenericRefType(tph.getName(), offset);
|
||||
parameterInhTyterm.add(fc.getFieldType());
|
||||
generics.add(new GenericTypeVar(tph.getName(), new ArrayList<>(), offset, offset));
|
||||
Field field = new Field(fc.getFieldName(), grt, Modifier.PUBLIC, offset);
|
||||
fielddecl.add(field);
|
||||
});
|
||||
|
||||
// Schleife <20>ber alle MethodConstraints mit ClassType i
|
||||
this.constraintsSet.getMethodConstraints().stream().filter(mc -> mc.getClassType().equals(i)).forEach(mc -> {
|
||||
TypePlaceholder returnType = TypePlaceholder.fresh(offset);
|
||||
parameterInhTyterm.add(mc.getReturnType());
|
||||
generics.add(new GenericTypeVar(returnType.getName(), new ArrayList<>(), offset, offset));
|
||||
Block block = new Block(new ArrayList<>(), offset);
|
||||
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), offset);
|
||||
List<FormalParameter> params = new ArrayList<>();
|
||||
mc.getArguments().stream().map(a -> a.getSupertype()).forEach(supertype -> {
|
||||
// Typ f<>r argument: GenericRefType
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
GenericRefType grt = new GenericRefType(tph.getName(), offset);
|
||||
params.add(new FormalParameter("arg" + tph.getName(), grt, offset));
|
||||
parameterInhTyterm.add(supertype);
|
||||
generics.add(new GenericTypeVar(tph.getName(), new ArrayList<>(), offset, offset));
|
||||
});
|
||||
ParameterList parameterList = new ParameterList(params, offset);
|
||||
// returnType f<>r method: GenericRefType
|
||||
Method method = new Method(Modifier.PUBLIC, mc.getMethodName(),
|
||||
new GenericRefType(returnType.getName(), offset), parameterList, block, gtvDeclarations, offset);
|
||||
methods.add(method);
|
||||
});
|
||||
|
||||
RefType inh_tyterm = new RefType(name, parameterInhTyterm, offset);
|
||||
TypePlaceholder x = TypePlaceholder.fresh(offset);
|
||||
this.subTypeConstraints.add(new SubTypeConstraint(x, inh_tyterm));
|
||||
this.inferredTypes.put(i, x);
|
||||
|
||||
final int modifiers = Modifier.PUBLIC;
|
||||
final RefType superClass = this.createSuperClass();
|
||||
final boolean isInterface = true;
|
||||
final List<Constructor> constructors = new ArrayList<>();
|
||||
final List<RefType> implementedInterfaces = new ArrayList<>();
|
||||
GenericDeclarationList genericClassParameters = new GenericDeclarationList(generics, i.getOffset());
|
||||
ClassOrInterface constructedInterface = new ClassOrInterface(modifiers, name, fielddecl, methods, constructors,
|
||||
genericClassParameters, superClass, isInterface, implementedInterfaces, offset);
|
||||
return constructedInterface;
|
||||
}
|
||||
|
||||
private RefType createSuperClass() {
|
||||
JavaClassName name = new JavaClassName(Object.class.getName());
|
||||
GenericDeclarationList genericsOfClass = new GenericDeclarationList(new ArrayList<>(), new NullToken());
|
||||
return ClassOrInterface.generateTypeOfClass(name, genericsOfClass, new NullToken());
|
||||
}
|
||||
|
||||
}
|
182
src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java
Normal file
182
src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java
Normal file
@ -0,0 +1,182 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
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.unify.MartelliMontanariUnify;
|
||||
import de.dhbwstuttgart.typeinference.unify.RuleSet;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.Unifier;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
import javafx.util.Pair;
|
||||
|
||||
public class RuleSetStrucType extends RuleSet {
|
||||
|
||||
public Optional<Set<UnifyPair>> strucTypeReduce(UnifyPair pair) {
|
||||
return super.reduce2(pair);
|
||||
}
|
||||
|
||||
public Optional<UnifyPair> strucTypeAdapt1(UnifyPair pair, IFiniteClosure fc) {
|
||||
return super.adapt(pair, fc);
|
||||
}
|
||||
|
||||
public Optional<Set<UnifyPair>> strucTypeAdapt2(Set<UnifyPair> pairs, IFiniteClosure fc) {
|
||||
// Filter SMALLERDOT Pairs
|
||||
final Set<UnifyPair> pairsSmallerDot = pairs.stream().filter(p -> PairOperator.SMALLERDOT.equals(p.getPairOp()))
|
||||
.collect(Collectors.toSet());
|
||||
List<Pair<UnifyPair, UnifyPair>> tupleOfPotentialLinkings = new ArrayList<>();
|
||||
for (UnifyPair pair : pairsSmallerDot) {
|
||||
// check outerLeftPair pair has Form (D<theta.1,..,theta.n> <. TPH S1)
|
||||
UnifyType typeD = pair.getLhsType();
|
||||
if (!(pair.getRhsType() instanceof PlaceholderType) || !(typeD instanceof ReferenceType)) {
|
||||
continue;
|
||||
}
|
||||
// filter potential outer Pairs for Linking
|
||||
pairsSmallerDot.stream()
|
||||
// check outerRightPair p has Form (TPH Sn <. D'<theta'.1,...,theta'.m>)
|
||||
.filter(p -> (p.getLhsType() instanceof PlaceholderType)
|
||||
&& (p.getRhsType() instanceof ReferenceType))
|
||||
.filter(p -> {
|
||||
UnifyType typeD1 = p.getRhsType();
|
||||
// check not(D<theta.1,..,theta.n> <=* D'<theta'.1,..,theta'.m>)
|
||||
if (fc.getAncestors(typeD).contains(typeD1))
|
||||
return false;
|
||||
Optional<UnifyType> opt = fc.getLeftHandedType(typeD.getName());
|
||||
if (!opt.isPresent())
|
||||
return false;
|
||||
|
||||
UnifyType typeDgen = opt.get();
|
||||
Set<UnifyType> greater = fc.getAncestors(typeDgen);
|
||||
opt = greater.stream().filter(x -> x.getName().equals(typeD1.getName())).findAny();
|
||||
// check (D<T1,..,Tn> <=* D'<ty1',...,tym'>)
|
||||
if (!opt.isPresent())
|
||||
return false;
|
||||
// UnifyType typeD1gen = opt.get();
|
||||
return true;
|
||||
}).map(p -> new Pair<>(pair, p)).forEach(tupleOfPotentialLinkings::add);
|
||||
}
|
||||
|
||||
// Build Linking between the Pairs. Empty if no Linking is possible.
|
||||
for (Pair<UnifyPair, UnifyPair> tuple : tupleOfPotentialLinkings) {
|
||||
UnifyPair outerLeftPair = tuple.getKey();
|
||||
UnifyPair outerRightPair = tuple.getValue();
|
||||
Optional<Set<UnifyPair>> opt = StrucTypeUnifyUtils.linkPairs(outerLeftPair, outerRightPair,
|
||||
pairsSmallerDot);
|
||||
if (!opt.isPresent())
|
||||
continue;
|
||||
// Linking has been found
|
||||
UnifyType typeD = outerLeftPair.getLhsType();
|
||||
UnifyType typeD1 = outerRightPair.getRhsType();
|
||||
// present already checked s.o.
|
||||
UnifyType typeDgen = fc.getLeftHandedType(typeD.getName()).get();
|
||||
// present already checked s.o.
|
||||
UnifyType typeD1gen = fc.getAncestors(typeDgen).stream().filter(x -> x.getName().equals(typeD1.getName()))
|
||||
.findAny().get();
|
||||
TypeParams typeDParams = typeD.getTypeParams();
|
||||
TypeParams typeDgenParams = typeDgen.getTypeParams();
|
||||
|
||||
Unifier unifD1gen = Unifier.identity();
|
||||
for (int i = 0; i < typeDParams.size(); i++)
|
||||
unifD1gen.add((PlaceholderType) typeDgenParams.get(i), typeDParams.get(i));
|
||||
Optional<Unifier> sigmaopt = new MartelliMontanariUnify().unify(unifD1gen.apply(typeD1gen), typeD);
|
||||
|
||||
if (!sigmaopt.isPresent())
|
||||
continue;
|
||||
// replace outerLeftPair.lhs and outerRightPair.rhs witch new Types
|
||||
Unifier sigma = sigmaopt.get();
|
||||
pairs.remove(outerLeftPair);
|
||||
pairs.remove(outerRightPair);
|
||||
pairs.add(UnifyTypeFactory.generateSmallerDotPair(sigma.apply(typeD), outerLeftPair.getRhsType()));
|
||||
pairs.add(UnifyTypeFactory.generateSmallerDotPair(outerRightPair.getLhsType(), sigma.apply(typeD1)));
|
||||
// TODO pairs.add mit sigma als Pair
|
||||
return Optional.of(pairs);
|
||||
}
|
||||
// No Linking found
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public boolean strucTypeErase1(UnifyPair pair, IFiniteClosure fc) {
|
||||
return super.erase1(pair, fc);
|
||||
}
|
||||
|
||||
public boolean strucTypeErase2(UnifyPair pair) {
|
||||
return super.erase3(pair);
|
||||
}
|
||||
|
||||
public Optional<UnifyPair> strucTypeSwap(UnifyPair pair) {
|
||||
return super.swap(pair);
|
||||
}
|
||||
|
||||
public Optional<Set<UnifyPair>> strucTypeSubst(Set<UnifyPair> pairs) {
|
||||
return super.subst(pairs);
|
||||
}
|
||||
|
||||
public Optional<Set<UnifyPair>> strucTypeRefl(Set<UnifyPair> pairs) {
|
||||
// Filter SMALLERDOT Pairs
|
||||
final Set<UnifyPair> pairsSmallerDot = pairs.stream().filter(p -> PairOperator.SMALLERDOT.equals(p.getPairOp()))
|
||||
.collect(Collectors.toSet());
|
||||
// System.out.println("Pairs to test: " + pairsSmallerDot);
|
||||
// Filter Tuples of Pairs for a potential Linking (t<T1,T1<T2,...,Tn<t)
|
||||
List<Pair<UnifyPair, UnifyPair>> tupleOfPotentialLinkings = new ArrayList<>();
|
||||
for (UnifyPair pair : pairsSmallerDot) {
|
||||
if (!(pair.getRhsType() instanceof PlaceholderType)) {
|
||||
// System.out.println("Pair not suitable for outerLeftPair: " + pair);
|
||||
continue;
|
||||
}
|
||||
// System.out.println("Try to find tuple of potential linkings for pair " + pair);
|
||||
pairsSmallerDot.stream().filter(p -> {
|
||||
// System.out.println(" Pair pair: " + pair);
|
||||
// System.out.println("Pair p: " + p);
|
||||
// System.out.println("p.lhs instnceof PH: " + (p.getLhsType() instanceof PlaceholderType));
|
||||
// System.out.println("p.rhs equals pair.lhs: " + (p.getRhsType().equals(pair.getLhsType())));
|
||||
return (p.getLhsType() instanceof PlaceholderType) && (p.getRhsType().equals(pair.getLhsType()));
|
||||
}).map(p -> {
|
||||
// System.out.println("Pair to map: " + p);
|
||||
return new Pair<>(pair, p);
|
||||
}).forEach(tupleOfPotentialLinkings::add);
|
||||
// System.out.println("tuple of potential linkings: " + tupleOfPotentialLinkings);
|
||||
}
|
||||
// Build Linking between the Pairs. Empty if no Linking is possible.
|
||||
for (Pair<UnifyPair, UnifyPair> tuple : tupleOfPotentialLinkings) {
|
||||
UnifyPair outerLeftPair = tuple.getKey();
|
||||
UnifyPair outerRightPair = tuple.getValue();
|
||||
// System.out.println("Try linking pair: " + outerLeftPair + ", " + outerRightPair);
|
||||
Optional<Set<UnifyPair>> opt = StrucTypeUnifyUtils.linkPairs(outerLeftPair, outerRightPair,
|
||||
pairsSmallerDot);
|
||||
// Remove Pairs of the Linking incl. outerLeft and outerRight, add
|
||||
// EQUALSDOT Pairs instead.
|
||||
if (opt.isPresent()) {
|
||||
// System.out.println("Linking found: " + opt.get());
|
||||
pairs.remove(outerLeftPair);
|
||||
pairs.remove(outerRightPair);
|
||||
pairs.removeAll(opt.get());
|
||||
// Get all Placeholder in Linking.
|
||||
Set<UnifyType> placeholderInLinking = new HashSet<>();
|
||||
opt.get().forEach(p -> {
|
||||
placeholderInLinking.add(p.getLhsType());
|
||||
placeholderInLinking.add(p.getRhsType());
|
||||
});
|
||||
// Generate and add new EQUALSDOT Pairs of Placeholder and
|
||||
// outermost UnifyType to the result.
|
||||
final UnifyType outermostUnifyType = outerLeftPair.getLhsType();
|
||||
placeholderInLinking.forEach(placeholder -> pairs
|
||||
.add(UnifyTypeFactory.generateEqualDotPair(placeholder, outermostUnifyType)));
|
||||
return Optional.of(pairs);
|
||||
}
|
||||
// System.out.println("No Linking found");
|
||||
}
|
||||
// No Linking was found.
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
}
|
129
src/de/dhbwstuttgart/strucTypes/Solve.java
Normal file
129
src/de/dhbwstuttgart/strucTypes/Solve.java
Normal file
@ -0,0 +1,129 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.exception.InconsistentConstraintsException;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.model.SolvedClass;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.InferTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.TypeExtract;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.TypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class Solve {
|
||||
|
||||
private Set<SubTypeConstraint> constraints = new HashSet<>();
|
||||
private IFiniteClosure fc;
|
||||
private InferredTypes inferredTypes = new InferredTypes();
|
||||
private ClassOrInterface clsA;
|
||||
private List<ClassOrInterface> generatedInterfaces = new ArrayList<>();
|
||||
|
||||
public Solve(Set<SubTypeConstraint> constraints, ClassOrInterface clsA, IFiniteClosure fc,
|
||||
InferredTypes inferredTypes, List<ClassOrInterface> generatedInterfaces) {
|
||||
this.constraints = constraints;
|
||||
this.fc = fc;
|
||||
this.inferredTypes = inferredTypes;
|
||||
this.clsA = clsA;
|
||||
this.generatedInterfaces = generatedInterfaces;
|
||||
}
|
||||
|
||||
public SolvedClass getSolvedClass() throws InconsistentConstraintsException {
|
||||
Set<UnifyPair> constraintsUnifyPair = this.constraints.stream().map(SubTypeConstraint::getAsUnifyPair)
|
||||
.collect(Collectors.toSet());
|
||||
StrucTypeUnify strucTypeUnify = new StrucTypeUnify(constraintsUnifyPair, this.fc);
|
||||
Set<UnifyPair> subst = strucTypeUnify.unify();
|
||||
|
||||
Map<String, TypePlaceholder> tphs = this.generateTPHMap(constraints);
|
||||
InferredTypes sigma = new InferredTypes();
|
||||
sigma.putAll(inferredTypes);
|
||||
sigma.putAll(
|
||||
StrucTypeUnifyUtils.convertEqualsdot(
|
||||
subst.stream()
|
||||
.filter(p -> p.getLhsType() instanceof PlaceholderType
|
||||
&& p.getPairOp().equals(PairOperator.EQUALSDOT))
|
||||
.collect(Collectors.toSet()),
|
||||
tphs));
|
||||
|
||||
Set<SubTypeConstraint> cs = StrucTypeUnifyUtils.convertSmallerdot(
|
||||
subst.stream().filter(p -> PairOperator.SMALLERDOT.equals(p.getPairOp())).collect(Collectors.toSet()),
|
||||
tphs);
|
||||
|
||||
List<GenericTypeVar> values = new ArrayList<>();
|
||||
// extract typeplaceholder (type variables) of clsA
|
||||
TypeVar typeVar = new TypeVar(inferredTypes);
|
||||
clsA.accept(typeVar);
|
||||
final ArrayList<RefTypeOrTPHOrWildcardOrGeneric> bounds = new ArrayList<>();
|
||||
final NullToken offset = new NullToken();
|
||||
// add type variables of clsA as GenericTypeVar to values of
|
||||
// tNew
|
||||
typeVar.getTypeVars().stream().map(tph -> new GenericTypeVar(tph.getName(), bounds, offset, offset))
|
||||
.forEach(gtv -> {
|
||||
if (values.stream().map(GenericTypeVar::getName).noneMatch(gtv.getName()::equals)) {
|
||||
values.add(gtv);
|
||||
};
|
||||
});
|
||||
// add type variables of cs as GenericRefType to values of
|
||||
// tNew
|
||||
cs.stream().flatMap(c -> Stream.of(c.getSubtype(), c.getSupertype())).filter(t -> t instanceof TypePlaceholder)
|
||||
.map(tph -> new GenericTypeVar(((TypePlaceholder) tph).getName(), bounds, offset, offset))
|
||||
.forEach(gtv -> {
|
||||
if (values.stream().map(GenericTypeVar::getName).noneMatch(gtv.getName()::equals)) {
|
||||
values.add(gtv);
|
||||
};
|
||||
});
|
||||
// add generics of all superclasses and superinterfaces of clsA to
|
||||
// values of tNew
|
||||
TypeExtract typeExtract = new TypeExtract();
|
||||
clsA.accept(typeExtract);
|
||||
typeExtract.getGenerics().forEach(gtv -> {
|
||||
if (values.stream().map(GenericTypeVar::getName).noneMatch(gtv.getName()::equals)) {
|
||||
values.add(gtv);
|
||||
};
|
||||
});
|
||||
GenericDeclarationList tNew = new GenericDeclarationList(values, offset);
|
||||
|
||||
if (!consistent(cs)) {
|
||||
throw new InconsistentConstraintsException();
|
||||
}
|
||||
return new SolvedClass(this.clsA.accept(new InferTypes(inferredTypes, tNew)), tNew,
|
||||
cs, this.generatedInterfaces);
|
||||
|
||||
}
|
||||
|
||||
private Map<String, TypePlaceholder> generateTPHMap(Set<SubTypeConstraint> constraints) {
|
||||
Map<String, TypePlaceholder> tphs = new HashMap<>();
|
||||
constraints.stream().forEach(c -> {
|
||||
if (c.getSubtype() instanceof TypePlaceholder) {
|
||||
TypePlaceholder subtype = (TypePlaceholder) c.getSubtype();
|
||||
tphs.put(subtype.getName(), subtype);
|
||||
}
|
||||
if (c.getSupertype() instanceof TypePlaceholder) {
|
||||
TypePlaceholder supertype = (TypePlaceholder) c.getSupertype();
|
||||
tphs.put(supertype.getName(), supertype);
|
||||
}
|
||||
});
|
||||
return tphs;
|
||||
}
|
||||
|
||||
private boolean consistent(Set<SubTypeConstraint> cs) {
|
||||
// TODO update inconsistencies
|
||||
return true;
|
||||
}
|
||||
}
|
63
src/de/dhbwstuttgart/strucTypes/StrucTYPE.java
Normal file
63
src/de/dhbwstuttgart/strucTypes/StrucTYPE.java
Normal file
@ -0,0 +1,63 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.DefaultASTVisitor;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.TYPEExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class StrucTYPE extends DefaultASTVisitor {
|
||||
|
||||
private ClassOrInterface clsA;
|
||||
private ConstraintsSet constraintsSet = new ConstraintsSet();
|
||||
private InferredTypes inferredTypes = new InferredTypes();
|
||||
|
||||
public StrucTYPE(ClassOrInterface clsA) {
|
||||
this.clsA = clsA;
|
||||
}
|
||||
|
||||
public ConstraintsSet getConstraints() {
|
||||
TYPEExpr typeExpr = new TYPEExpr();
|
||||
this.clsA.accept(typeExpr);
|
||||
this.clsA.getMethods().forEach(m -> m.accept(this));
|
||||
this.evaluateTypeExpr(typeExpr);
|
||||
return this.constraintsSet;
|
||||
}
|
||||
|
||||
public InferredTypes getInferredTypes() {
|
||||
return this.inferredTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
// Es gibt nur ein Return Statement
|
||||
Expression retexpr = ((Return) method.block.statements.get(0)).retexpr;
|
||||
|
||||
RefTypeOrTPHOrWildcardOrGeneric methodReturnType = method.getReturnType();
|
||||
RefTypeOrTPHOrWildcardOrGeneric retExprType = retexpr.getType();
|
||||
|
||||
// ordnet dem Methodentyp den Returntyp zu [sigma(Mt)]
|
||||
if (methodReturnType instanceof TypePlaceholder) {
|
||||
this.inferredTypes.put((TypePlaceholder) methodReturnType, retExprType);
|
||||
}
|
||||
if (methodReturnType instanceof RefType && retExprType instanceof TypePlaceholder) {
|
||||
this.inferredTypes.put((TypePlaceholder) retExprType, methodReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateTypeExpr(TYPEExpr typeExpr) {
|
||||
this.inferredTypes.putAll(typeExpr.getInferredTypes());
|
||||
this.inferredTypes.resolveTransitiveTypes();
|
||||
|
||||
ConstraintsSet constraints = typeExpr.getConstraints();
|
||||
constraints.inferTypes(this.inferredTypes);
|
||||
this.constraintsSet.addConstraintsSet(constraints);
|
||||
}
|
||||
|
||||
}
|
89
src/de/dhbwstuttgart/strucTypes/StrucTypeUnify.java
Normal file
89
src/de/dhbwstuttgart/strucTypes/StrucTypeUnify.java
Normal file
@ -0,0 +1,89 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class StrucTypeUnify {
|
||||
|
||||
private Set<UnifyPair> pairs;
|
||||
private IFiniteClosure fc;
|
||||
private RuleSetStrucType rules = new RuleSetStrucType();
|
||||
|
||||
public StrucTypeUnify(Set<UnifyPair> unifyPairs, IFiniteClosure finiteClosure) {
|
||||
this.pairs = unifyPairs;
|
||||
this.fc = finiteClosure;
|
||||
}
|
||||
|
||||
public Set<UnifyPair> unify() {
|
||||
Set<UnifyPair> pairs = this.applyTypeUnificationRules(this.pairs, fc);
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
private Set<UnifyPair> applyTypeUnificationRules(Set<UnifyPair> pairs, IFiniteClosure fc) {
|
||||
Set<UnifyPair> resultSet = new HashSet<>();
|
||||
|
||||
LinkedList<UnifyPair> pairQueue = new LinkedList<>();
|
||||
|
||||
pairs.forEach(p -> this.swapAddOrErase(p, fc, pairQueue));
|
||||
|
||||
while (!pairQueue.isEmpty()) {
|
||||
UnifyPair pair = pairQueue.pollFirst();
|
||||
|
||||
// reduce
|
||||
Optional<Set<UnifyPair>> optSet = rules.strucTypeReduce(pair);
|
||||
if (optSet.isPresent()) {
|
||||
optSet.get().forEach(p -> swapAddOrErase(p, fc, pairQueue));
|
||||
continue;
|
||||
}
|
||||
|
||||
// adapt1
|
||||
Optional<UnifyPair> opt = rules.strucTypeAdapt1(pair, fc);
|
||||
|
||||
if (opt.isPresent()) {
|
||||
this.swapAddOrErase(opt.get(), fc, pairQueue);
|
||||
continue;
|
||||
}
|
||||
|
||||
// none of the above rules applied
|
||||
resultSet.add(pair);
|
||||
}
|
||||
|
||||
// adapt2
|
||||
Optional<Set<UnifyPair>> adapt2 = rules.strucTypeAdapt2(resultSet, fc);
|
||||
if(adapt2.isPresent()){
|
||||
resultSet = this.applyTypeUnificationRules(adapt2.get(), fc);
|
||||
}
|
||||
|
||||
// subst
|
||||
Optional<Set<UnifyPair>> subst = rules.strucTypeSubst(resultSet);
|
||||
if(subst.isPresent()){
|
||||
resultSet = this.applyTypeUnificationRules(subst.get(), fc);
|
||||
}
|
||||
|
||||
// refl
|
||||
Optional<Set<UnifyPair>> refl = rules.strucTypeRefl(resultSet);
|
||||
if(refl.isPresent()){
|
||||
resultSet = this.applyTypeUnificationRules(refl.get(), fc);
|
||||
}
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private void swapAddOrErase(UnifyPair pair, IFiniteClosure fc, Collection<UnifyPair> collection) {
|
||||
// swap
|
||||
Optional<UnifyPair> opt = rules.strucTypeSwap(pair);
|
||||
UnifyPair unifyPair = opt.isPresent() ? opt.get() : pair;
|
||||
|
||||
// erase
|
||||
if (rules.strucTypeErase1(unifyPair, fc) || rules.strucTypeErase2(unifyPair))
|
||||
return;
|
||||
collection.add(unifyPair);
|
||||
}
|
||||
}
|
66
src/de/dhbwstuttgart/strucTypes/StrucTypeUnifyUtils.java
Normal file
66
src/de/dhbwstuttgart/strucTypes/StrucTypeUnifyUtils.java
Normal file
@ -0,0 +1,66 @@
|
||||
package de.dhbwstuttgart.strucTypes;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class StrucTypeUnifyUtils {
|
||||
|
||||
public static Optional<Set<UnifyPair>> linkPairs(UnifyPair outerLeft, UnifyPair outerRight,
|
||||
Collection<UnifyPair> pairs) {
|
||||
|
||||
Set<UnifyPair> resultLinking = new HashSet<>();
|
||||
|
||||
if (outerLeft.getRhsType().equals(outerRight.getLhsType())) {
|
||||
resultLinking.add(outerLeft);
|
||||
return Optional.of(resultLinking);
|
||||
}
|
||||
|
||||
List<UnifyPair> nextLinks = pairs.stream().filter(p -> outerLeft.getRhsType().equals(p.getLhsType()))
|
||||
.collect(Collectors.toList());
|
||||
for (UnifyPair nextLink : nextLinks) {
|
||||
Optional<Set<UnifyPair>> opt = linkPairs(nextLink, outerRight, pairs);
|
||||
if (opt.isPresent()) {
|
||||
resultLinking = opt.get();
|
||||
resultLinking.add(nextLink);
|
||||
return Optional.of(resultLinking);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static InferredTypes convertEqualsdot(Set<UnifyPair> pairs, Map<String, TypePlaceholder> tphs) {
|
||||
InferredTypes inferredTypes = new InferredTypes();
|
||||
if (!pairs.stream().allMatch(
|
||||
p -> PairOperator.EQUALSDOT.equals(p.getPairOp()) && p.getLhsType() instanceof PlaceholderType)) {
|
||||
throw new IllegalArgumentException("Not all UnifyPairs were EQUALSDOT pairs.");
|
||||
}
|
||||
for (UnifyPair pair : pairs) {
|
||||
TypePlaceholder lhs = (TypePlaceholder) UnifyTypeFactory.convert(pair.getLhsType(), tphs);
|
||||
RefTypeOrTPHOrWildcardOrGeneric rhs = UnifyTypeFactory.convert(pair.getRhsType(), tphs);
|
||||
inferredTypes.put(lhs, rhs);
|
||||
}
|
||||
return inferredTypes;
|
||||
}
|
||||
|
||||
public static Set<SubTypeConstraint> convertSmallerdot(Set<UnifyPair> pairs, Map<String, TypePlaceholder> tphs) {
|
||||
if (!pairs.stream().allMatch(p -> PairOperator.SMALLERDOT.equals(p.getPairOp()))) {
|
||||
throw new IllegalArgumentException("Not all UnifyPairs were SMALLERDOT pairs.");
|
||||
}
|
||||
return pairs.stream().map(p -> new SubTypeConstraint(UnifyTypeFactory.convert(p.getLhsType(), tphs),
|
||||
UnifyTypeFactory.convert(p.getRhsType(), tphs))).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package de.dhbwstuttgart.strucTypes.constraint;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
|
||||
public class ConstraintsSet {
|
||||
|
||||
private Set<SubTypeConstraint> subTypeConstraints;
|
||||
private Set<FieldConstraint> fieldConstraints;
|
||||
private Set<MethodConstraint> methodConstraints;
|
||||
|
||||
public ConstraintsSet() {
|
||||
this.subTypeConstraints = new HashSet<>();
|
||||
this.fieldConstraints = new HashSet<>();
|
||||
this.methodConstraints = new HashSet<>();
|
||||
}
|
||||
|
||||
public Set<SubTypeConstraint> getSubTypeConstraints() {
|
||||
return subTypeConstraints;
|
||||
}
|
||||
|
||||
public Set<FieldConstraint> getFieldConstraints() {
|
||||
return fieldConstraints;
|
||||
}
|
||||
|
||||
public Set<MethodConstraint> getMethodConstraints() {
|
||||
return methodConstraints;
|
||||
}
|
||||
|
||||
public void addConstraint(SubTypeConstraint constraint) {
|
||||
this.subTypeConstraints.add(constraint);
|
||||
}
|
||||
|
||||
public void addConstraint(FieldConstraint constraint) {
|
||||
this.fieldConstraints.add(constraint);
|
||||
}
|
||||
|
||||
public void addConstraint(MethodConstraint constraint) {
|
||||
this.methodConstraints.add(constraint);
|
||||
}
|
||||
|
||||
public void addConstraintsSet(ConstraintsSet constraintsSet) {
|
||||
constraintsSet.getSubTypeConstraints().forEach(this::addConstraint);
|
||||
constraintsSet.getFieldConstraints().forEach(this::addConstraint);
|
||||
constraintsSet.getMethodConstraints().forEach(this::addConstraint);
|
||||
}
|
||||
|
||||
public void inferTypes(InferredTypes inferredTypes) {
|
||||
this.subTypeConstraints.forEach(c -> c.inferTypes(inferredTypes));
|
||||
this.fieldConstraints.forEach(c -> c.inferTypes(inferredTypes));
|
||||
this.methodConstraints.forEach(c -> c.inferTypes(inferredTypes));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package de.dhbwstuttgart.strucTypes.constraint;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.InferTypes;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
|
||||
/**
|
||||
* fc(c, f, c') : Klasse/Typ c hat ein Feld f mit Typ c'
|
||||
*
|
||||
* @author mvr
|
||||
*
|
||||
*/
|
||||
public class FieldConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric classType;
|
||||
private String fieldName;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric fieldType;
|
||||
|
||||
public FieldConstraint(RefTypeOrTPHOrWildcardOrGeneric classType, String fieldName,
|
||||
RefTypeOrTPHOrWildcardOrGeneric fieldType) {
|
||||
this.classType = classType;
|
||||
this.fieldName = fieldName;
|
||||
this.fieldType = fieldType;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getFieldType() {
|
||||
return fieldType;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void inferTypes(InferredTypes inferredTypes) {
|
||||
// if (inferredTypes.containsKey(classType)) {
|
||||
// this.classType = inferredTypes.get(classType);
|
||||
// }
|
||||
// if (inferredTypes.containsKey(fieldType)) {
|
||||
// this.fieldType = inferredTypes.get(fieldType);
|
||||
// }
|
||||
InferTypes inferTypes = new InferTypes(inferredTypes);
|
||||
classType = classType.accept(inferTypes);
|
||||
fieldType = fieldType.accept(inferTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("F(%s, %s, %s)", this.classType, this.fieldName, this.fieldType);
|
||||
}
|
||||
|
||||
}
|
114
src/de/dhbwstuttgart/strucTypes/constraint/MethodConstraint.java
Normal file
114
src/de/dhbwstuttgart/strucTypes/constraint/MethodConstraint.java
Normal file
@ -0,0 +1,114 @@
|
||||
package de.dhbwstuttgart.strucTypes.constraint;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.InferTypes;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
/**
|
||||
* mc(c, m, C, (c', C')) : Klasse/Typ c hat Methode m mit Argumenten von Typ C
|
||||
* mit R<>ckgabewert c' und Subtyp-Constraints C <. C' wobei C = {c1,... , cn)
|
||||
*
|
||||
* @author mvr
|
||||
*
|
||||
*/
|
||||
public class MethodConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric classType;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric returnType;
|
||||
private String methodName;
|
||||
private List<SubTypeConstraint> arguments;
|
||||
|
||||
public MethodConstraint(RefTypeOrTPHOrWildcardOrGeneric classType, String methodName,
|
||||
List<SubTypeConstraint> arguments, RefTypeOrTPHOrWildcardOrGeneric returnType) {
|
||||
this.classType = classType;
|
||||
this.returnType = returnType;
|
||||
this.methodName = methodName;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getClassType() {
|
||||
return classType;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getReturnType() {
|
||||
return returnType;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public List<SubTypeConstraint> getArguments() {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
public void addArguments(SubTypeConstraint... subTypeConstraints) {
|
||||
for (SubTypeConstraint subTypeConstraint : subTypeConstraints) {
|
||||
this.arguments.add(subTypeConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
public void addArguments(RefTypeOrTPHOrWildcardOrGeneric... parameters) {
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric parameter : parameters) {
|
||||
Token offset = parameter.getOffset();
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(offset);
|
||||
SubTypeConstraint subTypeConstraint = new SubTypeConstraint(parameter, tph);
|
||||
this.arguments.add(subTypeConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
public void inferTypes(InferredTypes inferredTypes) {
|
||||
// if (inferredTypes.containsKey(classType)) {
|
||||
// this.classType = inferredTypes.get(classType);
|
||||
// }
|
||||
// if (inferredTypes.containsKey(returnType)) {
|
||||
// this.returnType = inferredTypes.get(returnType);
|
||||
// }
|
||||
InferTypes inferTypes = new InferTypes(inferredTypes);
|
||||
classType = classType.accept(inferTypes);
|
||||
returnType = returnType.accept(inferTypes);
|
||||
arguments.forEach(c -> c.inferTypes(inferredTypes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("M(");
|
||||
sb.append(this.classType);
|
||||
sb.append(", ");
|
||||
sb.append(this.methodName);
|
||||
sb.append(", [");
|
||||
List<SubTypeConstraint> arguments = this.arguments;
|
||||
if (!arguments.isEmpty()) {
|
||||
Iterator<SubTypeConstraint> iterator = arguments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric subtype = iterator.next().getSubtype();
|
||||
sb.append(subtype.toString());
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append("],(");
|
||||
sb.append(this.returnType);
|
||||
sb.append(", [");
|
||||
if (!arguments.isEmpty()) {
|
||||
Iterator<SubTypeConstraint> iterator = arguments.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric supertype = iterator.next().getSupertype();
|
||||
sb.append(supertype.toString());
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.append("]))");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package de.dhbwstuttgart.strucTypes.constraint;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.exception.ImpossibleSubTypeException;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.strucTypes.visitor.InferTypes;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||
|
||||
/**
|
||||
* c <. c' : c ist subtyp von c'
|
||||
*
|
||||
* @author mvr
|
||||
*
|
||||
*/
|
||||
public class SubTypeConstraint {
|
||||
|
||||
private RefTypeOrTPHOrWildcardOrGeneric subtype;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric supertype;
|
||||
|
||||
public SubTypeConstraint(RefTypeOrTPHOrWildcardOrGeneric subtype, RefTypeOrTPHOrWildcardOrGeneric supertype) {
|
||||
this.subtype = subtype;
|
||||
this.supertype = supertype;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getSubtype() {
|
||||
return subtype;
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric getSupertype() {
|
||||
return supertype;
|
||||
}
|
||||
|
||||
public void inferTypes(InferredTypes inferredTypes) {
|
||||
// if (inferredTypes.containsKey(subtype)) {
|
||||
// this.subtype = inferredTypes.get(subtype);
|
||||
// }
|
||||
// if (inferredTypes.containsKey(supertype)) {
|
||||
// this.supertype = inferredTypes.get(supertype);
|
||||
// }
|
||||
InferTypes inferTypes = new InferTypes(inferredTypes);
|
||||
subtype = subtype.accept(inferTypes);
|
||||
supertype = supertype.accept(inferTypes);
|
||||
}
|
||||
|
||||
|
||||
public boolean checkConstraintPossible() throws ImpossibleSubTypeException {
|
||||
if (this.subtype instanceof RefType && this.supertype instanceof RefType) {
|
||||
Class<?> subClass = this.createClass(((RefType) this.subtype).getName().toString());
|
||||
Class<?> superClass = this.createClass(((RefType) this.supertype).getName().toString());
|
||||
if (subClass != null && superClass != null) {
|
||||
if (superClass.isAssignableFrom(subClass))
|
||||
return true;
|
||||
else
|
||||
throw new ImpossibleSubTypeException(
|
||||
String.format("%s ist kein subtyp von %s", subClass.getName(), superClass.getName()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public UnifyPair getAsUnifyPair(){
|
||||
UnifyType tl = UnifyTypeFactory.convert(this.subtype);
|
||||
UnifyType tr = UnifyTypeFactory.convert(this.supertype);
|
||||
return UnifyTypeFactory.generateSmallerDotPair(tl, tr);
|
||||
}
|
||||
|
||||
private Class<?> createClass(String name) {
|
||||
try {
|
||||
return ClassLoader.getSystemClassLoader().loadClass(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((subtype == null) ? 0 : subtype.hashCode());
|
||||
result = prime * result + ((supertype == null) ? 0 : supertype.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SubTypeConstraint other = (SubTypeConstraint) obj;
|
||||
if (subtype == null) {
|
||||
if (other.subtype != null)
|
||||
return false;
|
||||
} else if (!subtype.equals(other.subtype))
|
||||
return false;
|
||||
if (supertype == null) {
|
||||
if (other.supertype != null)
|
||||
return false;
|
||||
} else if (!supertype.equals(other.supertype))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s <* %s", this.subtype, this.supertype);
|
||||
}
|
||||
|
||||
}
|
503
src/de/dhbwstuttgart/strucTypes/diagram/Trans.ucls
Normal file
503
src/de/dhbwstuttgart/strucTypes/diagram/Trans.ucls
Normal file
@ -0,0 +1,503 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<class-diagram version="1.2.2" icons="false" always-add-relationships="false" generalizations="true" realizations="true"
|
||||
associations="true" dependencies="false" nesting-relationships="true" router="FAN">
|
||||
<class id="1" language="java" name="de.dhbwstuttgart.strucTypes.StrucTYPE" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/StrucTYPE.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="136" y="291"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="2" language="java" name="de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/constraint/ConstraintsSet.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="593" y="277"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="3" language="java" name="de.dhbwstuttgart.strucTypes.model.InferredTypes" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/model/InferredTypes.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="626" y="450"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="4" language="java" name="de.dhbwstuttgart.strucTypes.visitor.TYPEExpr" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/TYPEExpr.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="242" y="464"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="5" language="java" name="de.dhbwstuttgart.strucTypes.visitor.DefaultASTVisitor" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/DefaultASTVisitor.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="601" y="86"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="6" language="java" name="de.dhbwstuttgart.strucTypes.Construct" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/Construct.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="1019" y="494"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="7" language="java" name="de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/constraint/SubTypeConstraint.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="220" x="1088" y="164"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="8" language="java" name="de.dhbwstuttgart.strucTypes.exception.IllegalInterfaceTypeException"
|
||||
project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/exception/IllegalInterfaceTypeException.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="218" x="1151" y="371"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="9" language="java" name="de.dhbwstuttgart.strucTypes.exception.ImpossibleSubTypeException"
|
||||
project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/exception/ImpossibleSubTypeException.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="218" x="1156" y="472"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="10" language="java" name="de.dhbwstuttgart.strucTypes.Solve" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/Solve.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="587" y="685"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="11" language="java" name="de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure"
|
||||
project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="665" y="849"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</interface>
|
||||
<class id="12" language="java" name="de.dhbwstuttgart.strucTypes.StrucTypeUnify" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/StrucTypeUnify.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="334" y="859"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="13" language="java" name="de.dhbwstuttgart.strucTypes.StrucTypeUnifyUtils" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/StrucTypeUnifyUtils.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="315" y="642"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="14" language="java" name="de.dhbwstuttgart.strucTypes.exception.InconsistentConstraintsException"
|
||||
project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/exception/InconsistentConstraintsException.java"
|
||||
binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="1241" y="600"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="15" language="java" name="de.dhbwstuttgart.strucTypes.model.SolvedClass" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/model/SolvedClass.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="782" y="572"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="16" language="java" name="de.dhbwstuttgart.strucTypes.visitor.InferTypes" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/InferTypes.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="864" y="690"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="17" language="java" name="de.dhbwstuttgart.strucTypes.visitor.TypeExtract" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/TypeExtract.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="198" x="-2" y="553"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="18" language="java" name="de.dhbwstuttgart.strucTypes.visitor.TypeVar" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/TypeVar.java" binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="198" x="-2" y="640"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="19" language="java" name="de.dhbwstuttgart.typeinference.unify.model.UnifyPair" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="292" y="767"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="20" language="java" name="de.dhbwstuttgart.strucTypes.constraint.FieldConstraint" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/constraint/FieldConstraint.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="862" y="72"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="21" language="java" name="de.dhbwstuttgart.strucTypes.constraint.MethodConstraint" project="JavaTXcompiler"
|
||||
file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/constraint/MethodConstraint.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="1110" y="77"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</class>
|
||||
<interface id="22" language="java" name="de.dhbwstuttgart.strucTypes.visitor.ASTReturnVisitor"
|
||||
project="JavaTXcompiler" file="/JavaTXcompiler/src/de/dhbwstuttgart/strucTypes/visitor/ASTReturnVisitor.java"
|
||||
binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="60" width="198" x="1031" y="703"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</display>
|
||||
</interface>
|
||||
<association id="23">
|
||||
<end type="SOURCE" refId="1" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="24" name="constraintsSet"/>
|
||||
<multiplicity id="25" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="2" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="26">
|
||||
<end type="SOURCE" refId="2" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="27" name="fieldConstraints"/>
|
||||
<multiplicity id="28" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="20" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="29">
|
||||
<end type="SOURCE" refId="4"/>
|
||||
<end type="TARGET" refId="17"/>
|
||||
</dependency>
|
||||
<generalization id="30">
|
||||
<end type="SOURCE" refId="1"/>
|
||||
<end type="TARGET" refId="5"/>
|
||||
</generalization>
|
||||
<generalization id="31">
|
||||
<end type="SOURCE" refId="4"/>
|
||||
<end type="TARGET" refId="5"/>
|
||||
</generalization>
|
||||
<generalization id="32">
|
||||
<end type="SOURCE" refId="17"/>
|
||||
<end type="TARGET" refId="5"/>
|
||||
</generalization>
|
||||
<association id="33">
|
||||
<end type="SOURCE" refId="15" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="34" name="constraints"/>
|
||||
<multiplicity id="35" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="36">
|
||||
<end type="SOURCE" refId="4" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="37" name="constraints"/>
|
||||
<multiplicity id="38" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="2" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="39">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="13"/>
|
||||
</dependency>
|
||||
<dependency id="40">
|
||||
<end type="SOURCE" refId="6"/>
|
||||
<end type="TARGET" refId="9"/>
|
||||
</dependency>
|
||||
<association id="41">
|
||||
<end type="SOURCE" refId="17" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="42" name="grtToTphMap"/>
|
||||
<multiplicity id="43" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="44">
|
||||
<end type="SOURCE" refId="7"/>
|
||||
<end type="TARGET" refId="16"/>
|
||||
</dependency>
|
||||
<association id="45">
|
||||
<end type="SOURCE" refId="17" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="46" name="subTypeConstraints"/>
|
||||
<multiplicity id="47" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="48">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="18"/>
|
||||
</dependency>
|
||||
<association id="49">
|
||||
<end type="SOURCE" refId="2" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="50" name="subTypeConstraints"/>
|
||||
<multiplicity id="51" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="52">
|
||||
<end type="SOURCE" refId="21" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="53" name="arguments"/>
|
||||
<multiplicity id="54" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="55">
|
||||
<end type="SOURCE" refId="4"/>
|
||||
<end type="TARGET" refId="7"/>
|
||||
</dependency>
|
||||
<association id="56">
|
||||
<end type="SOURCE" refId="6" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="57" name="subTypeConstraints"/>
|
||||
<multiplicity id="58" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="59">
|
||||
<end type="SOURCE" refId="21"/>
|
||||
<end type="TARGET" refId="3"/>
|
||||
</dependency>
|
||||
<dependency id="60">
|
||||
<end type="SOURCE" refId="21"/>
|
||||
<end type="TARGET" refId="16"/>
|
||||
</dependency>
|
||||
<dependency id="61">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="12"/>
|
||||
</dependency>
|
||||
<dependency id="62">
|
||||
<end type="SOURCE" refId="20"/>
|
||||
<end type="TARGET" refId="16"/>
|
||||
</dependency>
|
||||
<association id="63">
|
||||
<end type="SOURCE" refId="10" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="64" name="fc"/>
|
||||
<multiplicity id="65" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="11" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<generalization id="66">
|
||||
<end type="SOURCE" refId="6"/>
|
||||
<end type="TARGET" refId="5"/>
|
||||
</generalization>
|
||||
<association id="67">
|
||||
<end type="SOURCE" refId="6" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="68" name="inferredTypes"/>
|
||||
<multiplicity id="69" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="70">
|
||||
<end type="SOURCE" refId="1"/>
|
||||
<end type="TARGET" refId="4"/>
|
||||
</dependency>
|
||||
<association id="71">
|
||||
<end type="SOURCE" refId="4" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="72" name="inferredTypes"/>
|
||||
<multiplicity id="73" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="74">
|
||||
<end type="SOURCE" refId="2"/>
|
||||
<end type="TARGET" refId="3"/>
|
||||
</dependency>
|
||||
<association id="75">
|
||||
<end type="SOURCE" refId="3" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="76" name="EMPTY"/>
|
||||
<multiplicity id="77" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="78">
|
||||
<end type="SOURCE" refId="13"/>
|
||||
<end type="TARGET" refId="3"/>
|
||||
</dependency>
|
||||
<dependency id="79">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="16"/>
|
||||
</dependency>
|
||||
<dependency id="80">
|
||||
<end type="SOURCE" refId="6"/>
|
||||
<end type="TARGET" refId="8"/>
|
||||
</dependency>
|
||||
<association id="81">
|
||||
<end type="SOURCE" refId="1" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="82" name="inferredTypes"/>
|
||||
<multiplicity id="83" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="84">
|
||||
<end type="SOURCE" refId="10" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="85" name="inferredTypes"/>
|
||||
<multiplicity id="86" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="87">
|
||||
<end type="SOURCE" refId="18" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="88" name="inferredTypes"/>
|
||||
<multiplicity id="89" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="90">
|
||||
<end type="SOURCE" refId="16" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="91" name="inferredTypes"/>
|
||||
<multiplicity id="92" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="93">
|
||||
<end type="SOURCE" refId="12" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="94" name="fc"/>
|
||||
<multiplicity id="95" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="11" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="96">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="14"/>
|
||||
</dependency>
|
||||
<realization id="97">
|
||||
<end type="SOURCE" refId="16"/>
|
||||
<end type="TARGET" refId="22"/>
|
||||
</realization>
|
||||
<dependency id="98">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="15"/>
|
||||
</dependency>
|
||||
<association id="99">
|
||||
<end type="SOURCE" refId="6" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="100" name="constraintsSet"/>
|
||||
<multiplicity id="101" minimum="0" maximum="1"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="2" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="102">
|
||||
<end type="SOURCE" refId="20"/>
|
||||
<end type="TARGET" refId="3"/>
|
||||
</dependency>
|
||||
<association id="103">
|
||||
<end type="SOURCE" refId="10" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="104" name="constraints"/>
|
||||
<multiplicity id="105" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="106">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="19"/>
|
||||
</dependency>
|
||||
<association id="107">
|
||||
<end type="SOURCE" refId="12" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="108" name="pairs"/>
|
||||
<multiplicity id="109" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="19" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<dependency id="110">
|
||||
<end type="SOURCE" refId="10"/>
|
||||
<end type="TARGET" refId="17"/>
|
||||
</dependency>
|
||||
<dependency id="111">
|
||||
<end type="SOURCE" refId="7"/>
|
||||
<end type="TARGET" refId="3"/>
|
||||
</dependency>
|
||||
<association id="112">
|
||||
<end type="SOURCE" refId="2" navigable="false" variant="ASSOCIATION">
|
||||
<attribute id="113" name="methodConstraints"/>
|
||||
<multiplicity id="114" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="21" navigable="true" variant="ASSOCIATION"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="false"
|
||||
sort-features="false" accessors="false" visibility="false">
|
||||
<attributes public="false" package="false" protected="false" private="false" static="false"/>
|
||||
<operations public="false" package="false" protected="false" private="false" static="false"/>
|
||||
</classifier-display>
|
||||
<association-display labels="true" multiplicity="true"/>
|
||||
</class-diagram>
|
@ -0,0 +1,27 @@
|
||||
package de.dhbwstuttgart.strucTypes.exception;
|
||||
|
||||
public class IllegalInterfaceTypeException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public IllegalInterfaceTypeException() {
|
||||
}
|
||||
|
||||
public IllegalInterfaceTypeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public IllegalInterfaceTypeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public IllegalInterfaceTypeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public IllegalInterfaceTypeException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package de.dhbwstuttgart.strucTypes.exception;
|
||||
|
||||
public class ImpossibleSubTypeException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ImpossibleSubTypeException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ImpossibleSubTypeException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public ImpossibleSubTypeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ImpossibleSubTypeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ImpossibleSubTypeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package de.dhbwstuttgart.strucTypes.exception;
|
||||
|
||||
public class InconsistentConstraintsException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InconsistentConstraintsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InconsistentConstraintsException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public InconsistentConstraintsException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InconsistentConstraintsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InconsistentConstraintsException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package de.dhbwstuttgart.strucTypes.model;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
|
||||
public class ClassOrInterfaceFactory {
|
||||
|
||||
public static Optional<ClassOrInterface> createClass(JavaClassName name) {
|
||||
try {
|
||||
return Optional.of(ASTFactory.createClass(ClassLoader.getSystemClassLoader().loadClass(name.toString())));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static Optional<ClassOrInterface> createClass(RefType refType) {
|
||||
return ClassOrInterfaceFactory.createClass(refType.getName());
|
||||
}
|
||||
}
|
107
src/de/dhbwstuttgart/strucTypes/model/InferredTypes.java
Normal file
107
src/de/dhbwstuttgart/strucTypes/model/InferredTypes.java
Normal file
@ -0,0 +1,107 @@
|
||||
package de.dhbwstuttgart.strucTypes.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
public class InferredTypes implements Map<RefTypeOrTPHOrWildcardOrGeneric, RefTypeOrTPHOrWildcardOrGeneric> {
|
||||
|
||||
private Map<RefTypeOrTPHOrWildcardOrGeneric, RefTypeOrTPHOrWildcardOrGeneric> inferredTypes = new HashMap<>();
|
||||
|
||||
public static final InferredTypes EMPTY = new InferredTypes();
|
||||
|
||||
public void resolveTransitiveTypes() {
|
||||
Set<RefTypeOrTPHOrWildcardOrGeneric> keySet = this.inferredTypes.keySet();
|
||||
for (RefTypeOrTPHOrWildcardOrGeneric key : keySet) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric value = this.inferredTypes.get(key);
|
||||
if (value instanceof TypePlaceholder && keySet.contains(value)) {
|
||||
this.inferredTypes.put(key, this.inferredTypes.get(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return inferredTypes.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return inferredTypes.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return inferredTypes.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return inferredTypes.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefTypeOrTPHOrWildcardOrGeneric get(Object key) {
|
||||
return inferredTypes.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefTypeOrTPHOrWildcardOrGeneric put(RefTypeOrTPHOrWildcardOrGeneric key, RefTypeOrTPHOrWildcardOrGeneric value) {
|
||||
return inferredTypes.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefTypeOrTPHOrWildcardOrGeneric remove(Object key) {
|
||||
return inferredTypes.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends RefTypeOrTPHOrWildcardOrGeneric, ? extends RefTypeOrTPHOrWildcardOrGeneric> m) {
|
||||
inferredTypes.putAll(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
inferredTypes.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RefTypeOrTPHOrWildcardOrGeneric> keySet() {
|
||||
return inferredTypes.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RefTypeOrTPHOrWildcardOrGeneric> values() {
|
||||
return inferredTypes.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<java.util.Map.Entry<RefTypeOrTPHOrWildcardOrGeneric, RefTypeOrTPHOrWildcardOrGeneric>> entrySet() {
|
||||
return inferredTypes.entrySet();
|
||||
}
|
||||
|
||||
public RefTypeOrTPHOrWildcardOrGeneric infer(RefTypeOrTPHOrWildcardOrGeneric type){
|
||||
return inferredTypes.get(type) != null ? inferredTypes.get(type) : type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "[";
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> iterator = this.inferredTypes.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = iterator.next();
|
||||
s += type + " -> " + inferredTypes.get(type);
|
||||
if (iterator.hasNext()) {
|
||||
s += ", ";
|
||||
}
|
||||
}
|
||||
s += "]";
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
58
src/de/dhbwstuttgart/strucTypes/model/SolvedClass.java
Normal file
58
src/de/dhbwstuttgart/strucTypes/model/SolvedClass.java
Normal file
@ -0,0 +1,58 @@
|
||||
package de.dhbwstuttgart.strucTypes.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
|
||||
public class SolvedClass extends ClassOrInterface {
|
||||
|
||||
private Set<SubTypeConstraint> constraints = new HashSet<>();
|
||||
private List<ClassOrInterface> generatedInterfaces = new ArrayList<>();
|
||||
|
||||
public SolvedClass(int modifiers, JavaClassName name, List<Field> fielddecl,
|
||||
List<Method> methods, List<Constructor> constructors, GenericDeclarationList genericClassParameters,
|
||||
RefType superClass, Boolean isInterface, List<RefType> implementedInterfaces, Token offset,
|
||||
Set<SubTypeConstraint> constraints, List<ClassOrInterface> generatedInterfaces) {
|
||||
super(modifiers, name, fielddecl, methods, constructors, genericClassParameters, superClass, isInterface,
|
||||
implementedInterfaces, offset);
|
||||
this.constraints = constraints;
|
||||
this.generatedInterfaces = generatedInterfaces;
|
||||
}
|
||||
|
||||
public SolvedClass(ClassOrInterface classOrInterface, Set<SubTypeConstraint> constraints,
|
||||
List<ClassOrInterface> generatedInterfaces) {
|
||||
this(classOrInterface.getModifiers(), classOrInterface.getClassName(), classOrInterface.getFieldDecl(),
|
||||
classOrInterface.getMethods(), classOrInterface.getConstructors(), classOrInterface.getGenerics(),
|
||||
classOrInterface.getSuperClass(), classOrInterface.isInterface, classOrInterface.getSuperInterfaces(),
|
||||
classOrInterface.getOffset(), constraints, generatedInterfaces);
|
||||
}
|
||||
|
||||
public SolvedClass(ClassOrInterface classOrInterface, GenericDeclarationList generics,
|
||||
Set<SubTypeConstraint> constraints, List<ClassOrInterface> generatedInterfaces) {
|
||||
this(classOrInterface.getModifiers(), classOrInterface.getClassName(), classOrInterface.getFieldDecl(),
|
||||
classOrInterface.getMethods(), classOrInterface.getConstructors(), generics,
|
||||
classOrInterface.getSuperClass(), classOrInterface.isInterface, classOrInterface.getSuperInterfaces(),
|
||||
classOrInterface.getOffset(), constraints, generatedInterfaces);
|
||||
}
|
||||
|
||||
public Set<SubTypeConstraint> getConstraints() {
|
||||
return this.constraints;
|
||||
}
|
||||
|
||||
public List<ClassOrInterface> getGeneratedInterfaces() {
|
||||
return generatedInterfaces;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package de.dhbwstuttgart.strucTypes.printutils;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.FieldConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.MethodConstraint;
|
||||
import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
|
||||
public class PrintConstraints {
|
||||
|
||||
public void print(ConstraintsSet constraintsSet) {
|
||||
printSubTypeConstraints(constraintsSet.getSubTypeConstraints());
|
||||
printFieldConstraints(constraintsSet.getFieldConstraints());
|
||||
printMethodConstraints(constraintsSet.getMethodConstraints());
|
||||
}
|
||||
|
||||
public void printSubTypeConstraints(Set<SubTypeConstraint> constraints) {
|
||||
System.out.println("\n SubTypeConstraints:");
|
||||
constraints.forEach(System.out::println);
|
||||
// constraints.forEach(c -> System.out
|
||||
// .println(String.format("%s <* %s", c.getSubtype().toString(),
|
||||
// c.getSupertype().toString())));
|
||||
}
|
||||
|
||||
public void printSubTypeConstraintsAsUnifyPair(Set<UnifyPair> constraints){
|
||||
System.out.println("\n SubTypeConstraints:");
|
||||
constraints.forEach(System.out::println);
|
||||
}
|
||||
|
||||
public void printFieldConstraints(Set<FieldConstraint> constraints) {
|
||||
System.out.println("\n FieldConstraints:");
|
||||
constraints.forEach(System.out::println);
|
||||
// constraints.forEach(c -> System.out.println(String.format("F(%s, %s,
|
||||
// %s)", c.getClassType().toString(),
|
||||
// c.getFieldName(), c.getFieldType().toString())));
|
||||
}
|
||||
|
||||
public void printMethodConstraints(Set<MethodConstraint> constraints) {
|
||||
System.out.println("\n MethodConstraints:");
|
||||
constraints.forEach(System.out::println);
|
||||
// constraints.forEach(c -> {
|
||||
// StringBuilder sb = new StringBuilder("M(");
|
||||
// sb.append(c.getClassType().toString());
|
||||
// sb.append(", ");
|
||||
// sb.append(c.getMethodName());
|
||||
// sb.append(", [");
|
||||
// List<SubTypeConstraint> arguments = c.getArguments();
|
||||
// if (!arguments.isEmpty()) {
|
||||
// Iterator<SubTypeConstraint> iterator = arguments.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// RefTypeOrTPHOrWildcardOrGeneric subtype =
|
||||
// iterator.next().getSubtype();
|
||||
// sb.append(subtype.toString());
|
||||
// if (iterator.hasNext()) {
|
||||
// sb.append(", ");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// sb.append("],(");
|
||||
// sb.append(c.getReturnType().toString());
|
||||
// sb.append(", [");
|
||||
// if (!arguments.isEmpty()) {
|
||||
// Iterator<SubTypeConstraint> iterator = arguments.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// RefTypeOrTPHOrWildcardOrGeneric supertype =
|
||||
// iterator.next().getSupertype();
|
||||
// sb.append(supertype.toString());
|
||||
// if (iterator.hasNext()) {
|
||||
// sb.append(", ");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// sb.append("]))");
|
||||
// System.out.println(sb.toString());
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package de.dhbwstuttgart.strucTypes.printutils;
|
||||
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
|
||||
public class PrintInferredTypes {
|
||||
|
||||
public static void print(InferredTypes inferredTypes){
|
||||
System.out.println("\n Inferred Types:");
|
||||
inferredTypes.keySet().forEach(key -> System.out.println("[" + key + " -> " + inferredTypes.get(key) + "]"));
|
||||
}
|
||||
}
|
@ -0,0 +1,405 @@
|
||||
package de.dhbwstuttgart.strucTypes.printutils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.AssignToLocal;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
||||
import de.dhbwstuttgart.syntaxtree.ASTVisitor;
|
||||
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||
import de.dhbwstuttgart.syntaxtree.Field;
|
||||
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
|
||||
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ArgumentList;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Assign;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.AssignToField;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.BinaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Block;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.CastExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.DoStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.EmptyStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ExpressionReceiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.FieldVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ForStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.IfStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.InstanceOf;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.MethodCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewArray;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.NewClass;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Receiver;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Return;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.ReturnVoid;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.StaticClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Super;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.This;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.UnaryExpr;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.WhileStmt;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Literal;
|
||||
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;
|
||||
|
||||
public class SyntaxTreePrinter implements ASTVisitor {
|
||||
|
||||
private InferredTypes inferredTypes;
|
||||
|
||||
public SyntaxTreePrinter() {
|
||||
this(InferredTypes.EMPTY);
|
||||
}
|
||||
|
||||
public SyntaxTreePrinter(InferredTypes inferredTypes) {
|
||||
this.inferredTypes = inferredTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SourceFile sourceFile) {
|
||||
sourceFile.KlassenVektor.forEach(cl -> cl.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ClassOrInterface classOrInterface) {
|
||||
JavaClassName className = classOrInterface.getClassName();
|
||||
List<Field> fields = classOrInterface.getFieldDecl();
|
||||
List<Method> methods = classOrInterface.getMethods();
|
||||
RefType superClass = classOrInterface.getSuperClass();
|
||||
Collection<RefType> implementedInterfaces = classOrInterface.getSuperInterfaces();
|
||||
GenericDeclarationList generics = classOrInterface.getGenerics();
|
||||
|
||||
System.out.print("\nclass: " + className);
|
||||
Iterator<GenericTypeVar> iterator = generics.iterator();
|
||||
if (iterator.hasNext()) {
|
||||
System.out.print(" <");
|
||||
while (iterator.hasNext()) {
|
||||
GenericTypeVar g = iterator.next();
|
||||
g.accept(this);
|
||||
if (iterator.hasNext()) {
|
||||
System.out.print(", ");
|
||||
}
|
||||
}
|
||||
System.out.print(">");
|
||||
}
|
||||
System.out.println();
|
||||
|
||||
fields.forEach(f -> f.accept(this));
|
||||
methods.forEach(m -> m.accept(this));
|
||||
|
||||
System.out.print("\n superClass: ");
|
||||
superClass.accept(this);
|
||||
System.out.println();
|
||||
|
||||
if (!implementedInterfaces.isEmpty()) {
|
||||
System.out.println("\n implemented Interfaces: ");
|
||||
implementedInterfaces.forEach(i -> i.accept(this));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Field field) {
|
||||
String name = field.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = field.getType();
|
||||
System.out.print("field: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Method method) {
|
||||
String name = method.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric returnType = method.getReturnType();
|
||||
ParameterList parameterList = method.getParameterList();
|
||||
System.out.print("\n method: " + name + " : ");
|
||||
returnType.accept(this);
|
||||
System.out.println();
|
||||
parameterList.accept(this);
|
||||
method.block.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Block block) {
|
||||
block.statements.forEach(s -> s.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ArgumentList argumentList) {
|
||||
List<Expression> arguments = argumentList.getArguments();
|
||||
if (!arguments.isEmpty()) {
|
||||
System.out.println("arguments: ");
|
||||
arguments.forEach(a -> a.accept(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ParameterList formalParameters) {
|
||||
List<FormalParameter> formalparalist = formalParameters.getFormalparalist();
|
||||
formalparalist.forEach(p -> p.accept(this));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FormalParameter formalParameter) {
|
||||
String name = formalParameter.getName();
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = formalParameter.getType();
|
||||
System.out.print("parameter: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
String name = methodCall.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = methodCall.getType();
|
||||
ArgumentList argumentList = methodCall.getArgumentList();
|
||||
Receiver receiver = methodCall.receiver;
|
||||
System.out.print("methodCall: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
argumentList.accept(this);
|
||||
System.out.print("receiver: ");
|
||||
receiver.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Return aReturn) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = aReturn.getType();
|
||||
System.out.print("returnType: ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
aReturn.retexpr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVar localVar) {
|
||||
String name = localVar.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = localVar.getType();
|
||||
System.out.print("localVar: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LocalVarDecl localVarDecl) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(FieldVar fieldVar) {
|
||||
String name = fieldVar.fieldVarName;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = fieldVar.getType();
|
||||
Expression receiver = fieldVar.receiver;
|
||||
System.out.print("fieldVar: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
System.out.println("receiver: ");
|
||||
receiver.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CastExpr castExpr) {
|
||||
Expression expr = castExpr.expr;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = castExpr.getType();
|
||||
System.out.print("castExpr: ");
|
||||
expr.accept(this);
|
||||
System.out.print("typeCastExpr: ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewClass newClass) {
|
||||
String name = newClass.name;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = newClass.getType();
|
||||
ArgumentList argumentList = newClass.getArgumentList();
|
||||
System.out.print("new: " + name + " : ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
argumentList.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(This aThis) {
|
||||
ArgumentList arglist = aThis.arglist;
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = aThis.getType();
|
||||
System.out.print("this : ");
|
||||
type.accept(this);
|
||||
if (arglist != null)
|
||||
arglist.accept(this);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType refType) {
|
||||
System.out.print(refType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
if (inferredTypes.get(typePlaceholder) != null) {
|
||||
inferredTypes.get(typePlaceholder).accept(this);
|
||||
} else {
|
||||
System.out.print(typePlaceholder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(NewArray newArray) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ReturnVoid aReturn) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StaticClassName staticClassName) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Super aSuper) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(LambdaExpression lambdaExpression) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(WhileStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DoStmt whileStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Assign assign) {
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ForStmt forStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BinaryExpr binary) {
|
||||
System.out.println("binary");
|
||||
// binary.lexpr.accept(this);
|
||||
// System.out.println(binary.operation);
|
||||
// binary.rexpr.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IfStmt ifStmt) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(EmptyStmt emptyStmt) {
|
||||
System.out.println("empty statement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Literal literal) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric type = literal.getType();
|
||||
System.out.print("literal: ");
|
||||
type.accept(this);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(InstanceOf instanceOf) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToField assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AssignToLocal assignLeftSide) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperCall superCall) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExpressionReceiver expressionReceiver) {
|
||||
Expression expr = expressionReceiver.expr;
|
||||
// RefTypeOrTPHOrWildcardOrGeneric type = expressionReceiver.getType();
|
||||
// System.out.print("expressionReceiverType: ");
|
||||
// type.accept(this);
|
||||
// System.out.print(" expressionReceiver: ");
|
||||
expr.accept(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericTypeVar genericTypeVar) {
|
||||
System.out.print(genericTypeVar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericDeclarationList genericTypeVars) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Constructor field) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
System.out.println("GRT " + genericRefType.getParsedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(UnaryExpr unaryExpr) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user