Boo.Lang.Compiler.TypeSystem.CallableResolutionService.CalculateArgumentScore C# (CSharp) Метод

CalculateArgumentScore() защищенный Метод

protected CalculateArgumentScore ( IParameter param, IType parameterType, Node arg ) : int
param IParameter
parameterType IType
arg Node
Результат int
        protected int CalculateArgumentScore(IParameter param, IType parameterType, Node arg)
        {
            IType argumentType = ArgumentType(arg);
            if (param.IsByRef)
            {
                if (IsValidByRefArg(param, parameterType, argumentType, arg))
                {
                    return ExactMatchScore;
                }
                return -1;
            }
            else if (parameterType == argumentType
                || (TypeSystemServices.IsSystemObject(argumentType) &&
                    TypeSystemServices.IsSystemObject(parameterType)))
            {
                return parameterType is ICallableType
                    ? CallableExactMatchScore
                    : ExactMatchScore;
            }
            else if (parameterType.IsAssignableFrom(argumentType))
            {
                ICallableType callableType = parameterType as ICallableType;
                ICallableType callableArg = argumentType as ICallableType;
                if (callableType != null && callableArg != null)
                {
                    return CalculateCallableScore(callableType, callableArg);
                }
                return UpCastScore;
            }
            else if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
            {
                return ImplicitConversionScore;
            }
            else if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
            {
                if (IsWideningPromotion(parameterType, argumentType)) return WideningPromotion;
                return NarrowingPromotion;
            }
            else if (TypeSystemServices.CanBeReachedByDowncast(parameterType, argumentType))
            {
                return DowncastScore;
            }
            return -1;
        }

Usage Example

Пример #1
0
            public int Score(int argumentIndex)
            {
                _scores[argumentIndex] = _crs.CalculateArgumentScore(
                    Parameters[argumentIndex],
                    Parameters[argumentIndex].Type,
                    _crs.GetArgument(argumentIndex));

                return(_scores[argumentIndex]);
            }
All Usage Examples Of Boo.Lang.Compiler.TypeSystem.CallableResolutionService::CalculateArgumentScore