当前位置: 首页>>代码示例>>C#>>正文


C# BinderState.Invoke方法代码示例

本文整理汇总了C#中IronPython.Runtime.Binding.BinderState.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# BinderState.Invoke方法的具体用法?C# BinderState.Invoke怎么用?C# BinderState.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IronPython.Runtime.Binding.BinderState的用法示例。


在下文中一共展示了BinderState.Invoke方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Invoke

 public static Expression/*!*/ Invoke(Expression codeContext, BinderState/*!*/ binder, Type/*!*/ resultType, CallSignature signature, params Expression/*!*/[]/*!*/ args) {
     return Ast.Dynamic(
         binder.Invoke(
             signature
         ),
         resultType,
         ArrayUtils.Insert(codeContext, args)
     );
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:9,代码来源:BindingHelpers.cs

示例2: MakeSlotCallWorker

        private static void MakeSlotCallWorker(BinderState/*!*/ state, PythonTypeSlot/*!*/ slotTarget, Expression/*!*/ self, ConditionalBuilder/*!*/ bodyBuilder, params Expression/*!*/[]/*!*/ args) {
            // Generate:
            // 
            // SlotTryGetValue(context, slot, selfType, out callable) && (tmp=callable(args)) != NotImplemented) ?
            //      tmp :
            //      RestOfOperation
            //
            ParameterExpression callable = Ast.Variable(typeof(object), "slot");
            ParameterExpression tmp = Ast.Variable(typeof(object), "slot");

            bodyBuilder.AddCondition(
                Ast.AndAlso(
                    Ast.Call(
                        typeof(PythonOps).GetMethod("SlotTryGetValue"),
                        AstUtils.Constant(state.Context),
                        AstUtils.Convert(Utils.WeakConstant(slotTarget), typeof(PythonTypeSlot)),
                        AstUtils.Convert(self, typeof(object)),
                        Ast.Call(
                            typeof(DynamicHelpers).GetMethod("GetPythonType"),
                            AstUtils.Convert(self, typeof(object))
                        ),
                        callable
                    ),
                    Ast.NotEqual(
                        Ast.Assign(
                            tmp,
                            Ast.Dynamic(
                                state.Invoke(
                                    new CallSignature(args.Length)
                                ),
                                typeof(object),
                                ArrayUtils.Insert(AstUtils.Constant(state.Context), (Expression)callable, args)
                            )
                        ),
                        Ast.Property(null, typeof(PythonOps).GetProperty("NotImplemented"))
                    )
                ),
                tmp
            );
            bodyBuilder.AddVariable(callable);
            bodyBuilder.AddVariable(tmp);
        }
开发者ID:MiguelMadero,项目名称:ironruby,代码行数:42,代码来源:PythonProtocol.Operations.cs

示例3: InvokeKeywords

 /// <summary>
 /// Creates a new InvokeBinder which will call with positional and keyword splatting.
 /// 
 /// The signature of the target site should be object(function), object[], dictionary, retType
 /// </summary>
 public static PythonInvokeBinder/*!*/ InvokeKeywords(BinderState/*!*/ state) {
     return state.Invoke(
         new CallSignature(new Argument(ArgumentType.List), new Argument(ArgumentType.Dictionary))
     );
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:10,代码来源:Binders.cs

示例4: InvokeSplat

 /// <summary>
 /// Creates a new InvokeBinder which will call with positional splatting.
 /// 
 /// The signature of the target site should be object(function), object[], retType
 /// </summary>
 /// <param name="state"></param>
 /// <returns></returns>
 public static PythonInvokeBinder/*!*/ InvokeSplat(BinderState/*!*/ state) {
     return state.Invoke(
         new CallSignature(new Argument(ArgumentType.List))
     );
 }
开发者ID:jcteague,项目名称:ironruby,代码行数:12,代码来源:Binders.cs

示例5: InvokeAndConvert

        public static DynamicMetaObjectBinder/*!*/ InvokeAndConvert(BinderState/*!*/ state, int argCount, Type retType) {
            // +2 for the target object and CodeContext which InvokeBinder recevies
            ParameterMappingInfo[] args = new ParameterMappingInfo[argCount + 2];   
            for (int i = 0; i < argCount + 2; i++) {
                args[i] = ParameterMappingInfo.Parameter(i);
            }

            return new ComboBinder(
                new BinderMappingInfo(
                    state.Invoke(
                        new CallSignature(argCount)
                    ),
                    args
                ),
                new BinderMappingInfo(
                    state.Convert(retType, ConversionResultKind.ExplicitCast),
                    ParameterMappingInfo.Action(0)
                )
            );
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:20,代码来源:Binders.cs

示例6: GetSlotOrFunction

        public static SlotOrFunction/*!*/ GetSlotOrFunction(BinderState/*!*/ state, SymbolId op, params DynamicMetaObject[] types) {
            PythonTypeSlot slot;
            SlotOrFunction res;
            if (TryGetBinder(state, types, op, SymbolId.Empty, out res)) {
                if (res != SlotOrFunction.Empty) {
                    return res;
                }
            } else if (MetaUserObject.GetPythonType(types[0]).TryResolveSlot(state.Context, op, out slot)) {
                ParameterExpression tmp = Ast.Variable(typeof(object), "slotVal");

                Expression[] args = new Expression[types.Length - 1];
                for (int i = 1; i < types.Length; i++) {
                    args[i - 1] = types[i].Expression;
                }
                return new SlotOrFunction(
                    new DynamicMetaObject(
                        Ast.Block(
                            new ParameterExpression[] { tmp },
                            MetaPythonObject.MakeTryGetTypeMember(
                                state,
                                slot,
                                tmp,
                                types[0].Expression,
                                Ast.Call(
                                    typeof(DynamicHelpers).GetMethod("GetPythonType"),
                                    types[0].Expression
                                )
                            ),
                            Ast.Dynamic(
                                state.Invoke(
                                    new CallSignature(args.Length)
                                ),
                                typeof(object),
                                ArrayUtils.Insert<Expression>(
                                    AstUtils.Constant(state.Context),
                                    tmp,
                                    args
                                )
                            )
                        ),
                        BindingRestrictions.Combine(types).Merge(BindingRestrictionsHelpers.GetRuntimeTypeRestriction(types[0].Expression, types[0].GetLimitType()))
                    )
                );
            }

            return SlotOrFunction.Empty;
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:47,代码来源:SlotOrFunction.cs


注:本文中的IronPython.Runtime.Binding.BinderState.Invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。