FallbackInvoke() public méthode

Performs the binding of the dynamic invoke operation if the target dynamic object cannot bind.
public FallbackInvoke ( DynamicMetaObject target, DynamicMetaObject args ) : DynamicMetaObject
target DynamicMetaObject The target of the dynamic invoke operation.
args DynamicMetaObject The arguments of the dynamic invoke operation.
Résultat DynamicMetaObject
Exemple #1
0
            public static DynamicMetaObject/*!*/ Bind(RubyContext/*!*/ context, InvokeBinder/*!*/ binder,
                RubyMetaObject/*!*/ target, DynamicMetaObject/*!*/[]/*!*/ args, Action<MetaObjectBuilder, CallArguments>/*!*/ buildInvoke) {

                RubyCallSignature callSignature;
                if (RubyCallSignature.TryCreate(binder.CallInfo, out callSignature)) {
                    return binder.FallbackInvoke(target, args);
                }

                var metaBuilder = new MetaObjectBuilder();
                buildInvoke(metaBuilder, new CallArguments(target.CreateMetaContext(), target, args, callSignature));
                return metaBuilder.CreateMetaObject(binder);
            }
Exemple #2
0
            public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
            {
                Fallback fallback = null;

                if (!this.IsOverridden("TryInvoke"))
                {
                    return(base.BindInvoke(binder, args));
                }
                if (fallback == null)
                {
                    fallback = e => binder.FallbackInvoke(this, args, e);
                }
                return(this.CallMethodWithResult("TryInvoke", binder, GetArgArray(args), fallback));
            }
            public override DynamicMetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, DynamicMetaObject/*!*/[]/*!*/ args) {
                RubyCallSignature callSignature;
                if (RubyCallSignature.TryCreate(action.Arguments, out callSignature)) {
                    return action.FallbackInvoke(this, args);
                }

                var metaBuilder = new MetaObjectBuilder();

                var context = new DynamicMetaObject(
                    Methods.GetContextFromBlockParam.OpCall(AstUtils.Convert(Expression, typeof(BlockParam))),
                    BindingRestrictions.Empty,
                    RubyOps.GetContextFromBlockParam((BlockParam)Value)
                );

                BlockParam.SetCallActionRule(metaBuilder, new CallArguments(context, this, args, callSignature));
                return metaBuilder.CreateMetaObject(action, args);
            }
            public override MetaObject/*!*/ BindInvoke(InvokeBinder/*!*/ action, MetaObject/*!*/[]/*!*/ args) {
                RubyCallSignature callSignature;
                if (RubyCallSignature.TryCreate(action.Arguments, out callSignature)) {
                    return action.FallbackInvoke(this, args);
                }

                var self = (RubyMethod)Value;

                var context = new MetaObject(
                    Methods.GetContextFromMethod.OpCall(AstUtils.Convert(Expression, typeof(RubyMethod))),
                    Restrictions.Empty,
                    RubyOps.GetContextFromMethod(self)
                );

                var metaBuilder = new MetaObjectBuilder();
                Method.SetRuleForCall(metaBuilder, new CallArguments(context, this, args, callSignature));
                return metaBuilder.CreateMetaObject(action, args);
            }
 /// <summary>
 /// Performs the binding of the dynamic invoke operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
 {
     ContractUtils.RequiresNotNull(binder, "binder");
     return(binder.FallbackInvoke(this, args));
 }
            public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) {
                if (IsOverridden("TryInvoke")) {
                    return CallMethodWithResult("TryInvoke", binder, DynamicMetaObject.GetExpressions(args), (e) => binder.FallbackInvoke(this, args, e));
                }

                return base.BindInvoke(binder, args);
            }
Exemple #7
0
            public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
            {
                if (IsOverridden("TryInvoke"))
                {
                    return(CallMethodWithResult("TryInvoke", binder, DynamicMetaObject.GetExpressions(args), (e) => binder.FallbackInvoke(this, args, e)));
                }

                return(base.BindInvoke(binder, args));
            }
 /// <summary>
 /// Performs the binding of the dynamic invoke operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) {
     ContractUtils.RequiresNotNull(binder, "binder");
     return binder.FallbackInvoke(this, args);
 }
