Stand vom 9.11.2013 angefügt

This commit is contained in:
JanUlrich 2014-02-05 13:38:34 +01:00
parent 218684dd24
commit 7ec923c4bb
16 changed files with 12686 additions and 47 deletions

12
.cvsignore Executable file
View File

@ -0,0 +1,12 @@
bin
*.class
output*
JavaLexer.java
JavaParser.java
*.~*~
*.aux
*.dvi
*.log
y.output
Bytecode
JavaParserBuilder.launch

View File

@ -12,10 +12,10 @@
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="JavaCompilerCoreCVS"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="JavaCompilerCore"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/JavaCompilerCoreCVS/tools/AntParserBuilderWindows.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/JavaCompilerCore/tools/AntParserBuilderWindows.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,clean"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/JavaCompilerCoreCVS/tools}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/JavaCompilerCore/tools}"/>
</launchConfiguration>

View File

@ -7,16 +7,12 @@
<buildSpec>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>clean,full,incremental,</triggers>
<triggers>clean,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/JavaParserBuilder.launch</value>
</dictionary>
<dictionary>
<key>incclean</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>

0
README.me Executable file → Normal file
View File

View File

@ -0,0 +1,7 @@
class GenericVarTest{
Vector<? extends Object> test;
method(){
test = test;
return 1;
}
}

View File

@ -2,6 +2,6 @@ class LambdaTest1{
var = "test";
method(String toAppend){
return (String text) -> { return text;};
return (String text) -> { return toAppend;};
}
}

View File

@ -0,0 +1,73 @@
Class DEBUG [Typeinference] Erstellte Assumptions: Set {
op: TPH C,
<init>: NOPARAS --> TestLambda
}
Block DEBUG [Typeinference] Prozessing statement: null Return (test = mycompiler.mystatement.StringLiteral@3f78d35f)
Block DEBUG [Typeinference] Prozessing statement: TPH G Return TPH F(test: TPH D = mycompiler.mystatement.StringLiteral@3f78d35f)
Class DEBUG [Typeinference] Erstellte Constraints: String < TPH D
TPH D < TPH F
TPH F < TPH G
Fun1< TPH G, TPH D > < TPH E
TPH E < TPH C
TPH C < TPH H
Class DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(String <. TPH D), (TPH D <. TPH F), (TPH F <. TPH G), (Fun1< TPH G, TPH D > <. TPH E), (TPH E <. TPH C), (TPH C <. TPH H)]]
Class DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH G = String), (TPH H = Fun1< String, String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)], [(TPH G = String), (TPH H = Fun1< String, ? extends String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)], [(TPH G = String), (TPH H = Fun1< String, ? super String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)], [(TPH G = String), (TPH H = Fun1< String, ? extends String >), (TPH F = String), (TPH C = Fun1< String, ? extends String >), (TPH D = String), (TPH E = Fun1< String, String >)], [(TPH G = String), (TPH H = Fun1< String, ? super String >), (TPH F = String), (TPH C = Fun1< String, ? super String >), (TPH D = String), (TPH E = Fun1< String, String >)]]
Class DEBUG [Typeinference] Typinformationen:
TestLambda: (TPH C op = TPH E :: (TPH D test) ->
TPH G :: (Return (TPH D test = "string" : String) : TPH F)
) : void
Class DEBUG [Typeinference]
JavaFiles:
Class DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = String), (TPH H = Fun1< String, String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)]
Class DEBUG [Typeinference] class TestLambda extends Object
{
Fun1<String, String> op = (String test) -> {
return test = "string";
};
}
Class DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = String), (TPH H = Fun1< String, ? extends String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)]
Class DEBUG [Typeinference] class TestLambda extends Object
{
Fun1<String, String> op = (String test) -> {
return test = "string";
};
}
Class DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = String), (TPH H = Fun1< String, ? super String >), (TPH F = String), (TPH C = Fun1< String, String >), (TPH D = String), (TPH E = Fun1< String, String >)]
Class DEBUG [Typeinference] class TestLambda extends Object
{
Fun1<String, String> op = (String test) -> {
return test = "string";
};
}
Class DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = String), (TPH H = Fun1< String, ? extends String >), (TPH F = String), (TPH C = Fun1< String, ? extends String >), (TPH D = String), (TPH E = Fun1< String, String >)]
Class DEBUG [Typeinference] class TestLambda extends Object
{
Fun1<String, ? extends String> op = (String test) -> {
return test = "string";
};
}
Class DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = String), (TPH H = Fun1< String, ? super String >), (TPH F = String), (TPH C = Fun1< String, ? super String >), (TPH D = String), (TPH E = Fun1< String, String >)]
Class DEBUG [Typeinference] class TestLambda extends Object
{
Fun1<String, ? super String> op = (String test) -> {
return test = "string";
};
}

View File

