Exemplo n.º 1
0
 public override DefaultOverloadResolver CreateOverloadResolver(IList <DynamicMetaObject> args, CallSignature signature, CallTypes callType)
 {
     return(new DefaultOverloadResolver(_binder, args, signature, callType));
 }
Exemplo n.º 2
0
 // instance method call:
 public DefaultOverloadResolver(ActionBinder binder, DynamicMetaObject instance, IList <DynamicMetaObject> args, CallSignature signature)
     : this(binder, ArrayUtils.Insert(instance, args), signature, CallTypes.ImplicitInstance)
 {
 }
Exemplo n.º 3
0
 protected InvokeMemberAction(SymbolId memberName, InvokeMemberActionFlags flags, CallSignature signature)
     : base(memberName)
 {
     _flags     = flags;
     _signature = signature;
 }
Exemplo n.º 4
0
 public static InvokeMemberAction Make(SymbolId memberName, InvokeMemberActionFlags flags, CallSignature signature)
 {
     return(new InvokeMemberAction(memberName, flags, signature));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Performs binding against a set of overloaded methods using the specified arguments and the specified
        /// instance argument.  The arguments are consumed as specified by the CallSignature object.
        /// </summary>
        /// <param name="parameterBinder">ParameterBinder used to map arguments to parameters.</param>
        /// <param name="targets">The methods to be called</param>
        /// <param name="args">The arguments for the call</param>
        /// <param name="instance">The instance which will be provided for dispatching to an instance method.</param>
        /// <param name="signature">The call signature which specified how the arguments will be consumed</param>
        /// <param name="restrictions">Additional restrictions which should be applied to the resulting MetaObject.</param>
        /// <returns>A meta object which results from the call.</returns>
        public MetaObject CallInstanceMethod(ParameterBinder parameterBinder, IList <MethodBase> targets, MetaObject instance, IList <MetaObject> args, CallSignature signature, Restrictions restrictions)
        {
            ContractUtils.RequiresNotNull(instance, "instance");
            ContractUtils.RequiresNotNull(parameterBinder, "parameterBinder");

            return(CallWorker(
                       parameterBinder,
                       targets,
                       ArrayUtils.Insert(instance, args),
                       signature,
                       CallTypes.ImplicitInstance,
                       restrictions,
                       NarrowingLevel.None,
                       NarrowingLevel.All,
                       null
                       ));
        }
Exemplo n.º 6
0
 public static new CreateInstanceAction Make(CallSignature signature)
 {
     return(new CreateInstanceAction(signature));
 }
Exemplo n.º 7
0
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")] // TODO: fix
        private static MetaObject[] GetArgumentTypes(CallSignature signature, IList <MetaObject> args)
        {
            List <MetaObject> res          = new List <MetaObject>();
            List <MetaObject> namedObjects = null;

            for (int i = 0; i < args.Count; i++)
            {
                switch (signature.GetArgumentKind(i))
                {
                case ArgumentType.Named:
                    if (namedObjects == null)
                    {
                        namedObjects = new List <MetaObject>();
                    }
                    namedObjects.Add(args[i]);
                    break;

                case ArgumentType.Simple:
                case ArgumentType.Instance:
                    res.Add(args[i]);
                    break;

                case ArgumentType.List:
                    IList <object> list = args[i].Value as IList <object>;
                    if (list == null)
                    {
                        return(null);
                    }

                    for (int j = 0; j < list.Count; j++)
                    {
                        res.Add(
                            new MetaObject(
                                Ast.Call(
                                    Ast.Convert(
                                        args[i].Expression,
                                        typeof(IList <object>)
                                        ),
                                    typeof(IList <object>).GetMethod("get_Item"),
                                    Ast.Constant(j)
                                    ),
                                args[i].Restrictions,
                                list[j]
                                )
                            );
                    }
                    break;

                case ArgumentType.Dictionary:
                    // caller needs to process these...
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            if (namedObjects != null)
            {
                res.AddRange(namedObjects);
            }

            return(res.ToArray());
        }
 protected OldCreateInstanceAction(ActionBinder binder, CallSignature callSignature)
     : base(binder, callSignature)
 {
 }
Exemplo n.º 9
0
        private MetaObject CallWorker(ParameterBinder parameterBinder, IList <MethodBase> targets, IList <MetaObject> args, CallSignature signature, CallTypes callType, Restrictions restrictions, NarrowingLevel minLevel, NarrowingLevel maxLevel, string name, out BindingTarget target)
        {
            ContractUtils.RequiresNotNull(parameterBinder, "parameterBinder");
            ContractUtils.RequiresNotNullItems(args, "args");
            ContractUtils.RequiresNotNullItems(targets, "targets");
            ContractUtils.RequiresNotNull(restrictions, "restrictions");

            MetaObject[] finalArgs;
            SymbolId[]   argNames;

            if (callType == CallTypes.ImplicitInstance)
            {
                GetArgumentNamesAndTypes(signature, ArrayUtils.RemoveFirst(args), out argNames, out finalArgs);
                finalArgs = ArrayUtils.Insert(args[0], finalArgs);
            }
            else
            {
                GetArgumentNamesAndTypes(signature, args, out argNames, out finalArgs);
            }

            // attempt to bind to an individual method
            MethodBinder binder = MethodBinder.MakeBinder(
                this,
                name ?? GetTargetName(targets),
                targets,
                argNames,
                minLevel,
                maxLevel);

            target = binder.MakeBindingTarget(callType, finalArgs);

            if (target.Success)
            {
                // if we succeed make the target for the rule
                return(new MetaObject(
                           target.MakeExpression(parameterBinder),
                           restrictions.Merge(MakeSplatTests(callType, signature, args).Merge(Restrictions.Combine(target.RestrictedArguments)))
                           ));
            }
            // make an error rule
            return(MakeInvalidParametersRule(callType, signature, this, args, restrictions, target));
        }
Exemplo n.º 10
0
 private static Restrictions MakeSplatTests(CallTypes callType, CallSignature signature, IList <MetaObject> args)
 {
     return(MakeSplatTests(callType, signature, false, args));
 }
Exemplo n.º 11
0
        private MetaObject CallWorker(ParameterBinder parameterBinder, IList <MethodBase> targets, IList <MetaObject> args, CallSignature signature, CallTypes callType, Restrictions restrictions, NarrowingLevel minLevel, NarrowingLevel maxLevel, string name)
        {
            BindingTarget dummy;

            return(CallWorker(parameterBinder, targets, args, signature, callType, restrictions, minLevel, maxLevel, name, out dummy));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Performs binding against a set of overloaded methods using the specified arguments and the specified
 /// instance argument.  The arguments are consumed as specified by the CallSignature object.
 /// </summary>
 /// <param name="parameterBinder">ParameterBinder used to map arguments to parameters.</param>
 /// <param name="targets">The methods to be called</param>
 /// <param name="args">The arguments for the call</param>
 /// <param name="signature">The call signature which specified how the arguments will be consumed</param>
 /// <param name="restrictions">Additional restrictions which should be applied to the resulting MetaObject.</param>
 /// <param name="instance">The instance which will be provided for dispatching to an instance method.</param>
 /// <param name="maxLevel">The maximum narrowing level for arguments.  The current narrowing level is flowed thorugh to the DefaultBinder.</param>
 /// <param name="minLevel">The minimum narrowing level for the arguments.  The current narrowing level is flowed thorugh to the DefaultBinder.</param>
 /// <param name="target">The resulting binding target which can be used for producing error information.</param>
 /// <param name="name">The name of the method or null to use the name from targets.</param>
 /// <returns>A meta object which results from the call.</returns>
 public MetaObject CallInstanceMethod(ParameterBinder parameterBinder, IList <MethodBase> targets, MetaObject instance, IList <MetaObject> args, CallSignature signature, Restrictions restrictions, NarrowingLevel minLevel, NarrowingLevel maxLevel, string name, out BindingTarget target)
 {
     return(CallWorker(
                parameterBinder,
                targets,
                ArrayUtils.Insert(instance, args),
                signature,
                CallTypes.ImplicitInstance,
                restrictions,
                minLevel,
                maxLevel,
                name,
                out target
                ));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Performs binding against a set of overloaded methods using the specified arguments.  The arguments are
 /// consumed as specified by the CallSignature object.
 /// </summary>
 /// <param name="parameterBinder">ParameterBinder used to map arguments to parameters.</param>
 /// <param name="targets">The methods to be called</param>
 /// <param name="args">The arguments for the call</param>
 /// <param name="signature">The call signature which specified how the arguments will be consumed</param>
 /// <param name="restrictions">Additional restrictions which should be applied to the resulting MetaObject.</param>
 /// <param name="maxLevel">The maximum narrowing level for arguments.  The current narrowing level is flowed thorugh to the DefaultBinder.</param>
 /// <param name="minLevel">The minimum narrowing level for the arguments.  The current narrowing level is flowed thorugh to the DefaultBinder.</param>
 /// <param name="target">The resulting binding target which can be used for producing error information.</param>
 /// <param name="name">The name of the method or null to use the name from targets.</param>
 /// <returns>A meta object which results from the call.</returns>
 public MetaObject CallMethod(ParameterBinder parameterBinder, IList <MethodBase> targets, IList <MetaObject> args, CallSignature signature, Restrictions restrictions, NarrowingLevel minLevel, NarrowingLevel maxLevel, string name, out BindingTarget target)
 {
     return(CallWorker(
                parameterBinder,
                targets,
                args,
                signature,
                CallTypes.None,
                restrictions,
                minLevel,
                maxLevel,
                name,
                out target
                ));
 }
Exemplo n.º 14
0
 // method call:
 public DefaultOverloadResolver(ActionBinder binder, IList <DynamicMetaObject> args, CallSignature signature)
     : this(binder, args, signature, CallTypes.None)
 {
 }
Exemplo n.º 15
0
 /// <summary>
 /// Performs binding against a set of overloaded methods using the specified arguments.  The arguments are
 /// consumed as specified by the CallSignature object.
 /// </summary>
 /// <param name="parameterBinder">ParameterBinder used to map arguments to parameters.</param>
 /// <param name="targets">The methods to be called</param>
 /// <param name="args">The arguments for the call</param>
 /// <param name="signature">The call signature which specified how the arguments will be consumed</param>
 /// <returns>A meta object which results from the call.</returns>
 public MetaObject CallMethod(ParameterBinder parameterBinder, IList <MethodBase> targets, IList <MetaObject> args, CallSignature signature)
 {
     return(CallMethod(parameterBinder, targets, args, signature, Restrictions.Empty));
 }
Exemplo n.º 16
0
        public DefaultOverloadResolver(ActionBinder binder, IList <DynamicMetaObject> args, CallSignature signature, CallTypes callType)
            : base(binder)
        {
            ContractUtils.RequiresNotNullItems(args, nameof(args));

            Debug.Assert((callType == CallTypes.ImplicitInstance ? 1 : 0) + signature.ArgumentCount == args.Count);
            _args      = args;
            _signature = signature;
            _callType  = callType;
        }
Exemplo n.º 17
0
 protected CreateInstanceAction(CallSignature callSignature)
     : base(callSignature)
 {
 }
Exemplo n.º 18
0
 public static new OldCreateInstanceAction Make(ActionBinder binder, CallSignature signature)
 {
     return(new OldCreateInstanceAction(binder, signature));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Performs binding against a set of overloaded methods using the specified arguments.  The arguments are
 /// consumed as specified by the CallSignature object.
 /// </summary>
 /// <param name="parameterBinder">ParameterBinder used to map arguments to parameters.</param>
 /// <param name="targets">The methods to be called</param>
 /// <param name="args">The arguments for the call</param>
 /// <param name="signature">The call signature which specified how the arguments will be consumed</param>
 /// <param name="restrictions">Additional restrictions which should be applied to the resulting MetaObject.</param>
 /// <param name="name">The name of the method or null to use the name from targets.</param>
 /// <returns>A meta object which results from the call.</returns>
 public MetaObject CallMethod(ParameterBinder parameterBinder, IList <MethodBase> targets, IList <MetaObject> args, CallSignature signature, Restrictions restrictions, string name)
 {
     return(CallWorker(
                parameterBinder,
                targets,
                args,
                signature,
                CallTypes.None,
                restrictions,
                NarrowingLevel.None,
                NarrowingLevel.All,
                name
                ));
 }