public override CodeTreeNode BuildCodeTree(RuntimeState state)
 {
     CodeTreeNode node = obj.BuildCodeTree(state);
     
     string name = member.name;
     node = new MemberNode(Source, node, name);
     
     return node;
 }
Beispiel #2
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 }));
            }
        }
    }