@ -54,7 +54,7 @@ import typinferenz.ResultSet;
import typinferenz.TypeAssumptions;
import typinferenz.TypinferenzException;
import typinferenz.UndConstraint;
import typinferenz.FunN;
@ -744,8 +744,21 @@ public class Class extends AClassOrInterface
for(Vector<Pair> constraints : xConstraints){
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
//Alle FunN-Typen werden per clone-methode in RefTypes verwandelt. (Die clone Methode in FunN darf nicht überschrieben werden.
for(Pair p : constraints){
if(p.TA1 instanceof FunN){
p.TA1 = p.TA1.clone();
}
if(p.TA2 instanceof FunN){
p.TA2 = p.TA2.clone();
}
}
//Erst die Unifizierung erstellen:
result.addAll(Unify.unify(constraints, supportData.getFiniteClosure()));
Vector<Vector<Pair>> unifyResult = Unify.unify(constraints, supportData.getFiniteClosure());
//Dann den Ergebnissen anfügen
result.addAll(unifyResult);
// Debugoutput:Vector<Vector<Pair>>
typinferenzLog.debug("Unifiziertes Ergebnis: "+result);

View File

@ -14,7 +14,7 @@ import typinferenz.ResultSet;
/**
*
* @author J<EFBFBD>rg B<EFBFBD>uerle
* @version $Date: 2013/10/21 12:45:23 $
* @version $Date: 2013/09/22 20:12:53 $
*/
// ino.end
// ino.class.GenericTypeVar.26505.declaration

View File

@ -22,7 +22,7 @@ import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListe
* und
* ist in einer zentralen Registry, d.h. einer <code>Hashtable</code> abgelegt.
* @author J<EFBFBD>rg B<EFBFBD>uerle
* @version $Date: 2013/10/21 12:45:22 $
* @version $Date: 2013/06/19 12:45:37 $
*/
// ino.end
// ino.class.TypePlaceholder.26780.declaration

View File

@ -105,9 +105,12 @@ public class FunN extends RefType implements ITypeReplacementListener{
}
*/
public void replaceType(CReplaceTypeEvent e) {
if(R.equals(e.getOldType()))R=e.getNewType();
if(R.equals(e.getOldType()))this.setR(e.getNewType());
for(Type t : T){
if(t.equals(e.getOldType()))T.setElementAt(e.getNewType(),T.indexOf(t));
if(t.equals(e.getOldType())){
T.setElementAt(e.getNewType(),T.indexOf(t));
this.setT(T);
}
}
}
@ -140,11 +143,20 @@ public class FunN extends RefType implements ITypeReplacementListener{
}
/**
* Ein Überschreiben der clone-Methode ist notwendig, da sonst beim Unify-Algorithmus die Clone-Methode der Superklasse "RefType" ausgeführt wird.
*/
* Die Clone-Methode von RefType darf von FunN NICHT überschrieben werden.
@Override
public RefType clone()
public FunN clone()
{
return new FunN(this.R,this.T);
FunN ret = null;
Vector<Type> clonepara = new Vector<Type>();
for(int i = 0; i< this.T.size(); i++)
{
clonepara.addElement(((Type)this.T.elementAt(i)).clone());
}
ret = new FunN(this.R.clone(),clonepara);
ret.setPrimitiveFlag(this.getPrimitiveFlag());
return ret;
}
*/
}

View File

@ -0,0 +1,7 @@
class GenericVarTest{
Vector<? extends Object> test;
method(){
test = test;
return 1;
}
}

View File

@ -0,0 +1,21 @@
package mycompiler.test.lambda;
import mycompiler.mytest.LambdaTest;
import mycompiler.mytypereconstruction.CTypeReconstructionResult;
import org.junit.Test;
public class GenericParameterTest {
@Test
public void test() {
executeTest();
}
private static final String exampleJavFile = "GenericParameterTest.jav";
public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFile);
CTypeReconstructionResult result1 = tester.runTestAndGetSingularResultSet();
}
}

View File

@ -2,6 +2,6 @@ class LambdaTest1{
var = "test";
method(String toAppend){
return (String text) -> { return text;};
return (String text) -> { return toAppend;};
}
}

View File

@ -18,7 +18,11 @@ public class TestLambda {
@Test
public void test() {
// Die folgenden 3 Lösungen sind alle richtig.
//TODO: Möglichkeit mehrere richtiger Lösungen beim Test implementieren.
variableTypeAssumptions.put("op", "Fun1<String, ? extends String>");
variableTypeAssumptions.put("op", "Fun1<String, String>");
variableTypeAssumptions.put("op", "Fun1<String, ? super String>");
executeTest();
}
@ -26,8 +30,8 @@ public class TestLambda {
public void executeTest(){
LambdaTest tester = new LambdaTest(exampleJavFile);
tester.runTestAndCheckResultSet(classname, variableTypeAssumptions);
//tester.runTestAndCheckResultSet(classname, variableTypeAssumptions);
tester.runTest();
}
}

File diff suppressed because one or more lines are too long