forked from JavaTX/JavaCompilerCore
Merge branch 'master' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore
This commit is contained in:
commit
dd7d0edbfe
@ -1038,7 +1038,7 @@ case 42:
|
||||
// line 535 "./../src/de/dhbwstuttgart/parser/JavaParser.jay"
|
||||
{
|
||||
/*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;
|
||||
}
|
||||
break;
|
||||
|
@ -534,7 +534,7 @@ paralist : IDENTIFIER
|
||||
wildcardparameter : '?'
|
||||
{
|
||||
//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;
|
||||
}
|
||||
| '?' EXTENDS referencetype
|
||||
|
@ -62,11 +62,11 @@ public abstract class AddOp extends Operator
|
||||
@Override
|
||||
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
|
||||
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(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1),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(ass.getTypeFor(new RefType("java.lang.Long",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1),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.Integer",this,-1).TYPE(ass, this), new RefType("java.lang.Integer",this,-1).TYPE(ass, 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(new RefType("java.lang.Float",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, 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(new RefType("java.lang.String",this,-1).TYPE(ass, this), new RefType("java.lang.String",this,-1).TYPE(ass, this));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public abstract class LogOp extends Operator
|
||||
@Override
|
||||
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
|
||||
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;
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ public abstract class MulOp extends Operator
|
||||
@Override
|
||||
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
|
||||
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(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), 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(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.Integer",this,-1).TYPE(ass, this), new RefType("java.lang.Integer",this,-1).TYPE(ass, 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(new RefType("java.lang.Float",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, 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;
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ public abstract class RelOp extends Operator
|
||||
@Override
|
||||
public HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass) {
|
||||
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(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), 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(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.Integer",this,-1).TYPE(ass, 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(new RefType("java.lang.Boolean",this,-1).TYPE(ass, this), new RefType("java.lang.Float",this,-1).TYPE(ass, 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;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ public class IfStmt extends Statement
|
||||
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)));
|
||||
}
|
||||
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 &&
|
||||
(else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this,this.getOffset()));
|
||||
|
@ -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
|
||||
|
||||
//Die Constraints für ParameterTypen und Ret Typ erstellen:
|
||||
Vector<Type> tphParamTypes = new Vector<>();
|
||||
Vector<Type> modifiedParamTypes = new Vector<>();
|
||||
for(Type pT : paramTypes){
|
||||
TypePlaceholder tph = TypePlaceholder.fresh(this);
|
||||
tphParamTypes.add(tph);
|
||||
// PN < TPH PN
|
||||
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{
|
||||
OderConstraint orCons = new OderConstraint();
|
||||
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);
|
||||
modifiedParamTypes.add(pT);
|
||||
}
|
||||
}else{
|
||||
modifiedParamTypes.add(new SuperWildcardType((ObjectType) pT));
|
||||
}
|
||||
}
|
||||
Type retType = method_body.getType();
|
||||
Type tphRetType = TypePlaceholder.fresh(this);
|
||||
// PN < TPH PN
|
||||
if(retType instanceof WildcardType){
|
||||
ret.add(new SingleConstraint(retType.TYPE(assumptions, this), tphRetType.TYPE(assumptions, this)));
|
||||
//Auf Typfehler kontrollieren. Siehe Bug #12 Kommentar 3
|
||||
if(retType instanceof SuperWildcardType){
|
||||
throw new TypeinferenceException("Typfehler von Parametertyp "+retType,this);
|
||||
}else{
|
||||
OderConstraint orCons = new OderConstraint();
|
||||
SuperWildcardType superretType = new SuperWildcardType(retType.getOffset(), (ObjectType) retType);
|
||||
SingleConstraint cons1 = new SingleConstraint(tphRetType.TYPE(assumptions, this), superretType.TYPE(assumptions, this));
|
||||
SingleConstraint cons2 = new SingleConstraint(tphRetType.TYPE(assumptions, this), retType.TYPE(assumptions, this));
|
||||
orCons.addConstraint(cons1);
|
||||
orCons.addConstraint(cons2);
|
||||
ret.add(orCons);
|
||||
//retType bleibt unverändert
|
||||
}
|
||||
}else{
|
||||
retType = new ExtendsWildcardType((ObjectType) retType);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class NotExpr extends UnaryExpr
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
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);
|
||||
return ret;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class WhileStmt extends Statement
|
||||
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
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(this.loop_block.TYPEStmt(assumptions));
|
||||
this.setType(loop_block.getType());
|
||||
|
@ -91,7 +91,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
||||
Vector<ObjectType> tempBounds = new Vector<>();
|
||||
if(this.bounds != null){
|
||||
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);
|
||||
|
||||
//TODO: ??? stimmt der Cast???
|
||||
|
@ -20,19 +20,20 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
|
||||
public class ExtendsWildcardType extends WildcardType implements ITypeContainer, IMatchable{
|
||||
|
||||
private ObjectType extendsType = null;
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Standard Konstruktor für eine ExtendsWildcard
|
||||
*/
|
||||
public ExtendsWildcardType (int offset, ObjectType extendsType)
|
||||
{
|
||||
super(extendsType.getParent(), offset);
|
||||
this.extendsType = extendsType;
|
||||
super(extendsType, extendsType.getParent(), offset);
|
||||
this.name = new JavaClassName(this.toString());
|
||||
}
|
||||
|
||||
public ExtendsWildcardType(ObjectType extendsType) {
|
||||
this(extendsType.getOffset(),extendsType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Gibt den Typen in der Wildcard zurück.
|
||||
@ -41,7 +42,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
*/
|
||||
public ObjectType get_ExtendsType()
|
||||
{
|
||||
return this.extendsType;
|
||||
return this.innerType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
*/
|
||||
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()
|
||||
{
|
||||
//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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
//if(T instanceof RefType)
|
||||
this.extendsType = (RefType)T;
|
||||
this.innerType = (RefType)T;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,26 +135,26 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
return new JavaCodeResult("? extends "+this.extendsType.printJavaCode(resultSet));
|
||||
return new JavaCodeResult("? extends "+this.innerType.printJavaCode(resultSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
ret.addAll(this.extendsType.getInvolvedTypePlaceholder());
|
||||
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
this.extendsType.parserPostProcessing(this);
|
||||
this.innerType.parserPostProcessing(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
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.
|
||||
this.extendsType = (ObjectType) this.extendsType.TYPE(ass, parent).getType();
|
||||
this.innerType = (ObjectType) this.innerType.TYPE(ass, parent).getType();
|
||||
return super.TYPE(ass, parent);
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class FreshWildcardType extends Type {
|
||||
*/
|
||||
public WildcardType get_WildcardType()
|
||||
{
|
||||
return new WildcardType(this.getParent(),this.getOffset());
|
||||
return new WildcardType(null, this.getParent(),this.getOffset());
|
||||
}
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
|
@ -18,16 +18,17 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
|
||||
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/>
|
||||
* Standard Konstruktor für eine SuperWildcard
|
||||
*/
|
||||
public SuperWildcardType(int offset, ObjectType superType)
|
||||
public SuperWildcardType(int offset, ObjectType innerType)
|
||||
{
|
||||
super(superType.getParent(),offset);
|
||||
this.superType = superType;
|
||||
super(innerType, innerType.getParent(),offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +39,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
||||
*/
|
||||
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()
|
||||
{
|
||||
return "? super " + superType.toString();
|
||||
return "? super " + innerType.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,7 +58,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
||||
*/
|
||||
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()
|
||||
{
|
||||
return new FreshSuperWildcardType(this.superType,this.getParent(),-1);
|
||||
return new FreshSuperWildcardType(this.innerType,this.getParent(),-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Das gleiche wie get_SuperType().
|
||||
* Das gleiche wie get_innerType().
|
||||
* Überschreibt die Methode der Superklasse
|
||||
*/
|
||||
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)
|
||||
{
|
||||
//if(T instanceof RefType)
|
||||
this.superType = (RefType)T;
|
||||
this.innerType = (RefType)T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Das gleiche wie get_SuperType().
|
||||
* Das gleiche wie get_innerType().
|
||||
* Implementiert ITypeContainer
|
||||
*/
|
||||
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()
|
||||
{
|
||||
return this.get_SuperType();
|
||||
return this.get_innerType();
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
ret.addAll(this.superType.getInvolvedTypePlaceholder());
|
||||
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
this.superType.parserPostProcessing(this);
|
||||
this.innerType.parserPostProcessing(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,16 @@ package de.dhbwstuttgart.syntaxtree.type;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import de.dhbwstuttgart.logger.*;
|
||||
|
||||
import de.dhbwstuttgart.logger.*;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.parser.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintType;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.TypeInsertable;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||
// ino.class.TypePlaceholder.26780.description type=javadoc
|
||||
@ -41,6 +43,11 @@ public class TypePlaceholder extends ObjectType
|
||||
private SyntaxTreeNode parent;
|
||||
|
||||
|
||||
@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
|
||||
|
@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.type;
|
||||
import java.util.Vector;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.ConstraintType;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
@ -17,13 +18,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
public class WildcardType extends Type{
|
||||
|
||||
protected ObjectType innerType = null;
|
||||
|
||||
/**
|
||||
* Author: Arne Lüdtke<br/>
|
||||
* Standard Konstruktor für eine Wildcard
|
||||
*/
|
||||
public WildcardType(SyntaxTreeNode parent, int offset)
|
||||
public WildcardType(ObjectType innerType, SyntaxTreeNode parent, int offset)
|
||||
{
|
||||
super(parent, offset);
|
||||
this.innerType = innerType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +45,7 @@ public class WildcardType extends Type{
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
if(obj instanceof WildcardType)
|
||||
|
@ -285,6 +285,7 @@ public class TypeAssumptions {
|
||||
* @return null, falls der Typ nicht vorhanden ist.
|
||||
*/
|
||||
public ConstraintType getTypeFor(Type t, SyntaxTreeNode inNode){
|
||||
/*
|
||||
if(t instanceof WildcardType){
|
||||
WildcardType wt = (WildcardType)t;
|
||||
Type innerType = wt.GetWildcardType();
|
||||
@ -295,7 +296,7 @@ public class TypeAssumptions {
|
||||
|
||||
if(t instanceof TypePlaceholder)
|
||||
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:
|
||||
JavaClassName typName = t.getName();
|
||||
for(ClassAssumption ass : this.classAssumptions){
|
||||
|
@ -74,8 +74,8 @@ public class FC_TTO
|
||||
|
||||
public void generateFullyNamedTypes(TypeAssumptions ass) {
|
||||
for(Pair p : this.FC){
|
||||
p.TA1 = ass.getTypeFor(p.TA1, p.TA1.getParent()).getType();
|
||||
p.TA2 = ass.getTypeFor(p.TA2, p.TA2.getParent()).getType();
|
||||
p.TA1 = p.TA1.TYPE(ass, p.TA1.getParent()).getType();//ass.getTypeFor(p.TA1, p.TA1.getParent()).getType();
|
||||
p.TA2 = p.TA2.TYPE(ass, p.TA2.getParent()).getType();//ass.getTypeFor(p.TA2, p.TA2.getParent()).getType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
test/plugindevelopment/TypeInsertTests/LambdaTest27.jav
Normal file
17
test/plugindevelopment/TypeInsertTests/LambdaTest27.jav
Normal 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;
|
||||
}
|
||||
}
|
18
test/plugindevelopment/TypeInsertTests/LambdaTest27.java
Normal file
18
test/plugindevelopment/TypeInsertTests/LambdaTest27.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user