Пример #1
0
        //------------------------------------------------------------
        // FUNCBREC.BindUnaryOperator
        //
        // EXPR * BindStdUnaOp(BASENODE * tree, OPERATOR op, EXPR * arg);
        // EXPR * BindIntUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg);
        // EXPR * BindRealUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg);
        // EXPR * BindDecUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg);
        // EXPR * BindBoolUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg);
        // EXPR * BindEnumUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg);
        //------------------------------------------------------------
        internal EXPR BindUnaryOperator(
            BindUnaOpEnum op,
            BASENODE tree,
            EXPRKIND ek,
            EXPRFLAG flags,
            EXPR arg)
        {
            switch (op)
            {
            case BindUnaOpEnum.Integer:
                // Handles standard unary integer based operators.
                // EXPR * FUNCBREC::BindIntUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg)
                DebugUtil.Assert(arg.TypeSym.IsPredefined());
                return(BindIntOp(tree, ek, flags, arg, null, arg.TypeSym.GetPredefType()));

            case BindUnaOpEnum.Real:
                // Handles standard unary floating point (float, double) based operators.
                // EXPR * FUNCBREC::BindRealUnaOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg)
                DebugUtil.Assert(arg.TypeSym.IsPredefined());
                return(BindFloatOp(tree, ek, flags, arg, null));

            case BindUnaOpEnum.Decimal:
                return(BindDecUnaOp(tree, ek, flags, arg));

            case BindUnaOpEnum.Bool:
                return(BindBoolUnaOp(tree, ek, flags, arg));

                break;

            case BindUnaOpEnum.Enum:
                return(BindEnumUnaOp(tree, ek, flags, arg));

            default:
                DebugUtil.Assert(false, "FUNCBREC.BindUnaryOperator");
                break;
            }
            return(null);
        }
Пример #2
0
        //------------------------------------------------------------
        // FUNCBREC.BindBinaryOperator
        //
        // EXPR * BindIntBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindRealBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindDecBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindStrBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindShiftOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindBoolBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindBoolBitwiseOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindDelBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindEnumBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        //
        // EXPR * BindStrCmpOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindRefCmpOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindPtrBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        // EXPR * BindPtrCmpOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
        //
        /// <summary></summary>
        /// <param name="op"></param>
        /// <param name="tree"></param>
        /// <param name="ek"></param>
        /// <param name="flags"></param>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        /// <returns></returns>
        //------------------------------------------------------------
        private EXPR BindBinaryOperator(
            BindBinOpEnum op,
            BASENODE tree,
            EXPRKIND ek,
            EXPRFLAG flags,
            EXPR arg1,
            EXPR arg2)
        {
            switch (op)
            {
            case BindBinOpEnum.Integer:
                // Handles standard binary integer based operators.
                // EXPR * FUNCBREC::BindIntBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2)
                DebugUtil.Assert(
                    arg1.TypeSym.IsPredefined() &&
                    arg2.TypeSym.IsPredefined() &&
                    arg1.TypeSym.GetPredefType() == arg2.TypeSym.GetPredefType());
                return(BindIntOp(tree, ek, flags, arg1, arg2, arg1.TypeSym.GetPredefType()));

            case BindBinOpEnum.Real:
                // Handles standard binary floating point (float, double) based operators.
                // EXPR * FUNCBREC::BindRealBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2)
                DebugUtil.Assert(
                    arg1.TypeSym.IsPredefined() &&
                    arg2.TypeSym.IsPredefined() &&
                    arg1.TypeSym.GetPredefType() == arg2.TypeSym.GetPredefType());
                return(BindFloatOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.Decimal:
                return(BindDecBinOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.String:
                // Handles string concatenation.
                // EXPR * BindStrBinOp(BASENODE * tree, EXPRKIND ek, uint flags, EXPR * arg1, EXPR * arg2);
                DebugUtil.Assert(ek == EXPRKIND.ADD);
                DebugUtil.Assert(
                    arg1.TypeSym.IsPredefType(PREDEFTYPE.STRING) ||
                    arg2.TypeSym.IsPredefType(PREDEFTYPE.STRING));
                return(BindStringConcat(tree, arg1, arg2));

            case BindBinOpEnum.Shift:
                return(BindShiftOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.Bool:
                return(BindBoolBinOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.BoolBitwise:
                return(BindBoolBitwiseOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.Delegate:
                return(BindDelegateBinOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.Enum:
                return(BindEnumBinOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.StringCompare:
                return(BindStrCmpOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.ReferenceCompare:
                return(BindRefCmpOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.Pointer:
                return(BindPtrBinOp(tree, ek, flags, arg1, arg2));

            case BindBinOpEnum.PointerCompare:
                return(BindPtrCmpOp(tree, ek, flags, arg1, arg2));

            default:
                DebugUtil.Assert(false, "FUNCBREC.BindBinaryOperator");
                break;
            }
            return(null);
        }