Represents a dynamic binary operation in C#, providing the binding semantics and the details about the operation. Instances of this class are generated by the C# compiler.
Inheritance: System.Dynamic.BinaryOperationBinder
        public static object TryEvalBinaryOperators <T1, T2>(
            T1 arg1,
            T2 arg2,
            CSharpArgumentInfoFlags arg1Flags,
            CSharpArgumentInfoFlags arg2Flags,
            ExpressionType opKind,
            Type accessibilityContext)
        {
            CSharpArgumentInfo arg1Info = CSharpArgumentInfo.Create(arg1Flags, null);
            CSharpArgumentInfo arg2Info = CSharpArgumentInfo.Create(arg2Flags, null);

            CSharpBinaryOperationBinder binder = new CSharpBinaryOperationBinder(
                opKind,
                false, // isChecked
                CSharpBinaryOperationFlags.None,
                accessibilityContext,
                new CSharpArgumentInfo[] { arg1Info, arg2Info });

            var site = CallSite <Func <CallSite, T1, T2, object> > .Create(binder);

            return(site.Target(site, arg1, arg2));
        }
Beispiel #2
0
        /////////////////////////////////////////////////////////////////////////////////

        private EXPR BindBinaryOperation(
                CSharpBinaryOperationBinder payload,
                ArgumentObject[] arguments,
                Dictionary<int, LocalVariableSymbol> dictionary)
        {
            if (arguments.Length != 2)
            {
                throw Error.BindBinaryOperatorRequireTwoArguments();
            }

            ExpressionKind ek = Operators.GetExpressionKind(GetOperatorKind(payload.Operation, payload.IsLogicalOperation));
            EXPR arg1 = CreateArgumentEXPR(arguments[0], dictionary[0]);
            EXPR arg2 = CreateArgumentEXPR(arguments[1], dictionary[1]);

            arg1.errorString = Operators.GetDisplayName(GetOperatorKind(payload.Operation, payload.IsLogicalOperation));
            arg2.errorString = Operators.GetDisplayName(GetOperatorKind(payload.Operation, payload.IsLogicalOperation));

            if (ek > ExpressionKind.EK_MULTIOFFSET)
            {
                ek = (ExpressionKind)(ek - ExpressionKind.EK_MULTIOFFSET);
            }
            return _binder.BindStandardBinop(ek, arg1, arg2);
        }