Exemple #9
0
            public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
            {
                // TODO: Implement using InvokeAttribute

                DynamicMetaObject ret;
                if (_type.HandleInvoke(binder, this, args, out ret))
                    return ret;

                CodeContext context;
                Expression contextExpression;
                if (args.Length == binder.CallInfo.ArgumentCount + 1)
                {
                    context = (CodeContext)args[0].Value;
                    contextExpression = args[0].Expression;
                    args = ArrayUtils.RemoveFirst(args);
                }
                Debug.Assert(args.Length == binder.CallInfo.ArgumentCount);

                var fallback = binder.FallbackInvoke(this, args, ret);
                BindingRestrictions restrictions = fallback.Restrictions.Merge(BindingRestrictions.GetTypeRestriction(Expression, LimitType));
                foreach (var arg in args)
                    restrictions = restrictions.Merge(BindingRestrictions.GetTypeRestriction(arg.Expression, arg.LimitType));

                int normalArgCount = binder.CallInfo.ArgumentCount - binder.CallInfo.ArgumentNames.Count;

                List<Expression> normalArgs = new List<Expression>();
                for (var i = 0; i < normalArgCount; i++)
                    normalArgs.Add(EnsureObject(args[i].Expression));

                var addMethod = typeof(Dictionary<string, object>).GetMethod("Add");
                List<ElementInit> namedArgs = new List<ElementInit>();
                for (var i = 0; i < binder.CallInfo.ArgumentNames.Count; i++)
                {
                    namedArgs.Add(
                        Expression.ElementInit(
                            addMethod,
                            Expression.Constant(binder.CallInfo.ArgumentNames[i], typeof(string)),
                            EnsureObject(args[normalArgCount + i].Expression)
                        )
                    );
                }

                var dictExpr = namedArgs.Count > 0 ?
                    (Expression)Expression.ListInit(
                        Expression.New(typeof(Dictionary<string, object>)),
                        namedArgs
                    ) : Expression.New(typeof(Dictionary<string, object>));

                return new DynamicMetaObject(
                    AssertImplemented(
                        Expression.Call(
                            Expression.Constant(_type, typeof(TotemType)),
                            TotemType.MissingInvokeInfo,
                            Expression,
                            Expression.NewArrayInit(
                                typeof(object),
                                normalArgs
                            ),
                            dictExpr
                        ),
                        fallback.Expression
                    ),
                    restrictions
                );
            }
Exemple #10
0
 /// <summary>
 /// Performs the binding of the dynamic invoke operation.
 /// </summary>
 /// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke operation.</param>
 /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
 public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
 {
     ArgumentNullException.ThrowIfNull(binder);
     return(binder.FallbackInvoke(this, args));
 }
 public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
 {
     Fallback fallback = null;
     if (!this.IsOverridden("TryInvoke"))
     {
         return base.BindInvoke(binder, args);
     }
     if (fallback == null)
     {
         fallback = e => binder.FallbackInvoke(this, args, e);
     }
     return this.CallMethodWithResult("TryInvoke", binder, GetArgArray(args), fallback);
 }
 /// <summary>
 ///     Performs the binding of the dynamic invoke operation.
 /// </summary>
 /// <param name="binder">
 ///     An instance of the <see cref="T:System.Dynamic.InvokeBinder" /> that represents the details of the dynamic operation.
 /// </param>
 /// <param name="args">
 ///     An array of <see cref="T:System.Dynamic.DynamicMetaObject" /> instances - arguments to the invoke operation.
 /// </param>
 /// <returns>
 ///     The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding.
 /// </returns>
 public override DynamicMetaObject BindInvoke( InvokeBinder binder, DynamicMetaObject[] args )
 {
     return ApplyBinding( meta => meta.BindInvoke( binder, args ),
                          ( target, errorSuggestion ) => binder.FallbackInvoke( target, args, errorSuggestion ) );
 }
 public override DynamicMetaObject BindInvoke( InvokeBinder binder, DynamicMetaObject[] args )
 {
     return binder.FallbackInvoke( _baseMetaObject,
                                   args,
                                   AddTypeRestrictions( _metaObject.BindInvoke( binder, args ) ) );
 }