Exemplo n.º 1
0
        public override object Get(RuntimeState state, object[] parametersHint)
        {
            // when you get a user defined expression, goes here and then into expression.get which builds the code tree then and there, which passes a null method

            object getMethod = MemberNode.GetMember(obj, "Get", true);

            return(CallNode.Call(state, getMethod, null));
        }
Exemplo n.º 2
0
        public override void Set(RuntimeState state, object v)
        {
            object getMethod = MemberNode.GetMember(obj, "Set", true);

            CallNode.Call(state, getMethod, new object[] { v });
        }
Exemplo n.º 3
0
        public override object Run(RuntimeState state)
        {
            object runMethod = MemberNode.GetMember(obj, "Run", true);

            return(CallNode.Call(state, runMethod, null));
        }
Exemplo n.º 4
0
        public static object Call(RuntimeState state, object callable,
                                  object[] parameters, bool wantRefParams, out bool[] refParams)
        {
            if (parameters == null)
            {
                parameters = new object[] {}
            }
            ;

            if (callable == null)
            {
                throw new NotImplementedException(
                          "No call operation for null");
            }
            else if (callable is ICallable)
            {
                return(((ICallable)callable).Call(state, parameters,
                                                  wantRefParams, out refParams));
            }
            else if (callable is MethodInfo)
            {
                ClrObjectMethodBinding binding
                    = new ClrObjectMethodBinding(null, (MethodInfo)callable);

                return(binding.Call(state, parameters, wantRefParams,
                                    out refParams));
            }
            else
            {
                object callMethod = MemberNode.GetMember(callable, "Call",
                                                         false);

                if (callMethod == null)
                {
                    throw new NotImplementedException(
                              "No call operation for "
                              + TypeNames.GetName(callable.GetType()));
                }

                if (wantRefParams)
                {
                    object getRefParamsMethod = MemberNode.GetMember(callable,
                                                                     "GetRefParams", false);

                    if (getRefParamsMethod != null)
                    {
                        object refParamsObject = CallNode.Call(state,
                                                               getRefParamsMethod, null);

                        refParams = (bool[])ConvertNode.Convert(
                            refParamsObject, typeof(bool[]));
                    }
                    else
                    {
                        refParams = null;
                    }
                }
                else
                {
                    refParams = null;
                }

                return(Call(state, callMethod, new object[] { parameters }));
            }
        }
    }