CheckLightThrow() static private méthode

static private CheckLightThrow ( DynamicMetaObjectBinder call, DynamicMetaObject res, BindingTarget target ) : IronPython.Runtime.Types.BuiltinFunction.BindingResult
call System.Dynamic.DynamicMetaObjectBinder
res System.Dynamic.DynamicMetaObject
target Microsoft.Scripting.Actions.Calls.BindingTarget
Résultat IronPython.Runtime.Types.BuiltinFunction.BindingResult
Exemple #1
0
        private DynamicMetaObject /*!*/ InvokeWorker(DynamicMetaObjectBinder /*!*/ call, Expression /*!*/ codeContext, DynamicMetaObject /*!*/[] args)
        {
            PerfTrack.NoteEvent(PerfTrack.Categories.Binding, "BuiltinMethodDesc Invoke " + Value.DeclaringType + "." + Value.__name__ + " w/ " + args.Length + " args");
            PerfTrack.NoteEvent(PerfTrack.Categories.BindingTarget, "BuiltinMethodDesc Invoke");

            CallSignature       signature    = BindingHelpers.GetCallSignature(call);
            BindingRestrictions selfRestrict = BindingRestrictions.GetInstanceRestriction(Expression, Value).Merge(Restrictions);

            selfRestrict = selfRestrict.Merge(
                BindingRestrictions.GetExpressionRestriction(
                    MakeFunctionTest(
                        Ast.Call(
                            typeof(PythonOps).GetMethod("GetBuiltinMethodDescriptorTemplate"),
                            Ast.Convert(Expression, typeof(BuiltinMethodDescriptor))
                            )
                        )
                    )
                );

            return(Value.Template.MakeBuiltinFunctionCall(
                       call,
                       codeContext,
                       this,
                       args,
                       false, // no self
                       selfRestrict,
                       (newArgs) => {
                BindingTarget target;
                PythonContext state = PythonContext.GetPythonContext(call);

                DynamicMetaObject res = state.Binder.CallMethod(
                    new PythonOverloadResolver(
                        state.Binder,
                        newArgs,
                        signature,
                        codeContext
                        ),
                    Value.Template.Targets,
                    selfRestrict,
                    Value.Template.Name,
                    NarrowingLevel.None,
                    Value.Template.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All,
                    out target
                    );

                return BindingHelpers.CheckLightThrow(call, res, target);
            }));
        }
Exemple #2
0
        private DynamicMetaObject /*!*/ MakeSelflessCall(DynamicMetaObjectBinder /*!*/ call, Expression /*!*/ codeContext, DynamicMetaObject /*!*/[] /*!*/ args)
        {
            // just check if it's the same built-in function.  Because built-in functions are
            // immutable the identity check will suffice.  Because built-in functions are uncollectible
            // anyway we don't use the typical InstanceRestriction.
            BindingRestrictions selfRestrict = BindingRestrictions.GetExpressionRestriction(Ast.Equal(Expression, AstUtils.Constant(Value))).Merge(Restrictions);

            return(Value.MakeBuiltinFunctionCall(
                       call,
                       codeContext,
                       this,
                       args,
                       false, // no self
                       selfRestrict,
                       (newArgs) => {
                BindingTarget target;
                var binder = PythonContext.GetPythonContext(call).Binder;

                DynamicMetaObject res = binder.CallMethod(
                    new PythonOverloadResolver(
                        binder,
                        newArgs,
                        BindingHelpers.GetCallSignature(call),
                        codeContext
                        ),
                    Value.Targets,
                    selfRestrict,
                    Value.Name,
                    PythonNarrowing.None,
                    Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All,
                    out target
                    );

                return BindingHelpers.CheckLightThrow(call, res, target);
            }
                       ));
        }
Exemple #3
0
        private DynamicMetaObject /*!*/ MakeSelfCall(DynamicMetaObjectBinder /*!*/ call, Expression /*!*/ codeContext, DynamicMetaObject /*!*/[] /*!*/ args)
        {
            BindingRestrictions selfRestrict = Restrictions.Merge(
                BindingRestrictionsHelpers.GetRuntimeTypeRestriction(
                    Expression,
                    LimitType
                    )
                ).Merge(
                BindingRestrictions.GetExpressionRestriction(
                    Value.MakeBoundFunctionTest(
                        AstUtils.Convert(Expression, typeof(BuiltinFunction))
                        )
                    )
                );

            Expression instance = Ast.Call(
                typeof(PythonOps).GetMethod("GetBuiltinFunctionSelf"),
                AstUtils.Convert(
                    Expression,
                    typeof(BuiltinFunction)
                    )
                );

            DynamicMetaObject self = GetInstance(instance, CompilerHelpers.GetType(Value.BindingSelf));

            return(Value.MakeBuiltinFunctionCall(
                       call,
                       codeContext,
                       this,
                       ArrayUtils.Insert(self, args),
                       true, // has self
                       selfRestrict,
                       (newArgs) => {
                CallSignature signature = BindingHelpers.GetCallSignature(call);
                DynamicMetaObject res;
                PythonContext state = PythonContext.GetPythonContext(call);
                BindingTarget target;
                PythonOverloadResolver resolver;
                if (Value.IsReversedOperator)
                {
                    resolver = new PythonOverloadResolver(
                        state.Binder,
                        newArgs,
                        GetReversedSignature(signature),
                        codeContext
                        );
                }
                else
                {
                    resolver = new PythonOverloadResolver(
                        state.Binder,
                        self,
                        args,
                        signature,
                        codeContext
                        );
                }

                res = state.Binder.CallMethod(
                    resolver,
                    Value.Targets,
                    self.Restrictions,
                    Value.Name,
                    NarrowingLevel.None,
                    Value.IsBinaryOperator ? PythonNarrowing.BinaryOperator : NarrowingLevel.All,
                    out target
                    );

                return BindingHelpers.CheckLightThrow(call, res, target);
            }
                       ));
        }