Merge branch 'master' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore

This commit is contained in:
Martin Plümicke 2013-01-01 02:57:01 +01:00
commit dd7d0edbfe
20 changed files with 131 additions and 82 deletions

View File

@ -1038,7 +1038,7 @@ case 42:
// line 535 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" // line 535 "./../src/de/dhbwstuttgart/parser/JavaParser.jay"
{ {
/*Luar 29.11.06 Offset auf -1, da keine Angabe vorhanden*/ /*Luar 29.11.06 Offset auf -1, da keine Angabe vorhanden*/
WildcardType wc = new WildcardType(null,-1); WildcardType wc = new WildcardType(null,null,-1);
yyVal = wc; yyVal = wc;
} }
break; break;

View File

@ -534,7 +534,7 @@ paralist : IDENTIFIER
wildcardparameter : '?' wildcardparameter : '?'
{ {
//Luar 29.11.06 Offset auf -1, da keine Angabe vorhanden //Luar 29.11.06 Offset auf -1, da keine Angabe vorhanden
WildcardType wc = new WildcardType(null,-1); WildcardType wc = new WildcardType(null,null,-1);
$$ = wc; $$ = wc;
} }
| '?' EXTENDS referencetype | '?' EXTENDS referencetype

View File

@ -62,11 +62,11 @@ public abstract class AddOp extends Operator
@Override @Override
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) { public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
HashMap<ConstraintType,ConstraintType> ret = new HashMap<ConstraintType,ConstraintType>(); HashMap<ConstraintType,ConstraintType> ret = new HashMap<ConstraintType,ConstraintType>();
ret.put(ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1),this)); ret.put(new RefType("java.lang.Integer",this,-1).TYPE(ass, this), new RefType("java.lang.Integer",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1),this)); ret.put(new RefType("java.lang.Double",this,-1).TYPE(ass, this), new RefType("java.lang.Double",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Float",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1),this)); ret.put(new RefType("java.lang.Float",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Long",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1),this)); ret.put(new RefType("java.lang.Long",this,-1).TYPE(ass, this), new RefType("java.lang.Long",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.String",this,-1),this), ass.getTypeFor(new RefType("java.lang.String",this,-1),this)); ret.put(new RefType("java.lang.String",this,-1).TYPE(ass, this), new RefType("java.lang.String",this,-1).TYPE(ass, this));
return ret; return ret;
} }

View File

@ -232,7 +232,7 @@ public abstract class LogOp extends Operator
@Override @Override
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) { public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
HashMap<ConstraintType,ConstraintType> ret = new HashMap<>(); HashMap<ConstraintType,ConstraintType> ret = new HashMap<>();
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this)); ret.put(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Boolean",this,-1).TYPE(ass, this));
return ret; return ret;
} }

View File

@ -43,10 +43,10 @@ public abstract class MulOp extends Operator
@Override @Override
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) { public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
HashMap<ConstraintType,ConstraintType> ret = new HashMap<>(); HashMap<ConstraintType,ConstraintType> ret = new HashMap<>();
ret.put(ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this)); ret.put(new RefType("java.lang.Integer",this,-1).TYPE(ass, this), new RefType("java.lang.Integer",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), this)); ret.put(new RefType("java.lang.Double",this,-1).TYPE(ass, this), new RefType("java.lang.Double",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Float",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1), this)); ret.put(new RefType("java.lang.Float",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Long",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1), this)); ret.put(new RefType("java.lang.Long",this,-1).TYPE(ass, this), new RefType("java.lang.Long",this,-1).TYPE(ass, this));
return ret; return ret;
} }

View File

@ -54,10 +54,10 @@ public abstract class RelOp extends Operator
@Override @Override
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) { public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
HashMap<ConstraintType,ConstraintType> ret = new HashMap<>(); HashMap<ConstraintType,ConstraintType> ret = new HashMap<>();
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this)); ret.put(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Integer",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), this)); ret.put(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Double",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1), this)); ret.put(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, this));
ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1), this)); ret.put(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Long",this,-1).TYPE(ass, this));
return ret; return ret;
} }

View File

