forked from JavaTX/JavaCompilerCore
Merge branch 'master' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore
This commit is contained in:
commit
b910584c29
5
bin/.gitignore
vendored
5
bin/.gitignore
vendored
@ -1,5 +0,0 @@
|
||||
/bytecode/
|
||||
/de/
|
||||
/plugindevelopment/
|
||||
/syntaxTree/
|
||||
/mycompiler/
|
@ -698,7 +698,7 @@ public class SourceFile
|
||||
retValue = Unify.unify(pairs, finiteClosure);
|
||||
return retValue;};
|
||||
oderConstraints.filterWrongConstraints(unifier);
|
||||
//oderConstraints.unifyUndConstraints(unifier);
|
||||
oderConstraints.unifyUndConstraints(unifier);
|
||||
typinferenzLog.debug("Übriggebliebene Konstraints:\n"+oderConstraints+"\n", Section.TYPEINFERENCE);
|
||||
//Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden):
|
||||
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
|
||||
|
@ -18,6 +18,7 @@ import de.dhbwstuttgart.syntaxtree.type.DoubleType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
@ -150,9 +151,15 @@ public class LambdaExpression extends Expr{
|
||||
//ArgumentAssumptions + assumptions ergeben die Assumptions für die Statements innerhalb des Lambda-Bodys:
|
||||
ret.add(method_body.TYPEStmt(ArgumentAssumptions.add(assumptions))); //Es gibt die LambdaExpression nur mit einem Block als Method Body, nicht mit einer einzelnen Expression
|
||||
|
||||
//Die Typen innerhalb von FunN anpassen:
|
||||
Vector<Type> superParamTypes = new Vector<>();
|
||||
for(Type pT : paramTypes){
|
||||
superParamTypes.add(new SuperWildcardType(pT.getOffset(), pT));
|
||||
}
|
||||
Type retType = method_body.getType();
|
||||
ExtendsWildcardType extRetType = new ExtendsWildcardType(retType.getOffset(), retType);
|
||||
ret.add(new SingleConstraint(new FunN(extRetType, paramTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
|
||||
|
||||
ret.add(new SingleConstraint(new FunN(extRetType, superParamTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
{
|
||||
if(obj instanceof ExtendsWildcardType)
|
||||
{
|
||||
return this.extendsType.equals(((ExtendsWildcardType)obj).get_ExtendsType());
|
||||
return super.equals(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,22 +56,6 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
||||
return new SuperWildcardType(getOffset(), superType.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Vergleicht mit einem anderen Objekt.
|
||||
* @param obj - Object to compare.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(obj instanceof SuperWildcardType)
|
||||
{
|
||||
return this.superType.equals(((SuperWildcardType)obj).get_SuperType());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
@ -129,4 +113,21 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
||||
return new JavaCodeResult("? super " + this.superType.printJavaCode(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Vergleicht mit einem anderen Objekt.
|
||||
* @param obj - Object to compare.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(obj instanceof SuperWildcardType)
|
||||
{
|
||||
return super.equals(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,24 +42,6 @@ public class WildcardType extends Type{
|
||||
return new WildcardType(this.getParent(), getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Vergleicht mit einem anderen Objekt.
|
||||
* @param obj - Object to compare.
|
||||
*/
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
//Luar 06-11-29 If Block erstellt, falls weitere Einschränkungen notwendig werden.
|
||||
if(obj instanceof WildcardType && !(obj instanceof SuperWildcardType || obj instanceof ExtendsWildcardType))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Gibt die passende FreshWildcardType Klasse zurück.
|
||||
@ -93,4 +75,18 @@ public class WildcardType extends Type{
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(obj instanceof WildcardType)
|
||||
{
|
||||
return ((WildcardType)obj).GetWildcardType().equals(this.GetWildcardType());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
16
test/plugindevelopment/TypeInsertTests/OL.jav
Executable file
16
test/plugindevelopment/TypeInsertTests/OL.jav
Executable file
@ -0,0 +1,16 @@
|
||||
class OL {
|
||||
|
||||
Integer m(Integer x) { return x + x; }
|
||||
|
||||
Boolean m(Boolean x) {return x || x; }
|
||||
}
|
||||
|
||||
class Main {
|
||||
|
||||
main(x) {
|
||||
ol;
|
||||
ol = new OL();
|
||||
return ol.m(x);
|
||||
}
|
||||
|
||||
}
|
17
test/plugindevelopment/TypeInsertTests/OL.java
Normal file
17
test/plugindevelopment/TypeInsertTests/OL.java
Normal file
@ -0,0 +1,17 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class OL {
|
||||
private static final String TEST_FILE = "OL.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("Integer main");
|
||||
mustContain.add("Boolean main");
|
||||
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
class Example {
|
||||
test(){
|
||||
variable1;
|
||||
variable2;
|
||||
variable1 = this;
|
||||
variable2 = variable1.intValue();
|
||||
return variable1.intValue();
|
||||
}
|
||||
|
||||
int intValue(){
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class OverloadingExample {
|
||||
private static final String TEST_FILE = "OverloadingExample.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
mustContain.add("Example variable");
|
||||
MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
class OverloadingRecursive{
|
||||
|
||||
|
||||
m (f) {
|
||||
f.apply(f);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class OverloadingRecursive {
|
||||
|
||||
private static final String TEST_FILE = "OverloadingRecursive.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
|
||||
//mustContain.add("Fun0<Fun1<java.lang.String, Fun2<AH, LambdaTest, java.lang.String>>> op");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
class LambdaTest{
|
||||
|
||||
op = (f) -> f.apply(this);
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class WildcardTestForLambda2 {
|
||||
|
||||
private static final String TEST_FILE = "WildcardTestForLambda2.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
|
||||
//mustContain.add("Fun0<Fun1<java.lang.String, Fun2<AH, LambdaTest, java.lang.String>>> op");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user