Class SymbolMatcher
java.lang.Object
org.ek9lang.compiler.support.SymbolMatcher
- All Implemented Interfaces:
Serializable
Given some search criteria and a List of Symbols, this class will find the best match.
The main reason for this is to avoid method name mangling and incorporate coercion,
and interface/super type matches.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMatchesToResult
(MethodSymbolSearchResult result, SymbolSearch criteria, List<MethodSymbol> methodSymbols) Match the search criteria against one or more symbol methods.double
getCostOfMatch
(Optional<ISymbol> fromSymbol, Optional<ISymbol> toSymbol) Calculates the cost of matching two symbols, which may or may not be present.double
getCostOfParameterMatch
(List<ISymbol> fromSymbols, List<ISymbol> toSymbols) Calculates the percentage of matching these two lists of parameters.
-
Field Details
-
ZERO_COST
public static final double ZERO_COST- See Also:
-
SUPER_COST
public static final double SUPER_COST- See Also:
-
TRAIT_COST
public static final double TRAIT_COST- See Also:
-
COERCION_COST
public static final double COERCION_COST- See Also:
-
HIGH_COST
public static final double HIGH_COST- See Also:
-
INVALID_COST
public static final double INVALID_COST- See Also:
-
PERCENT_100
public static final double PERCENT_100- See Also:
-
PERCENT_ZERO
public static final double PERCENT_ZERO- See Also:
-
PERCENT_INVALID
public static final double PERCENT_INVALID- See Also:
-
-
Constructor Details
-
SymbolMatcher
public SymbolMatcher()
-
-
Method Details
-
addMatchesToResult
public void addMatchesToResult(MethodSymbolSearchResult result, SymbolSearch criteria, List<MethodSymbol> methodSymbols) Match the search criteria against one or more symbol methods. We use a percentage match algorithm to try and find the best match where there are methods of the same name. -
getCostOfParameterMatch
Calculates the percentage of matching these two lists of parameters. This is useful for calculating matches to overloaded methods and coercions. But if the symbols do not have types then it's an immediate failure to match. -
getCostOfMatch
-