Class SymbolMatcher

java.lang.Object
org.ek9lang.compiler.support.SymbolMatcher
All Implemented Interfaces:
Serializable

public class SymbolMatcher extends Object implements 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 Details

  • 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

      public double getCostOfParameterMatch(List<ISymbol> fromSymbols, List<ISymbol> toSymbols)
      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

      public double getCostOfMatch(Optional<ISymbol> fromSymbol, Optional<ISymbol> toSymbol)
      Calculates the cost of matching two symbols, which may or may not be present.