Esempio n. 1
0
 internal OverloadResult(MemberSymbol symbol, ParameterListSymbol paramList, int nFixedArgs, int nVarArgs, int nMissingArgs)
 {
     Symbol      = symbol;
     Parameters  = paramList;
     FixedArgs   = nFixedArgs;
     VarArgs     = nVarArgs;
     MissingArgs = nMissingArgs;
     Conversions = new ConversionSymbol[nFixedArgs + nVarArgs + nMissingArgs];
 }
Esempio n. 2
0
        static void CheckArguments(MemberSymbol symbol, ParameterListSymbol paramList, ArgList args, ref OverloadResult ovRes, BindOptions options)
        {
            var  parameters   = paramList.Parameters;
            var  nParams      = parameters.Length;
            var  fixedArgs    = args.Args.Count;
            var  varArgs      = 0;
            var  missingArgs  = 0;
            bool hasExtraArgs = false;

            if (nParams <= fixedArgs)
            {
                if (paramList.HasParamArray)
                {
                    varArgs   = fixedArgs - (nParams - 1);
                    fixedArgs = nParams - 1;
                }
                else if (nParams < fixedArgs)
                {
                    hasExtraArgs = true;
                }
            }
            else if (nParams > fixedArgs)
            {
                if (paramList.HasParamArray)
                {
                    missingArgs = nParams - fixedArgs - 1;
                }
                else
                {
                    missingArgs = nParams - fixedArgs;
                }
            }
            if (!hasExtraArgs)
            {
                var ovr = OverloadResult.Create(symbol, paramList, fixedArgs, varArgs, missingArgs);
                for (int p = 0; p < fixedArgs; p++)
                {
                    ovr.ArgConversion(p, ArgumentConversion(args.Args[p], parameters[p], options));
                }
                if (missingArgs > 0)
                {
                    for (int p = fixedArgs; p < fixedArgs + missingArgs; p++)
                    {
                        ovr.ArgConversion(p, ArgumentConversion(null, parameters[p], options));
                    }
                }
                else if (paramList.HasParamArray)
                {
                    var varArgType = FindType(parameters[fixedArgs].ParameterType.GetElementType());
                    for (int p = fixedArgs; p < fixedArgs + varArgs; p++)
                    {
                        ovr.ArgConversion(p, VarArgumentConversion(args.Args[p], varArgType, options));
                    }
                }
                ovRes = ovr.Better(ovRes);
            }
        }
Esempio n. 3
0
 internal static OverloadResult Create(MemberSymbol symbol, ParameterListSymbol paramList, int nFixedArgs, int nVarArgs, int nMissingArgs)
 {
     return(new OverloadResult(symbol, paramList, nFixedArgs, nVarArgs, nMissingArgs));
 }