private MakeCopy ( int newIndex ) : SimpleArgBuilder | ||
newIndex | int | |
Résultat | SimpleArgBuilder |
private MethodCandidate CreateDefaultCandidate(int defaultsUsed) { List <ArgBuilder> defaultArgBuilders = new List <ArgBuilder>(_arguments); List <ParameterWrapper> necessaryParams = _parameters.GetRange(0, _parameters.Count - defaultsUsed); for (int curDefault = 0; curDefault < defaultsUsed; curDefault++) { int readIndex = _defaultArguments.Count - defaultsUsed + curDefault; int writeIndex = defaultArgBuilders.Count - defaultsUsed + curDefault; if (_defaultArguments[readIndex] != null) { defaultArgBuilders[writeIndex] = _defaultArguments[readIndex]; } else { necessaryParams.Add(_parameters[_parameters.Count - defaultsUsed + curDefault]); } } // shift any arguments forward that need to be... int curArg = _overload.IsStatic ? 0 : 1; for (int i = 0; i < defaultArgBuilders.Count; i++) { SimpleArgBuilder sab = defaultArgBuilders[i] as SimpleArgBuilder; if (sab != null) { defaultArgBuilders[i] = sab.MakeCopy(curArg++); } } return(new MethodCandidate(_resolver, _overload, necessaryParams, _paramsDict, _returnBuilder, _instanceBuilder, defaultArgBuilders, null)); }
private MethodCandidate MakeParamsExtended(string[] names, int[] nameIndices, List<ParameterWrapper> parameters) { Debug.Assert(Overload.IsVariadic); List<ArgBuilder> newArgBuilders = new List<ArgBuilder>(_argBuilders.Count); // current argument that we consume, initially skip this if we have it. int curArg = _overload.IsStatic ? 0 : 1; int kwIndex = -1; ArgBuilder paramsDictBuilder = null; foreach (ArgBuilder ab in _argBuilders) { // TODO: define a virtual method on ArgBuilder implementing this functionality: SimpleArgBuilder sab = ab as SimpleArgBuilder; if (sab != null) { // we consume one or more incoming argument(s) if (sab.IsParamsArray) { // consume all the extra arguments int paramsUsed = parameters.Count - GetConsumedArguments() - names.Length + (_overload.IsStatic ? 1 : 0); newArgBuilders.Add(new ParamsArgBuilder( sab.ParameterInfo, sab.Type.GetElementType(), curArg, paramsUsed )); curArg += paramsUsed; } else if (sab.IsParamsDict) { // consume all the kw arguments kwIndex = newArgBuilders.Count; paramsDictBuilder = sab; } else { // consume the argument, adjust its position: newArgBuilders.Add(sab.MakeCopy(curArg++)); } } else if (ab is KeywordArgBuilder) { newArgBuilders.Add(ab); curArg++; } else { // CodeContext, null, default, etc... we don't consume an // actual incoming argument. newArgBuilders.Add(ab); } } if (kwIndex != -1) { newArgBuilders.Insert(kwIndex, new ParamsDictArgBuilder(paramsDictBuilder.ParameterInfo, curArg, names, nameIndices)); } return new MethodCandidate(_resolver, _overload, parameters, null, _returnBuilder, _instanceBuilder, newArgBuilders, null); }
internal MethodTarget MakeParamsExtended(int argCount, SymbolId[] names, int[] nameIndexes) { Debug.Assert(BinderHelpers.IsParamsMethod(Method)); List <ArgBuilder> newArgBuilders = new List <ArgBuilder>(_argBuilders.Count); // current argument that we consume, initially skip this if we have it. int curArg = CompilerHelpers.IsStatic(_method) ? 0 : 1; int kwIndex = -1; ArgBuilder paramsDictBuilder = null; foreach (ArgBuilder ab in _argBuilders) { SimpleArgBuilder sab = ab as SimpleArgBuilder; if (sab != null) { // we consume one or more incoming argument(s) if (sab.IsParamsArray) { // consume all the extra arguments int paramsUsed = argCount - GetConsumedArguments() - names.Length + (CompilerHelpers.IsStatic(_method) ? 1 : 0); newArgBuilders.Add(new ParamsArgBuilder( sab.ParameterInfo, sab.Type.GetElementType(), curArg, paramsUsed )); curArg += paramsUsed; } else if (sab.IsParamsDict) { // consume all the kw arguments kwIndex = newArgBuilders.Count; paramsDictBuilder = sab; } else { // consume the argument, adjust its position: newArgBuilders.Add(sab.MakeCopy(curArg++)); } } else { // CodeContext, null, default, etc... we don't consume an // actual incoming argument. newArgBuilders.Add(ab); } } if (kwIndex != -1) { newArgBuilders.Insert(kwIndex, new ParamsDictArgBuilder(paramsDictBuilder.ParameterInfo, curArg, names, nameIndexes)); } return(new MethodTarget(_binder, Method, argCount, _instanceBuilder, newArgBuilders, _returnBuilder)); }