Exemplo n.º 1
0
        protected override void GetNamedArguments(out IList<DynamicMetaObject> namedArgs, out IList<string> argNames) {
            if (_signature.HasNamedArgument() || _signature.HasDictionaryArgument()) {
                var objects = new List<DynamicMetaObject>();
                var names = new List<string>();

                for (int i = 0; i < _signature.ArgumentCount; i++) {
                    if (_signature.GetArgumentKind(i) == ArgumentType.Named) {
                        objects.Add(GetArgument(i));
                        names.Add(_signature.GetArgumentName(i));
                    }
                }

                if (_signature.HasDictionaryArgument()) {
                    if (objects == null) {
                        objects = new List<DynamicMetaObject>();
                        names = new List<string>();
                    }
                    SplatDictionaryArgument(names, objects);
                }

               
                names.TrimExcess();
                objects.TrimExcess();
                argNames = names;
                namedArgs = objects;
            } else { 
                argNames = ArrayUtils.EmptyStrings;
                namedArgs = DynamicMetaObject.EmptyMetaObjects;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all of the argument names and types. The instance argument is not included
        /// </summary>
        /// <param name="argNames">The names correspond to the end of argTypes.
        /// ArgumentKind.Dictionary is unpacked in the return value.
        /// This is set to an array of size 0 if there are no keyword arguments</param>
        /// <param name="resultingArgs">Non named arguments are returned at the beginning.
        /// ArgumentKind.List is unpacked in the return value. </param>
        /// <param name="args">The MetaObject array which has the arguments for the call</param>
        /// <param name="signature">The signature we're building the call for</param>
        private static void GetArgumentNamesAndTypes(CallSignature signature, IList <MetaObject> args, out SymbolId[] argNames, out MetaObject[] resultingArgs)
        {
            // Get names of named arguments
            argNames = signature.GetArgumentNames();

            resultingArgs = GetArgumentTypes(signature, args);

            if (signature.HasDictionaryArgument())
            {
                // need to get names from dictionary argument...
                GetDictionaryNamesAndTypes(args, ref argNames, ref resultingArgs);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Makes test for param arrays and param dictionary parameters.
        /// </summary>
        private static BindingRestrictions MakeSplatTests(CallTypes callType, CallSignature signature, bool testTypes, IList <DynamicMetaObject> args)
        {
            BindingRestrictions res = BindingRestrictions.Empty;

            if (signature.HasListArgument())
            {
                res = MakeParamsArrayTest(callType, signature, testTypes, args);
            }

            if (signature.HasDictionaryArgument())
            {
                res = res.Merge(MakeParamsDictionaryTest(args, testTypes));
            }

            return(res);
        }