forked from JavaTX/JavaCompilerCore
Add more debug help
This commit is contained in:
parent
a60282414c
commit
688358aa33
@ -439,7 +439,7 @@ public class RuleSet implements IRuleSet{
|
|||||||
if(!(rhsType instanceof ReferenceType) && !(rhsType instanceof PlaceholderType))
|
if(!(rhsType instanceof ReferenceType) && !(rhsType instanceof PlaceholderType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return fc.greater(lhsType, new HashSet<>()).contains(rhsType);
|
return fc.greater(lhsType, new HashSet<>(), pair.getLocation()).contains(rhsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,6 +10,7 @@ import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||||
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -22,13 +23,19 @@ public interface IFiniteClosure {
|
|||||||
* Returns all types of the finite closure that are subtypes of the argument.
|
* Returns all types of the finite closure that are subtypes of the argument.
|
||||||
* @return The set of subtypes of the argument.
|
* @return The set of subtypes of the argument.
|
||||||
*/
|
*/
|
||||||
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded);
|
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded, Token position);
|
||||||
|
public default Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded) {
|
||||||
|
return this.smaller(type, fBounded, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all types of the finite closure that are supertypes of the argument.
|
* Returns all types of the finite closure that are supertypes of the argument.
|
||||||
* @return The set of supertypes of the argument.
|
* @return The set of supertypes of the argument.
|
||||||
*/
|
*/
|
||||||
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded);
|
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded, Token position);
|
||||||
|
public default Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded) {
|
||||||
|
return this.greater(type, fBounded, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wo passt Type rein?
|
* Wo passt Type rein?
|
||||||
|
@ -27,6 +27,7 @@ import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||||
import de.dhbwstuttgart.util.Pair;
|
import de.dhbwstuttgart.util.Pair;
|
||||||
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The finite closure for the type unification
|
* The finite closure for the type unification
|
||||||
@ -145,7 +146,7 @@ implements IFiniteClosure {
|
|||||||
* @return The set of subtypes of the argument.
|
* @return The set of subtypes of the argument.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded) {
|
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded, Token position) {
|
||||||
|
|
||||||
Set<UnifyType> ret;
|
Set<UnifyType> ret;
|
||||||
if ((ret = smallerHash.get(new hashKeyType(type))) != null) {
|
if ((ret = smallerHash.get(new hashKeyType(type))) != null) {
|
||||||
@ -260,8 +261,7 @@ implements IFiniteClosure {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
//Eingefuegt PL 2018-05-24 F-Bounded Problematik
|
//Eingefuegt PL 2018-05-24 F-Bounded Problematik
|
||||||
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded) {
|
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded, Token location) {
|
||||||
|
|
||||||
Set<UnifyType> ret;
|
Set<UnifyType> ret;
|
||||||
if ((ret = greaterHash.get(new hashKeyType(type))) != null) {
|
if ((ret = greaterHash.get(new hashKeyType(type))) != null) {
|
||||||
//System.out.println(greaterHash);
|
//System.out.println(greaterHash);
|
||||||
@ -302,7 +302,7 @@ implements IFiniteClosure {
|
|||||||
|
|
||||||
//PL 18-04-05 Unifier durch Matcher ersetzt ANFANG
|
//PL 18-04-05 Unifier durch Matcher ersetzt ANFANG
|
||||||
ArrayList<UnifyPair> termList= new ArrayList<UnifyPair>();
|
ArrayList<UnifyPair> termList= new ArrayList<UnifyPair>();
|
||||||
termList.add(new UnifyPair(theta1,type, PairOperator.EQUALSDOT));
|
termList.add(new UnifyPair(theta1,type, PairOperator.EQUALSDOT, location));
|
||||||
Optional<Unifier> optSigma = match.match(termList);
|
Optional<Unifier> optSigma = match.match(termList);
|
||||||
//PL 18-04-05 Unifier durch Matcher ersetzt ENDE
|
//PL 18-04-05 Unifier durch Matcher ersetzt ENDE
|
||||||
if(!optSigma.isPresent()) {
|
if(!optSigma.isPresent()) {
|
||||||
@ -344,7 +344,7 @@ implements IFiniteClosure {
|
|||||||
BiFunction<Boolean,UnifyType,Boolean> f = (x,y) ->
|
BiFunction<Boolean,UnifyType,Boolean> f = (x,y) ->
|
||||||
{
|
{
|
||||||
ArrayList<UnifyPair> termList = new ArrayList<UnifyPair>();
|
ArrayList<UnifyPair> termList = new ArrayList<UnifyPair>();
|
||||||
termList.add(new UnifyPair(y,t.getTypeParams().get(i_ef), PairOperator.EQUALSDOT));
|
termList.add(new UnifyPair(y,t.getTypeParams().get(i_ef), PairOperator.EQUALSDOT, location));
|
||||||
return ((match.match(termList).isPresent()) || x);
|
return ((match.match(termList).isPresent()) || x);
|
||||||
};
|
};
|
||||||
//if (parai.getName().equals("java.lang.Integer")) {
|
//if (parai.getName().equals("java.lang.Integer")) {
|
||||||
|
@ -102,7 +102,7 @@ public class Unifier implements Function<UnifyType, UnifyType>, Iterable<Entry<P
|
|||||||
}
|
}
|
||||||
return new UnifyPair(newLhs, newRhs, p.getPairOp(), suniUnifyPair, p);
|
return new UnifyPair(newLhs, newRhs, p.getPairOp(), suniUnifyPair, p);
|
||||||
}
|
}
|
||||||
return new UnifyPair(newLhs, newRhs, p.getPairOp(), p.getSubstitution(), p.getBasePair(), p.getfBounded());
|
return new UnifyPair(newLhs, newRhs, p.getPairOp(), p.getSubstitution(), p.getBasePair(), p.getfBounded(), p.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify.model;
|
package de.dhbwstuttgart.typeinference.unify.model;
|
||||||
|
|
||||||
import com.google.common.collect.ObjectArrays;
|
import com.google.common.collect.ObjectArrays;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -79,26 +80,28 @@ public class UnifyPair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Set<UnifyPair> uni, UnifyPair base) {
|
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Set<UnifyPair> uni, UnifyPair base) {
|
||||||
|
this(lhs, rhs, op, uni, base, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Set<UnifyPair> uni, UnifyPair base, Set<UnifyType> fBounded) {
|
||||||
|
this(lhs, rhs, op, uni, base, fBounded, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Set<UnifyPair> uni, UnifyPair base, Set<UnifyType> fBounded, Token location) {
|
||||||
this.lhs = lhs;
|
this.lhs = lhs;
|
||||||
this.rhs = rhs;
|
this.rhs = rhs;
|
||||||
pairOp = op;
|
pairOp = op;
|
||||||
substitution = uni;
|
substitution = uni;
|
||||||
basePair = base;
|
basePair = base;
|
||||||
|
this.location = location;
|
||||||
|
|
||||||
// Caching hashcode
|
// Caching hashcode
|
||||||
hashCode = 17 + 31 * lhs.hashCode() + 31 * rhs.hashCode() + 31 * pairOp.hashCode();
|
hashCode = 17 + 31 * lhs.hashCode() + 31 * rhs.hashCode() + 31 * pairOp.hashCode();
|
||||||
}
|
|
||||||
|
|
||||||
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Set<UnifyPair> uni, UnifyPair base, Set<UnifyType> fBounded) {
|
|
||||||
this(lhs, rhs, op, uni, base);
|
|
||||||
|
|
||||||
this.fBounded = fBounded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Token getLocation() {
|
public Token getLocation() {
|
||||||
if (location != null) return location;
|
if (location != null) return location;
|
||||||
else if (basePair != null) return basePair.getLocation();;
|
else if (basePair != null) return basePair.getLocation();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user