Testfälle angefügt
This commit is contained in:
parent
e6ca6fefa2
commit
09d1acab93
4
bin/.gitignore
vendored
4
bin/.gitignore
vendored
@ -1,6 +1,2 @@
|
||||
/bytecode/
|
||||
/de/
|
||||
/mycompiler/
|
||||
/parser/
|
||||
/plugindevelopment/
|
||||
/syntaxTree/
|
||||
|
@ -1194,11 +1194,11 @@ case 64:
|
||||
// line 664 "./../src/de/dhbwstuttgart/parser/JavaParser.jay"
|
||||
{
|
||||
/*PL 05-07-30 eingefuegt containedTypes ANFANG*/
|
||||
RefType RT = new RefType(null,-1);
|
||||
RefType RT = new RefType(((UsedId)yyVals[0+yyTop]).get_Name_1Element(),null,-1);
|
||||
/*RT.set_UsedId($1);*/
|
||||
/*RT.setName(RT.get_UsedId().get_Name_1Element());*/
|
||||
RT.set_ParaList(((UsedId)yyVals[0+yyTop]).get_RealParaList());
|
||||
RT.setName(((UsedId)yyVals[0+yyTop]).get_Name_1Element());
|
||||
//RT.setName();
|
||||
containedTypes.addElement(RT);
|
||||
/*PL 05-07-30 eingefuegt containedTypes ENDE*/
|
||||
|
||||
@ -1868,9 +1868,9 @@ case 148:
|
||||
case 149:
|
||||
// line 1239 "./../src/de/dhbwstuttgart/parser/JavaParser.jay"
|
||||
{
|
||||
RefType RT = new RefType(null,-1);
|
||||
RT.set_UsedId(((UsedId)yyVals[0+yyTop]));
|
||||
RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
RefType RT = new RefType(((UsedId)yyVals[0+yyTop]).get_Name_1Element(),null,-1);
|
||||
//RT.set_UsedId(((UsedId)yyVals[0+yyTop]));
|
||||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
yyVal=RT;
|
||||
}
|
||||
break;
|
||||
@ -1940,7 +1940,7 @@ case 155:
|
||||
/*((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );*/
|
||||
}
|
||||
UsedId uid = ((UsedId)yyVals[-1+yyTop]);
|
||||
RefType RT = new RefType(null,uid.getOffset());
|
||||
RefType RT = new RefType(uid.getQualifiedName(),null,uid.getOffset());
|
||||
|
||||
RT.set_ParaList(uid.get_RealParaList());
|
||||
RT.setName(uid.getQualifiedName());
|
||||
@ -1957,7 +1957,7 @@ case 156:
|
||||
// line 1317 "./../src/de/dhbwstuttgart/parser/JavaParser.jay"
|
||||
{
|
||||
de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->referenctype: " + ((UsedId)yyVals[0+yyTop]), Section.PARSER);
|
||||
RefType RT = new RefType(null,((UsedId)yyVals[0+yyTop]).getOffset());
|
||||
RefType RT = new RefType(((UsedId)yyVals[0+yyTop]).getQualifiedName().toString(),null,((UsedId)yyVals[0+yyTop]).getOffset());
|
||||
|
||||
/*ausgetauscht PL 05-07-30*/
|
||||
/*RT.set_UsedId($1); */
|
||||
|
@ -663,11 +663,11 @@ modifier : PUBLIC
|
||||
classtype : classorinterfacetype
|
||||
{
|
||||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||||
RefType RT = new RefType(null,-1);
|
||||
RefType RT = new RefType($1.get_Name_1Element(),null,-1);
|
||||
//RT.set_UsedId($1);
|
||||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
RT.set_ParaList($1.get_RealParaList());
|
||||
RT.setName($1.get_Name_1Element());
|
||||
//RT.setName($1.get_Name_1Element());
|
||||
containedTypes.addElement(RT);
|
||||
//PL 05-07-30 eingefuegt containedTypes ENDE
|
||||
|
||||
@ -1237,9 +1237,9 @@ explicitconstructorinvocation : THIS '(' ')' ';'
|
||||
|
||||
classtypelist : classtype
|
||||
{
|
||||
RefType RT = new RefType(null,-1);
|
||||
RefType RT = new RefType(RT.get_UsedId().get_Name_1Element(),null,-1);
|
||||
RT.set_UsedId($1);
|
||||
RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
$$=RT;
|
||||
}
|
||||
| classtypelist ',' classtype
|
||||
@ -1300,10 +1300,10 @@ referencelongtype : typename parameter
|
||||
//((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
}
|
||||
UsedId uid = $1;
|
||||
RefType RT = new RefType(null,uid.getOffset());
|
||||
RefType RT = new RefType(uid.getQualifiedName(),null,uid.getOffset());
|
||||
|
||||
RT.set_ParaList(uid.get_RealParaList());
|
||||
RT.setName(uid.getQualifiedName());
|
||||
//RT.setName(uid.getQualifiedName());
|
||||
|
||||
|
||||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||||
@ -1316,13 +1316,13 @@ referencelongtype : typename parameter
|
||||
referencetype :classorinterfacetype
|
||||
{
|
||||
de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1, Section.PARSER);
|
||||
RefType RT = new RefType(null,$1.getOffset());
|
||||
RefType RT = new RefType($1.getQualifiedName(),null,$1.getOffset());
|
||||
|
||||
//ausgetauscht PL 05-07-30
|
||||
//RT.set_UsedId($1);
|
||||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
RT.set_ParaList($1.get_RealParaList());
|
||||
RT.setName($1.getQualifiedName());
|
||||
//RT.setName($1.getQualifiedName());
|
||||
|
||||
|
||||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||||
|
@ -397,7 +397,7 @@ public class SourceFile
|
||||
|
||||
// Parameter des rechten Typausdrucks des betrachteten Paars extrahieren
|
||||
Vector<Type> vPara = ((RefType)(PTypKonst.TA2)).get_ParaList();
|
||||
RefType Subst = null; // Substitution
|
||||
Integer Subst = null; // Substitution
|
||||
int nSubstStelle = 0;
|
||||
inferencelog.debug("nSubstStelleStart" + nSubstStelle + " " + n, Section.FINITECLOSURE);
|
||||
|
||||
@ -412,7 +412,7 @@ public class SourceFile
|
||||
if( vPara.elementAt(nSubstStelle) instanceof RefType && ((RefType)vPara.elementAt(nSubstStelle)).get_ParaList() != null )
|
||||
{
|
||||
// Typkonstruktor gefunden -> wird nun als Substitution verwendet
|
||||
Subst = new RefType( (RefType)vPara.elementAt(nSubstStelle) ,-1);
|
||||
Subst = 1;//new RefType( (RefType)vPara.elementAt(nSubstStelle) ,-1);
|
||||
inferencelog.debug( "Ausgangstyp:" + ((RefType)PTypKonst.TA2).getName() , Section.FINITECLOSURE);
|
||||
inferencelog.debug( "RefType = " + ((RefType)vPara.elementAt(nSubstStelle)).getName() , Section.FINITECLOSURE);
|
||||
break; // Einschraenkung - nur fuer ein RefType wird eine Substitution gesucht
|
||||
|
@ -15,6 +15,7 @@ import de.dhbwstuttgart.syntaxtree.Method;
|
||||
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
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.Type;
|
||||
@ -148,7 +149,10 @@ public class LambdaExpression extends Expr{
|
||||
this.setType(TypePlaceholder.fresh(this));
|
||||
//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
|
||||
ret.add(new SingleConstraint(new FunN(method_body.getType(), paramTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
|
||||
|
||||
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)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
|
||||
import de.dhbwstuttgart.parser.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
@ -25,6 +26,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
{
|
||||
super(extendsType.getParent(), offset);
|
||||
this.extendsType = extendsType;
|
||||
this.name = new JavaClassName(this.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ public class RefType extends Type implements IMatchable
|
||||
|
||||
|
||||
// ino.method.RefType.26634.definition
|
||||
public RefType(SyntaxTreeNode parent, int offset)
|
||||
protected RefType(SyntaxTreeNode parent, int offset)
|
||||
// ino.end
|
||||
// ino.method.RefType.26634.body
|
||||
{
|
||||
@ -124,6 +124,10 @@ public class RefType extends Type implements IMatchable
|
||||
//this.parameter = null;
|
||||
}
|
||||
|
||||
public RefType(JavaClassName jName, SyntaxTreeNode parent, int offset) {
|
||||
this(jName.toString(), parent, offset);
|
||||
}
|
||||
|
||||
// ino.method.Type2Key.26646.definition
|
||||
public String Type2Key()
|
||||
// ino.end
|
||||
|
@ -45,7 +45,7 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
|
||||
// ino.end
|
||||
|
||||
// ino.method.Type.26732.definition
|
||||
public Type(SyntaxTreeNode parent,int offset)
|
||||
protected Type(SyntaxTreeNode parent,int offset)
|
||||
// ino.end
|
||||
// ino.method.Type.26732.body
|
||||
{
|
||||
|
@ -17,6 +17,7 @@ import de.dhbwstuttgart.typeinference.ConstraintType;
|
||||
import de.dhbwstuttgart.typeinference.FunN;
|
||||
import de.dhbwstuttgart.typeinference.FunNInterface;
|
||||
import de.dhbwstuttgart.typeinference.FunNMethod;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||
|
||||
/**
|
||||
@ -325,6 +326,8 @@ public class TypeAssumptions {
|
||||
return new ConstraintType(ass.getAssumedType());
|
||||
}
|
||||
}
|
||||
|
||||
if(t.getName() == null)throw new DebugException(t.toString());
|
||||
//Spezialfälle bei char, int, boolean, ....
|
||||
String name = t.getName().toString();
|
||||
switch(name){
|
||||
|
43
test/plugindevelopment/KarthesischesProduktTest.java
Normal file
43
test/plugindevelopment/KarthesischesProduktTest.java
Normal file
@ -0,0 +1,43 @@
|
||||
package plugindevelopment;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.ConstraintPair;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintType;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||
import de.dhbwstuttgart.typeinference.KarthesischesProdukt;
|
||||
import de.dhbwstuttgart.typeinference.OderConstraint;
|
||||
import de.dhbwstuttgart.typeinference.SingleConstraint;
|
||||
|
||||
public class KarthesischesProduktTest {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
Vector<Vector<String>> testV = new Vector<>();
|
||||
Vector<String> dummy = new Vector<>();
|
||||
dummy.add("1");
|
||||
dummy.add("2");
|
||||
dummy.add("3");
|
||||
testV.add(dummy);
|
||||
testV.add(dummy);
|
||||
|
||||
ConstraintsSet cs = new ConstraintsSet();
|
||||
OderConstraint oc = new OderConstraint();
|
||||
//oc.addConstraint(new SingleConstraint(new RefType("")));
|
||||
cs.add(oc);
|
||||
|
||||
Vector out = new KarthesischesProdukt().berechneKarthesischesProdukt(testV);
|
||||
System.out.println(out);
|
||||
}
|
||||
|
||||
}
|
||||
class TestConstraintPair extends ConstraintPair{
|
||||
|
||||
public TestConstraintPair(ConstraintType t1, ConstraintType t2) {
|
||||
super(t1, t2);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
class LambdaTest{
|
||||
|
||||
methode(){
|
||||
return (Integer i)-> i;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class WildcardTestForLambda {
|
||||
|
||||
private static final String TEST_FILE = "WildcardTestForLambda.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