@ -258,7 +258,7 @@ public class IfStmt extends Statement
ret.add(this.else_block.TYPEStmt(assumptions)); ret.add(this.else_block.TYPEStmt(assumptions));
if(!(else_block.getType() instanceof Void))ret.add(new SingleConstraint(else_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); if(!(else_block.getType() instanceof Void))ret.add(new SingleConstraint(else_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
} }
ret.add(new SingleConstraint(expr.getType().TYPE(assumptions, this),assumptions.getTypeFor(new RefType("Boolean",this,0), this))); //(expressionDesIfStmt)<.boolean ret.add(new SingleConstraint(expr.getType().TYPE(assumptions, this),new RefType("Boolean",this,0).TYPE(assumptions, this))); //(expressionDesIfStmt)<.boolean
if(!(then_block.getType() instanceof Void))ret.add(new SingleConstraint(then_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); if(!(then_block.getType() instanceof Void))ret.add(new SingleConstraint(then_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
if(then_block.getType() instanceof Void && if(then_block.getType() instanceof Void &&
(else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this,this.getOffset())); (else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this,this.getOffset()));

View File

@ -155,39 +155,33 @@ public class LambdaExpression extends Expr{
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(method_body.TYPEStmt(ArgumentAssumptions.add(assumptions))); //Es gibt die LambdaExpression nur mit einem Block als Method Body, nicht mit einer einzelnen Expression
//Die Constraints für ParameterTypen und Ret Typ erstellen: //Die Constraints für ParameterTypen und Ret Typ erstellen:
Vector<Type> tphParamTypes = new Vector<>(); Vector<Type> modifiedParamTypes = new Vector<>();
for(Type pT : paramTypes){ for(Type pT : paramTypes){
TypePlaceholder tph = TypePlaceholder.fresh(this);
tphParamTypes.add(tph);
// PN < TPH PN
if(pT instanceof WildcardType){ if(pT instanceof WildcardType){
ret.add(new SingleConstraint(tph.TYPE(assumptions, this), pT.TYPE(assumptions, this))); //Auf Typfehler kontrollieren. Siehe Bug #12 Kommentar 3
if(pT instanceof ExtendsWildcardType){
throw new TypeinferenceException("Typfehler von Parametertyp "+pT,this);
}else{
modifiedParamTypes.add(pT);
}
}else{ }else{
OderConstraint orCons = new OderConstraint(); modifiedParamTypes.add(new SuperWildcardType((ObjectType) pT));
SuperWildcardType superpT = new SuperWildcardType(pT.getOffset(), (ObjectType) pT);
SingleConstraint cons1 = new SingleConstraint(tph.TYPE(assumptions, this), superpT.TYPE(assumptions, this));
SingleConstraint cons2 = new SingleConstraint(tph.TYPE(assumptions, this), pT.TYPE(assumptions, this));
orCons.addConstraint(cons1);
orCons.addConstraint(cons2);
ret.add(orCons);
} }
} }
Type retType = method_body.getType(); Type retType = method_body.getType();
Type tphRetType = TypePlaceholder.fresh(this);
// PN < TPH PN // PN < TPH PN
if(retType instanceof WildcardType){ if(retType instanceof WildcardType){
ret.add(new SingleConstraint(retType.TYPE(assumptions, this), tphRetType.TYPE(assumptions, this))); //Auf Typfehler kontrollieren. Siehe Bug #12 Kommentar 3
}else{ if(retType instanceof SuperWildcardType){
OderConstraint orCons = new OderConstraint(); throw new TypeinferenceException("Typfehler von Parametertyp "+retType,this);
SuperWildcardType superretType = new SuperWildcardType(retType.getOffset(), (ObjectType) retType); }else{
SingleConstraint cons1 = new SingleConstraint(tphRetType.TYPE(assumptions, this), superretType.TYPE(assumptions, this)); //retType bleibt unverändert
SingleConstraint cons2 = new SingleConstraint(tphRetType.TYPE(assumptions, this), retType.TYPE(assumptions, this)); }
orCons.addConstraint(cons1); }else{
orCons.addConstraint(cons2); retType = new ExtendsWildcardType((ObjectType) retType);
ret.add(orCons);
} }
ret.add(new SingleConstraint(new FunN(tphRetType, tphParamTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); ret.add(new SingleConstraint(new FunN(retType, modifiedParamTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this)));
return ret; return ret;
} }

View File

@ -145,7 +145,7 @@ public class NotExpr extends UnaryExpr
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
OderConstraint constraint = new OderConstraint(); OderConstraint constraint = new OderConstraint();
constraint.addConstraint(this.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean",this,-1),this)); constraint.addConstraint(this.getType().TYPE(assumptions, this), new RefType("Boolean",this,-1).TYPE(assumptions, this));
ret.add(constraint); ret.add(constraint);
return ret; return ret;
} }

View File

@ -165,7 +165,7 @@ public class WhileStmt extends Statement
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
ret.add(expr.TYPEExpr(assumptions)); ret.add(expr.TYPEExpr(assumptions));
SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean",this, 0), this)); // while(expr){}; expr <. boolean SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType().TYPE(assumptions, this), new RefType("Boolean",this, 0).TYPE(assumptions, this)); // while(expr){}; expr <. boolean
ret.add(exprMustBeBool); ret.add(exprMustBeBool);
ret.add(this.loop_block.TYPEStmt(assumptions)); ret.add(this.loop_block.TYPEStmt(assumptions));
this.setType(loop_block.getType()); this.setType(loop_block.getType());

View File

@ -91,7 +91,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar
Vector<ObjectType> tempBounds = new Vector<>(); Vector<ObjectType> tempBounds = new Vector<>();
if(this.bounds != null){ if(this.bounds != null){
for(ObjectType ev : this.bounds){ for(ObjectType ev : this.bounds){
ConstraintType extendsType = ass.getTypeFor(ev, this); ConstraintType extendsType = ev.TYPE(ass, this);
if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this); if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this);
//TODO: ??? stimmt der Cast??? //TODO: ??? stimmt der Cast???

View File

@ -20,19 +20,20 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
public class ExtendsWildcardType extends WildcardType implements ITypeContainer, IMatchable{ public class ExtendsWildcardType extends WildcardType implements ITypeContainer, IMatchable{
private ObjectType extendsType = null;
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Standard Konstruktor für eine ExtendsWildcard * Standard Konstruktor für eine ExtendsWildcard
*/ */
public ExtendsWildcardType (int offset, ObjectType extendsType) public ExtendsWildcardType (int offset, ObjectType extendsType)
{ {
super(extendsType.getParent(), offset); super(extendsType, extendsType.getParent(), offset);
this.extendsType = extendsType;
this.name = new JavaClassName(this.toString()); this.name = new JavaClassName(this.toString());
} }
public ExtendsWildcardType(ObjectType extendsType) {
this(extendsType.getOffset(),extendsType);
}
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Gibt den Typen in der Wildcard zurück. * Gibt den Typen in der Wildcard zurück.
@ -41,7 +42,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
*/ */
public ObjectType get_ExtendsType() public ObjectType get_ExtendsType()
{ {
return this.extendsType; return this.innerType;
} }
/** /**
@ -50,7 +51,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
*/ */
public String toString() public String toString()
{ {
return "? extends " + extendsType.toString(); return "? extends " + innerType.toString();
} }
/** /**
@ -61,7 +62,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
public ExtendsWildcardType clone() public ExtendsWildcardType clone()
{ {
//Hier ist unklar, ob der Extends Type auch geklont werden muss. //Hier ist unklar, ob der Extends Type auch geklont werden muss.
return new ExtendsWildcardType(getOffset(),extendsType.clone()); return new ExtendsWildcardType(getOffset(),innerType.clone());
} }
/** /**
@ -88,7 +89,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
*/ */
public FreshExtendsWildcardType GetFreshWildcardType() public FreshExtendsWildcardType GetFreshWildcardType()
{ {
return new FreshExtendsWildcardType(this.extendsType,this.getParent(),-1); return new FreshExtendsWildcardType(this.innerType,this.getParent(),-1);
} }
/** /**
@ -109,7 +110,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
public void SetWildcardType(ObjectType T) public void SetWildcardType(ObjectType T)
{ {
//if(T instanceof RefType) //if(T instanceof RefType)
this.extendsType = (RefType)T; this.innerType = (RefType)T;
} }
/** /**
@ -134,26 +135,26 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
@Override @Override
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult("? extends "+this.extendsType.printJavaCode(resultSet)); return new JavaCodeResult("? extends "+this.innerType.printJavaCode(resultSet));
} }
@Override @Override
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() { public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder(); Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
ret.addAll(this.extendsType.getInvolvedTypePlaceholder()); ret.addAll(this.innerType.getInvolvedTypePlaceholder());
return ret; return ret;
} }
@Override @Override
public void parserPostProcessing(SyntaxTreeNode parent) { public void parserPostProcessing(SyntaxTreeNode parent) {
super.parserPostProcessing(parent); super.parserPostProcessing(parent);
this.extendsType.parserPostProcessing(this); this.innerType.parserPostProcessing(this);
} }
@Override @Override
public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) { public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
//Folgender TypeCast ist sicher. Wird ein ObjectType in einen ConstraintType umgewandelt und wieder zurück, kann kein Fehler auftreten. //Folgender TypeCast ist sicher. Wird ein ObjectType in einen ConstraintType umgewandelt und wieder zurück, kann kein Fehler auftreten.
this.extendsType = (ObjectType) this.extendsType.TYPE(ass, parent).getType(); this.innerType = (ObjectType) this.innerType.TYPE(ass, parent).getType();
return super.TYPE(ass, parent); return super.TYPE(ass, parent);
} }
} }

View File

@ -147,7 +147,7 @@ public class FreshWildcardType extends Type {
*/ */
public WildcardType get_WildcardType() public WildcardType get_WildcardType()
{ {
return new WildcardType(this.getParent(),this.getOffset()); return new WildcardType(null, this.getParent(),this.getOffset());
} }
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>

View File

@ -18,16 +18,17 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
public class SuperWildcardType extends WildcardType implements ITypeContainer, IMatchable{ public class SuperWildcardType extends WildcardType implements ITypeContainer, IMatchable{
private ObjectType superType = null; public SuperWildcardType(ObjectType innerType){
this(innerType.getOffset(), innerType);
}
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Standard Konstruktor für eine SuperWildcard * Standard Konstruktor für eine SuperWildcard
*/ */
public SuperWildcardType(int offset, ObjectType superType) public SuperWildcardType(int offset, ObjectType innerType)
{ {
super(superType.getParent(),offset); super(innerType, innerType.getParent(),offset);
this.superType = superType;
} }
/** /**
@ -38,7 +39,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/ */
public ObjectType get_SuperType() public ObjectType get_SuperType()
{ {
return this.superType; return this.innerType;
} }
/** /**
@ -47,7 +48,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/ */
public String toString() public String toString()
{ {
return "? super " + superType.toString(); return "? super " + innerType.toString();
} }
/** /**
@ -57,7 +58,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/ */
public SuperWildcardType clone() public SuperWildcardType clone()
{ {
return new SuperWildcardType(getOffset(), (ObjectType) superType.clone()); return new SuperWildcardType(getOffset(), (ObjectType) innerType.clone());
} }
@ -68,17 +69,17 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/ */
public FreshSuperWildcardType GetFreshWildcardType() public FreshSuperWildcardType GetFreshWildcardType()
{ {
return new FreshSuperWildcardType(this.superType,this.getParent(),-1); return new FreshSuperWildcardType(this.innerType,this.getParent(),-1);
} }
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Das gleiche wie get_SuperType(). * Das gleiche wie get_innerType().
* Überschreibt die Methode der Superklasse * Überschreibt die Methode der Superklasse
*/ */
public Type GetWildcardType() public Type GetWildcardType()
{ {
return this.get_SuperType(); return this.get_innerType();
} }
/** /**
@ -89,17 +90,17 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
public void SetWildcardType(ObjectType T) public void SetWildcardType(ObjectType T)
{ {
//if(T instanceof RefType) //if(T instanceof RefType)
this.superType = (RefType)T; this.innerType = (RefType)T;
} }
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Das gleiche wie get_SuperType(). * Das gleiche wie get_innerType().
* Implementiert ITypeContainer * Implementiert ITypeContainer
*/ */
public Type getContainedType() public Type getContainedType()
{ {
return this.get_SuperType(); return this.get_innerType();
} }
/** /**
@ -109,12 +110,12 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/ */
public Type getMatchType() public Type getMatchType()
{ {
return this.get_SuperType(); return this.get_innerType();
} }
@Override @Override
public JavaCodeResult printJavaCode(ResultSet result){ public JavaCodeResult printJavaCode(ResultSet result){
return new JavaCodeResult("? super " + this.superType.printJavaCode(result)); return new JavaCodeResult("? super " + this.innerType.printJavaCode(result));
} }
/** /**
@ -137,19 +138,19 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
@Override @Override
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() { public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder(); Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
ret.addAll(this.superType.getInvolvedTypePlaceholder()); ret.addAll(this.innerType.getInvolvedTypePlaceholder());
return ret; return ret;
} }
@Override @Override
public void parserPostProcessing(SyntaxTreeNode parent) { public void parserPostProcessing(SyntaxTreeNode parent) {
super.parserPostProcessing(parent); super.parserPostProcessing(parent);
this.superType.parserPostProcessing(this); this.innerType.parserPostProcessing(this);
} }
@Override @Override
public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) { public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
this.superType = (ObjectType) this.superType.TYPE(ass, parent).getType(); this.innerType = (ObjectType) this.innerType.TYPE(ass, parent).getType();
return super.TYPE(ass, parent); return super.TYPE(ass, parent);
} }

View File

@ -6,14 +6,16 @@ package de.dhbwstuttgart.syntaxtree.type;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import de.dhbwstuttgart.logger.*;
import de.dhbwstuttgart.logger.*;
import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintType;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable; import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
// ino.class.TypePlaceholder.26780.description type=javadoc // ino.class.TypePlaceholder.26780.description type=javadoc
@ -41,7 +43,12 @@ public class TypePlaceholder extends ObjectType
private SyntaxTreeNode parent; private SyntaxTreeNode parent;
// ino.method.TypePlaceholder.26794.defdescription type=javadoc @Override
public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
return new ConstraintType(this);
}
// ino.method.TypePlaceholder.26794.defdescription type=javadoc
/** /**
* Privater Konstruktor - Eine TypePlaceholder-Variable wird <EFBFBD>ber die * Privater Konstruktor - Eine TypePlaceholder-Variable wird <EFBFBD>ber die
* Factory-Methode <code>fresh()</code> erzeugt. * Factory-Methode <code>fresh()</code> erzeugt.

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.type;
import java.util.Vector; import java.util.Vector;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintType;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
@ -17,13 +18,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
public class WildcardType extends Type{ public class WildcardType extends Type{
protected ObjectType innerType = null;
/** /**
* Author: Arne Lüdtke<br/> * Author: Arne Lüdtke<br/>
* Standard Konstruktor für eine Wildcard * Standard Konstruktor für eine Wildcard
*/ */
public WildcardType(SyntaxTreeNode parent, int offset) public WildcardType(ObjectType innerType, SyntaxTreeNode parent, int offset)
{ {
super(parent, offset); super(parent, offset);
this.innerType = innerType;
} }
/** /**
@ -41,7 +45,7 @@ public class WildcardType extends Type{
*/ */
public WildcardType clone() public WildcardType clone()
{ {
return new WildcardType(this.getParent(), getOffset()); return new WildcardType(this.innerType, this.getParent(), getOffset());
} }
/** /**
@ -78,6 +82,12 @@ public class WildcardType extends Type{
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
this.innerType = (ObjectType) innerType.TYPE(ass, this).getType();
return new ConstraintType(this);
}
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if(obj instanceof WildcardType) if(obj instanceof WildcardType)

View File

@ -285,6 +285,7 @@ public class TypeAssumptions {
* @return null, falls der Typ nicht vorhanden ist. * @return null, falls der Typ nicht vorhanden ist.
*/ */
public ConstraintType getTypeFor(Type t, SyntaxTreeNode inNode){ public ConstraintType getTypeFor(Type t, SyntaxTreeNode inNode){
/*
if(t instanceof WildcardType){ if(t instanceof WildcardType){
WildcardType wt = (WildcardType)t; WildcardType wt = (WildcardType)t;
Type innerType = wt.GetWildcardType(); Type innerType = wt.GetWildcardType();
@ -295,7 +296,7 @@ public class TypeAssumptions {
if(t instanceof TypePlaceholder) if(t instanceof TypePlaceholder)
return new ConstraintType((TypePlaceholder)t); //Handelt es sich um einen TypePlaceholder kann dieser nicht in den Assumptions vorkommen. return new ConstraintType((TypePlaceholder)t); //Handelt es sich um einen TypePlaceholder kann dieser nicht in den Assumptions vorkommen.
*/
//Alle bekannten Klassen nach diesem Typ durchsuchen: //Alle bekannten Klassen nach diesem Typ durchsuchen:
JavaClassName typName = t.getName(); JavaClassName typName = t.getName();
for(ClassAssumption ass : this.classAssumptions){ for(ClassAssumption ass : this.classAssumptions){

View File

@ -74,8 +74,8 @@ public class FC_TTO
public void generateFullyNamedTypes(TypeAssumptions ass) { public void generateFullyNamedTypes(TypeAssumptions ass) {
for(Pair p : this.FC){ for(Pair p : this.FC){
p.TA1 = ass.getTypeFor(p.TA1, p.TA1.getParent()).getType(); p.TA1 = p.TA1.TYPE(ass, p.TA1.getParent()).getType();//ass.getTypeFor(p.TA1, p.TA1.getParent()).getType();
p.TA2 = ass.getTypeFor(p.TA2, p.TA2.getParent()).getType(); p.TA2 = p.TA2.TYPE(ass, p.TA2.getParent()).getType();//ass.getTypeFor(p.TA2, p.TA2.getParent()).getType();
} }
} }
} }

View File

@ -0,0 +1,17 @@
class Klasse{
main(String argument){
var;
var.methode(argument);
return var.methode(argument);
}
}
class Klasse1{
String methode(String arg){
return arg;
}
}
class Klasse2{
Integer methode(Integer arg){
return arg;
}
}

View File

@ -0,0 +1,18 @@
package plugindevelopment.TypeInsertTests;
import java.util.Vector;
import org.junit.Test;
public class LambdaTest27 {
private static final String TEST_FILE = "LambdaTest27.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
//mustContain.add("A a");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
}
}