Class BoundResolution
java.lang.Object
de.monticore.types3.generics.util.BoundResolution
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static BoundResolutionprotected static final Stringthe name to be used for Log.info, etc. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<Map<SymTypeInferenceVariable, SymTypeExpression>> protected voidaddAllIfNotDuplicate(List<Bound> oldBounds, List<Bound> newBounds) Helper; adds all newBounds to oldBounds as long as they are not included.protected Map<SymTypeInferenceVariable, List<Bound>> completeVarBoundDependencies(Map<SymTypeInferenceVariable, List<Bound>> varBoundDependencies) fills the dependency matrix.protected <S extends SymTypeExpression,T>
Map<S, T> Deprecated, for removal: This API element is subject to removal in a future version.protected List<TypeEqualityBound> findInstantiationsSimple(List<SymTypeInferenceVariable> varsToResolve, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2LowerBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2UpperBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2SourceBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2TargetBounds) Finds new instantiations for a given minimal set of inference variables with no further dependencies.protected static BoundResolutionprotected Optional<SymTypeExpression> getGlbOfProperUpperBounds(List<SymTypeExpression> upperBounds) uses only proper(!) types to create a GlBprotected List<SymTypeInferenceVariable> getInferenceVariablesOfBounds(List<Bound> bounds) to be used after incorporation/reduction.protected Optional<SymTypeExpression> getLubOfProperLowerBounds(List<SymTypeExpression> lowerBounds) uses only proper(!) types to create a LuBprotected Map<SymTypeInferenceVariable, List<Bound>> getVarBoundDependencies(List<Bound> bounds) Dependency matrix of inference variablesincorporateAndReduce(List<Bound> newBoundsIn, List<Bound> oldBoundsIn) static voidinit()protected StringprintBounds(List<? extends Bound> constraints) protected Optional<Map<SymTypeInferenceVariable, SymTypeExpression>> recursiveResolve(List<Bound> newBounds, List<Bound> oldBounds, List<SymTypeInferenceVariable> toBeResolved, boolean createdNewInferenceVariablesLastIteration) static voidreset()Aims to find instantiations for inference variables given a set of bounds.resolve(List<Bound> bounds, List<SymTypeInferenceVariable> toBeResolved) s.protected static Optional<Map<SymTypeInferenceVariable, SymTypeExpression>> protected static voidsetDelegate(BoundResolution newDelegate)
-
Field Details
-
LOG_NAME
the name to be used for Log.info, etc.- See Also:
-
delegate
-
-
Constructor Details
-
BoundResolution
public BoundResolution()
-
-
Method Details
-
resolve
Aims to find instantiations for inference variables given a set of bounds. This will also take care of bound incorporation and constraint reduction.- Returns:
- empty iff there is no instantiation found such that the bounds can be satisfied
-
resolve
public static Optional<Map<SymTypeInferenceVariable,SymTypeExpression>> resolve(List<Bound> bounds, List<SymTypeInferenceVariable> toBeResolved) - Parameters:
toBeResolved- only resolves the listed variables, or all if empty
-
resolve
protected static Optional<Map<SymTypeInferenceVariable,SymTypeExpression>> resolve(List<Bound> newBounds, List<Bound> oldBounds, List<SymTypeInferenceVariable> toBeResolved) -
_resolve
protected Optional<Map<SymTypeInferenceVariable,SymTypeExpression>> _resolve(List<Bound> newBounds, List<Bound> oldBounds, List<SymTypeInferenceVariable> toBeResolved) -
recursiveResolve
protected Optional<Map<SymTypeInferenceVariable,SymTypeExpression>> recursiveResolve(List<Bound> newBounds, List<Bound> oldBounds, List<SymTypeInferenceVariable> toBeResolved, boolean createdNewInferenceVariablesLastIteration) - Parameters:
createdNewInferenceVariablesLastIteration- used to stop infinite recursion
-
incorporateAndReduce
-
findInstantiationsSimple
protected List<TypeEqualityBound> findInstantiationsSimple(List<SymTypeInferenceVariable> varsToResolve, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2LowerBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2UpperBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2SourceBounds, Map<SymTypeInferenceVariable, List<SymTypeExpression>> var2TargetBounds) Finds new instantiations for a given minimal set of inference variables with no further dependencies. if there are no CaptureBounds, this tries a simple LuB/GlB approach. For this approach, the inference variables must not be in a CapureBound! s. Java Spec 21 18.4. -
getInferenceVariablesOfBounds
to be used after incorporation/reduction. Does only include top-most inference variables, e.g.,List<a1> <: a2, with a1,a2 being inference variables, returns a2. -
getVarBoundDependencies
Dependency matrix of inference variables -
completeVarBoundDependencies
protected Map<SymTypeInferenceVariable,List<Bound>> completeVarBoundDependencies(Map<SymTypeInferenceVariable, List<Bound>> varBoundDependencies) fills the dependency matrix. any inferenceVariable, which does not have a bound yet, has the bound added:TV <: #Top -
getLubOfProperLowerBounds
protected Optional<SymTypeExpression> getLubOfProperLowerBounds(List<SymTypeExpression> lowerBounds) uses only proper(!) types to create a LuB -
getGlbOfProperUpperBounds
protected Optional<SymTypeExpression> getGlbOfProperUpperBounds(List<SymTypeExpression> upperBounds) uses only proper(!) types to create a GlB -
createSymTypeExprMap
@Deprecated(forRemoval=true) protected <S extends SymTypeExpression,T> Map<S,T> createSymTypeExprMap()Deprecated, for removal: This API element is subject to removal in a future version.simply use aTreeMapreturns a map that does not rely on hashes (which does not work well with SymTypeExpressions) -
addAllIfNotDuplicate
Helper; adds all newBounds to oldBounds as long as they are not included.- Parameters:
oldBounds- is modified!
-
printBounds
-
init
public static void init() -
reset
public static void reset() -
setDelegate
-
getDelegate
-
TreeMap