本文整理汇总了Java中com.sun.tools.javac.code.Type.UndetVar类的典型用法代码示例。如果您正苦于以下问题:Java UndetVar类的具体用法?Java UndetVar怎么用?Java UndetVar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UndetVar类属于com.sun.tools.javac.code.Type包,在下文中一共展示了UndetVar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rollback
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/** Restore the state of this inference context to the previous known checkpoint.
* Consider that the number of saved undetermined variables can be different to the current
* amount. This is because new captured variables could have been added.
*/
public void rollback(List<Type> saved_undet) {
Assert.check(saved_undet != null);
//restore bounds (note: we need to preserve the old instances)
ListBuffer<Type> newUndetVars = new ListBuffer<>();
ListBuffer<Type> newInferenceVars = new ListBuffer<>();
while (saved_undet.nonEmpty() && undetvars.nonEmpty()) {
UndetVar uv = (UndetVar)undetvars.head;
UndetVar uv_saved = (UndetVar)saved_undet.head;
if (uv.qtype == uv_saved.qtype) {
uv_saved.dupTo(uv, types);
undetvars = undetvars.tail;
saved_undet = saved_undet.tail;
newUndetVars.add(uv);
newInferenceVars.add(uv.qtype);
} else {
undetvars = undetvars.tail;
}
}
undetvars = newUndetVars.toList();
inferencevars = newInferenceVars.toList();
}
示例2: visitUndetVar
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public Void visitUndetVar(UndetVar t, Void _unused) {
if (min.add(t.qtype)) {
Set<Type> deps = minMap.getOrDefault(t.qtype, new HashSet<>(Collections.singleton(t.qtype)));
for (InferenceBound boundKind : InferenceBound.values()) {
for (Type b : t.getBounds(boundKind)) {
Type undet = asUndetVar(b);
if (!undet.hasTag(TypeTag.UNDETVAR)) {
visit(undet);
} else if (isEquiv(t, b, boundKind)) {
deps.add(b);
equiv.add(b);
} else {
visit(undet);
}
}
}
minMap.put(t.qtype, deps);
}
return null;
}
示例3: isEquiv
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
boolean isEquiv(UndetVar from, Type t, InferenceBound boundKind) {
UndetVar uv = (UndetVar)asUndetVar(t);
for (InferenceBound ib : InferenceBound.values()) {
List<Type> b1 = from.getBounds(ib);
if (ib == boundKind) {
b1 = b1.diff(List.of(t));
}
List<Type> b2 = uv.getBounds(ib);
if (ib == boundKind.complement()) {
b2 = b2.diff(List.of(from.qtype));
}
if (!b1.containsAll(b2) || !b2.containsAll(b1)) {
return false;
}
}
return true;
}
示例4: solveLegacy
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
* Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
* During overload resolution, instantiation is done by doing a partial
* inference process using eq/lower bound instantiation. During check,
* we also instantiate any remaining vars by repeatedly using eq/upper
* instantiation, until all variables are solved.
*/
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
while (true) {
List<Type> solvedVars = solveBasic(steps);
if (restvars().isEmpty() || partial) {
//all variables have been instantiated - exit
break;
} else if (solvedVars.isEmpty()) {
//some variables could not be instantiated because of cycles in
//upper bounds - provide a (possibly recursive) default instantiation
infer.instantiateAsUninferredVars(restvars(), this);
break;
} else {
//some variables have been instantiated - replace newly instantiated
//variables in remaining upper bounds and continue
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
}
}
}
infer.doIncorporation(this, warn);
}
示例5: rollback
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/** Restore the state of this inference context to the previous known checkpoint.
* Consider that the number of saved undetermined variables can be different to the current
* amount. This is because new captured variables could have been added.
*/
void rollback(List<Type> saved_undet) {
Assert.check(saved_undet != null);
//restore bounds (note: we need to preserve the old instances)
ListBuffer<Type> newUndetVars = new ListBuffer<>();
ListBuffer<Type> newInferenceVars = new ListBuffer<>();
while (saved_undet.nonEmpty() && undetvars.nonEmpty()) {
UndetVar uv = (UndetVar)undetvars.head;
UndetVar uv_saved = (UndetVar)saved_undet.head;
if (uv.qtype == uv_saved.qtype) {
uv_saved.dupTo(uv, types);
undetvars = undetvars.tail;
saved_undet = saved_undet.tail;
newUndetVars.add(uv);
newInferenceVars.add(uv.qtype);
} else {
undetvars = undetvars.tail;
}
}
undetvars = newUndetVars.toList();
inferencevars = newInferenceVars.toList();
}
示例6: visitUndetVar
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public String visitUndetVar(UndetVar t, Locale locale) {
if (t.inst != null) {
return visit(t.inst, locale);
} else {
return visit(t.qtype, locale) + "?";
}
}
示例7: filterVars
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
private List<Type> filterVars(Filter<UndetVar> fu) {
ListBuffer<Type> res = new ListBuffer<>();
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
if (fu.accepts(uv)) {
res.append(uv.qtype);
}
}
return res.toList();
}
示例8: instTypes
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
List<Type> instTypes() {
ListBuffer<Type> buf = new ListBuffer<>();
for (Type t : undetvars) {
UndetVar uv = (UndetVar)t;
buf.append(uv.getInst() != null ? uv.getInst() : uv.qtype);
}
return buf.toList();
}
示例9: save
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
* Save the state of this inference context
*/
public List<Type> save() {
ListBuffer<Type> buf = new ListBuffer<>();
for (Type t : undetvars) {
buf.add(((UndetVar)t).dup(infer.types));
}
return buf.toList();
}
示例10: visitTypeVar
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public Void visitTypeVar(TypeVar t, Void aVoid) {
Type undet = asUndetVar(t);
if (undet.hasTag(TypeTag.UNDETVAR)) {
visitUndetVar((UndetVar)undet, null);
}
return null;
}
示例11: solveBasic
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
List<Type> solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) {
ListBuffer<Type> solvedVars = new ListBuffer<>();
for (Type t : varsToSolve.intersect(restvars())) {
UndetVar uv = (UndetVar)asUndetVar(t);
for (InferenceStep step : steps) {
if (step.accepts(uv, this)) {
uv.setInst(step.solve(uv, this));
solvedVars.add(uv.qtype);
break;
}
}
}
return solvedVars.toList();
}
示例12: checkEqualityBound
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
void checkEqualityBound(UndetVar uv, Type boundType) {
com.sun.tools.javac.util.List<Type> equalBounds = uv.getBounds(InferenceBound.EQ);
Assert.check(!equalBounds.isEmpty() && equalBounds.length() == 1,
"undetVar must have only one equality bound");
Type bound = equalBounds.head;
Assert.check(bound == boundType, "equal bound must be of type " + boundType);
}
示例13: restvars
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
* returns the list of uninstantiated variables (as type-variables) in this
* inference context
*/
List<Type> restvars() {
return filterVars(new Filter<UndetVar>() {
public boolean accepts(UndetVar uv) {
return uv.getInst() == null;
}
});
}
示例14: instvars
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
* returns the list of instantiated variables (as type-variables) in this
* inference context
*/
List<Type> instvars() {
return filterVars(new Filter<UndetVar>() {
public boolean accepts(UndetVar uv) {
return uv.getInst() != null;
}
});
}
示例15: boundedVars
import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
* Get list of bounded inference variables (where bound is other than
* declared bounds).
*/
final List<Type> boundedVars() {
return filterVars(new Filter<UndetVar>() {
public boolean accepts(UndetVar uv) {
return uv.getBounds(InferenceBound.UPPER)
.diff(uv.getDeclaredBounds())
.appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty();
}
});
}