Ejemplo n.º 1
0
        private DynamicMetaObject /*!*/ InvokeWorker(DynamicMetaObjectBinder /*!*/ action, Expression /*!*/ codeContext, DynamicMetaObject /*!*/[] args)
        {
            ValidationInfo typeTest = BindingHelpers.GetValidationInfo(this, Value.PythonType);

            if (Value is PythonType)
            {
                PythonContext context = PythonContext.GetPythonContext(action);
                // optimization for meta classes.  Don't dispatch to type.__call__ if it's inherited,
                // instead produce a normal type call rule.
                PythonTypeSlot callSlot, typeCallSlot;
                if (Value.PythonType.TryResolveMixedSlot(context.SharedContext, "__call__", out callSlot) &&
                    TypeCache.PythonType.TryResolveSlot(context.SharedContext, "__call__", out typeCallSlot) &&
                    callSlot == typeCallSlot)
                {
                    return(InvokeFallback(action, codeContext, args));
                }
            }

            return(BindingHelpers.AddDynamicTestAndDefer(
                       action,
                       PythonProtocol.Call(action, this, args) ?? InvokeFallback(action, codeContext, args),
                       args,
                       typeTest
                       ));
        }
Ejemplo n.º 2
0
 internal DynamicMetaObject /*!*/ InvokeFallback(DynamicMetaObject /*!*/ target, DynamicMetaObject /*!*/[] /*!*/ args, CallSignature sig, DynamicMetaObject errorSuggestion)
 {
     return
         (PythonProtocol.Call(this, target, args) ??
          Context.Binder.Create(sig, target, args, AstUtils.Constant(_context.SharedContext)) ??
          Context.Binder.Call(sig, errorSuggestion, new PythonOverloadResolverFactory(Context.Binder, AstUtils.Constant(_context.SharedContext)), target, args));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Fallback - performs the default binding operation if the object isn't recognized
        /// as being invokable.
        /// </summary>
        internal DynamicMetaObject /*!*/ Fallback(Expression codeContext, DynamicMetaObject target, DynamicMetaObject /*!*/[] /*!*/ args)
        {
            if (target.NeedsDeferral())
            {
                return(Defer(args));
            }

            return(PythonProtocol.Call(this, target, args) ??
                   Context.Binder.Create(Signature, target, args, codeContext) ??
                   Context.Binder.Call(Signature, new PythonOverloadResolverFactory(Context.Binder, codeContext), target, args));
        }