Microsoft.CSharp.RuntimeBinder.RuntimeBinder.CreateCallingObjectForCall C# (CSharp) Method

CreateCallingObjectForCall() private method

private CreateCallingObjectForCall ( ICSharpInvokeOrInvokeMemberBinder payload, ArgumentObject arguments, LocalVariableSymbol>.Dictionary dictionary ) : EXPR
payload ICSharpInvokeOrInvokeMemberBinder
arguments ArgumentObject
dictionary LocalVariableSymbol>.Dictionary
return Microsoft.CSharp.RuntimeBinder.Semantics.EXPR
        private EXPR CreateCallingObjectForCall(
            ICSharpInvokeOrInvokeMemberBinder payload,
            ArgumentObject[] arguments,
            Dictionary<int, LocalVariableSymbol> dictionary)
        {
            // Here we have a regular call, so create the calling object off of the first
            // parameter and pass it through.
            EXPR callingObject;
            if (payload.StaticCall)
            {
                if (arguments[0].Value == null || !(arguments[0].Value is Type))
                {
                    Debug.Assert(false, "Cannot make static call without specifying a type");
                    throw Error.InternalCompilerError();
                }
                Type t = arguments[0].Value as Type;
                callingObject = _exprFactory.CreateClass(_symbolTable.GetCTypeFromType(t), null, t.GetTypeInfo().ContainsGenericParameters ?
                        _exprFactory.CreateTypeArguments(SymbolLoader.getBSymmgr().AllocParams(_symbolTable.GetCTypeArrayFromTypes(t.GetGenericArguments())), null) : null);
            }
            else
            {
                // If we have a null argument, just bail and throw.
                if (!arguments[0].Info.UseCompileTimeType && arguments[0].Value == null)
                {
                    throw Error.NullReferenceOnMemberException();
                }

                callingObject = _binder.mustConvert(
                    CreateArgumentEXPR(arguments[0], dictionary[0]),
                    _symbolTable.GetCTypeFromType(arguments[0].Type));

                if (arguments[0].Type.GetTypeInfo().IsValueType && callingObject.isCAST())
                {
                    // If we have a struct type, unbox it.
                    callingObject.flags |= EXPRFLAG.EXF_UNBOXRUNTIME;
                }
            }
            return callingObject;
        }