forked from JavaTX/JavaCompilerCore
modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
modified: src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java modified: src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java modified: src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java modified: src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java modified: src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java modified: src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java modified: src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java visitor freshPlaceholder implements UnifyTypeVisitor
This commit is contained in:
parent
3638edfa73
commit
103c7e4b14
@ -750,9 +750,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
//if (i == 62)
|
||||
// System.out.println(tqp.toString());
|
||||
Optional<Unifier> opt = stdUnify.unify(tqp.setTypeParams(newTp), thetaPrime);
|
||||
if (!opt.isPresent()) tpq muesse freshtv gesetzt werden PL 2018-03-16
|
||||
if (!opt.isPresent()) { //tpq muesse freshtv gesetzt werden PL 2018-03-16
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
Unifier unifier = opt.get();
|
||||
unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams());
|
||||
Set<UnifyPair> substitutionSet = new HashSet<>();
|
||||
|
@ -2,15 +2,21 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* An extends wildcard type "? extends T".
|
||||
*/
|
||||
public final class ExtendsType extends WildcardType {
|
||||
|
||||
public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht) {
|
||||
return visitor.visit(this, ht);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new extends wildcard type.
|
||||
* @param extendedType The extended type e.g. Integer in "? extends Integer"
|
||||
|
@ -1,8 +1,10 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* A real function type in java.
|
||||
@ -10,6 +12,10 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
*/
|
||||
public class FunNType extends UnifyType {
|
||||
|
||||
public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht) {
|
||||
return visitor.visit(this, ht);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a FunN-Type with the specified TypeParameters.
|
||||
*/
|
||||
|
@ -3,10 +3,12 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* An unbounded placeholder type.
|
||||
@ -54,6 +56,10 @@ public final class PlaceholderType extends UnifyType{
|
||||
IsGenerated = isGenerated;
|
||||
}
|
||||
|
||||
public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht) {
|
||||
return visitor.visit(this, ht);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a fresh placeholder type with a name that does so far not exist.
|
||||
* A user could later instantiate a type using the same name that is equivalent to this type.
|
||||
|
@ -1,8 +1,10 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* A reference type e.q. Integer or List<T>.
|
||||
@ -16,6 +18,11 @@ public final class ReferenceType extends UnifyType {
|
||||
*/
|
||||
private final int hashCode;
|
||||
|
||||
|
||||
public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht) {
|
||||
return visitor.visit(this, ht);
|
||||
}
|
||||
|
||||
public ReferenceType(String name, UnifyType... params) {
|
||||
super(name, new TypeParams(params));
|
||||
hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode();
|
||||
|
@ -1,8 +1,10 @@
|
||||
package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* A super wildcard type e.g. ? super Integer.
|
||||
@ -10,6 +12,10 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
*/
|
||||
public final class SuperType extends WildcardType {
|
||||
|
||||
public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht) {
|
||||
return visitor.visit(this, ht);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance "? extends superedType"
|
||||
* @param superedType The type that is supered e.g. Integer in "? super Integer"
|
||||
|
@ -115,6 +115,14 @@ public final class TypeParams implements Iterable<UnifyType>{
|
||||
return typeParams[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parameters of this object.
|
||||
* PL 2018-03-17
|
||||
*/
|
||||
public UnifyType[] get() {
|
||||
return typeParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the the type t as the i-th parameter and returns a new object
|
||||
* that equals this object, except for the i-th type.
|
||||
|
@ -2,10 +2,13 @@ package de.dhbwstuttgart.typeinference.unify.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.StatementVisitor;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor;
|
||||
|
||||
/**
|
||||
* Represents a java type.
|
||||
@ -33,6 +36,9 @@ public abstract class UnifyType {
|
||||
typeParams = p;
|
||||
}
|
||||
|
||||
|
||||
abstract public UnifyType accept(UnifyTypeVisitor visitor, Hashtable<PlaceholderType,PlaceholderType> ht);
|
||||
|
||||
/**
|
||||
* Returns the name of the type.
|
||||
* @return The name e.q. List for List<T>, Integer or ? extends Integer
|
||||
|
Loading…
Reference in New Issue
Block a user