Inheritance: System.Dynamic.DynamicMetaObject
Beispiel #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);
            }
Beispiel #2
0
            public static DynamicMetaObject /*!*/ Bind(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 callArgs    = new CallArguments(target.CreateMetaContext(), target, args, callSignature);
                var metaBuilder = new MetaObjectBuilder(target, args);

                buildInvoke(metaBuilder, callArgs);
                return(metaBuilder.CreateMetaObject(binder));
            }
Beispiel #3
0
        internal static bool TryBuildConversionToDelegate(MetaObjectBuilder/*!*/ metaBuilder, RubyMetaObject/*!*/ metaTarget, Type/*!*/ delegateType, MethodInfo/*!*/ delegateFactory) {
            MethodInfo invoke;
            if (!typeof(Delegate).IsAssignableFrom(delegateType) || (invoke = delegateType.GetMethod("Invoke")) == null) {
                return false;
            }

            var type = metaTarget.Value.GetType();
            metaBuilder.AddTypeRestriction(type, metaTarget.Expression);
            metaBuilder.Result = delegateFactory.OpCall(AstUtils.Constant(delegateType), Ast.Convert(metaTarget.Expression, type));
            return true;
        }
Beispiel #4
0
 // TODO: convert binder
 internal static DynamicMetaObject TryBindCovertToDelegate(RubyMetaObject/*!*/ metaTarget, ConvertBinder/*!*/ binder, MethodInfo/*!*/ delegateFactory) {
     var metaBuilder = new MetaObjectBuilder();
     return TryBuildConversionToDelegate(metaBuilder, metaTarget, binder.Type, delegateFactory) ? metaBuilder.CreateMetaObject(binder) : null;
 }
Beispiel #5
0
        internal static bool TryBuildConversionToDelegate(MetaObjectBuilder /*!*/ metaBuilder, RubyMetaObject /*!*/ target, Type /*!*/ delegateType, MethodInfo /*!*/ delegateFactory)
        {
            if (!typeof(Delegate).IsAssignableFrom(delegateType) || delegateType.GetMethod("Invoke") == null)
            {
                return(false);
            }

            var type = target.Value.GetType();

            metaBuilder.AddTypeRestriction(type, target.Expression);
            metaBuilder.Result = delegateFactory.OpCall(AstUtils.Constant(delegateType), Ast.Convert(target.Expression, type));
            return(true);
        }
Beispiel #6
0
        // TODO: convert binder
        internal static DynamicMetaObject TryBindCovertToDelegate(RubyMetaObject /*!*/ target, ConvertBinder /*!*/ binder, MethodInfo /*!*/ delegateFactory)
        {
            var metaBuilder = new MetaObjectBuilder(target);

            return(TryBuildConversionToDelegate(metaBuilder, target, binder.Type, delegateFactory) ? metaBuilder.CreateMetaObject(binder) : null);
        }