Example #1
0
        /// <summary>
        /// Initializes a new CSharp binary operation binder.
        /// </summary>
        ///
        /// <returns>
        /// Returns a new CSharp binary operation binder.
        /// </returns>
        /// <param name="flags">The flags with which to initialize the binder.</param><param name="operation">The binary operation kind.</param><param name="context">The <see cref="T:System.Type"/> that indicates where this operation is used.</param><param name="argumentInfo">The sequence of <see cref="T:Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo"/> instances for the arguments to this operation.</param>
        public static CallSiteBinder BinaryOperation(CSharpBinderFlags flags, ExpressionType operation, Type context, IEnumerable <CSharpArgumentInfo> argumentInfo)
        {
            bool isChecked = (flags & CSharpBinderFlags.CheckedContext) != CSharpBinderFlags.None;
            bool flag      = (flags & CSharpBinderFlags.BinaryOperationLogical) != CSharpBinderFlags.None;
            CSharpBinaryOperationFlags binaryOperationFlags = CSharpBinaryOperationFlags.None;

            if (flag)
            {
                binaryOperationFlags |= CSharpBinaryOperationFlags.LogicalOperation;
            }
            return((CallSiteBinder) new CSharpBinaryOperationBinder(operation, isChecked, binaryOperationFlags, context, argumentInfo));
        }
Example #2
0
        //////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpBinaryOperationBinder"/> class.
        /// </summary>
        /// <param name="operation">The binary operation kind.</param>
        /// <param name="isChecked">True if the operation is defined in a checked context; otherwise false.</param>
        /// <param name="binaryOperationFlags">The flags associated with this binary operation.</param>
        /// <param name="callingContext">The <see cref="Type"/> that indicates where this operation is defined.</param>
        /// <param name="argumentInfo">The sequence of <see cref="CSharpArgumentInfo"/> instances for the arguments to this operation.</param>
        public CSharpBinaryOperationBinder(
            ExpressionType operation,
            bool isChecked,
            CSharpBinaryOperationFlags binaryOperationFlags,
            Type callingContext,
            IEnumerable <CSharpArgumentInfo> argumentInfo) :
            base(operation)
        {
            _binopFlags   = binaryOperationFlags;
            _argumentInfo = BinderHelper.ToArray(argumentInfo);
            Debug.Assert(_argumentInfo.Length == 2);
            _binder = new RuntimeBinder(callingContext, isChecked);
        }
Example #3
0
        //////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpBinaryOperationBinder"/> class.
        /// </summary>
        /// <param name="operation">The binary operation kind.</param>
        /// <param name="isChecked">True if the operation is defined in a checked context; otherwise false.</param>
        /// <param name="binaryOperationFlags">The flags associated with this binary operation.</param>
        /// <param name="argumentInfo">The sequence of <see cref="CSharpArgumentInfo"/> instances for the arguments to this operation.</param>
        public CSharpBinaryOperationBinder(
            ExpressionType operation,
            bool isChecked,
            CSharpBinaryOperationFlags binaryOperationFlags,
            Type callingContext,
            IEnumerable <CSharpArgumentInfo> argumentInfo) :
            base(operation)
        {
            m_isChecked      = isChecked;
            m_binopFlags     = binaryOperationFlags;
            m_callingContext = callingContext;
            m_argumentInfo   = BinderHelper.ToList(argumentInfo);
            Debug.Assert(m_argumentInfo.Count == 2);
            m_binder = RuntimeBinder.GetInstance();
        }
        //////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpBinaryOperationBinder"/> class.
        /// </summary>
        /// <param name="operation">The binary operation kind.</param>
        /// <param name="isChecked">True if the operation is defined in a checked context; otherwise false.</param>        
        /// <param name="binaryOperationFlags">The flags associated with this binary operation.</param>
        /// <param name="argumentInfo">The sequence of <see cref="CSharpArgumentInfo"/> instances for the arguments to this operation.</param>
        public CSharpBinaryOperationBinder(
            ExpressionType operation,
            bool isChecked,
            CSharpBinaryOperationFlags binaryOperationFlags,
            Type callingContext,
            IEnumerable<CSharpArgumentInfo> argumentInfo) :
            base(operation)
        {
            _isChecked = isChecked;
            _binopFlags = binaryOperationFlags;
            _callingContext = callingContext;
            _argumentInfo = BinderHelper.ToList(argumentInfo);
            Debug.Assert(_argumentInfo.Count == 2);
            _binder = RuntimeBinder.GetInstance();
        }
Example #5
0
        //////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new CSharp binary operation binder.
        /// </summary>
        /// <param name="flags">The flags with which to initialize the binder.</param>
        /// <param name="operation">The binary operation kind.</param>
        /// <param name="context">The <see cref="System.Type"/> that indicates where this operation is used.</param>
        /// <param name="argumentInfo">The sequence of <see cref="CSharpArgumentInfo"/> instances for the arguments to this operation.</param>
        /// <returns>Returns a new CSharp binary operation binder.</returns>
        public static CallSiteBinder BinaryOperation(
            CSharpBinderFlags flags,
            ExpressionType operation,
            Type?context,
            IEnumerable <CSharpArgumentInfo>?argumentInfo)
        {
            bool isChecked = (flags & CSharpBinderFlags.CheckedContext) != 0;
            bool isLogical = (flags & CSharpBinderFlags.BinaryOperationLogical) != 0;

            CSharpBinaryOperationFlags binaryOperationFlags = 0;

            if (isLogical)
            {
                binaryOperationFlags |= CSharpBinaryOperationFlags.LogicalOperation;
            }

            return(new CSharpBinaryOperationBinder(operation, isChecked, binaryOperationFlags, context, argumentInfo).TryGetExisting());
        }