protected virtual EXPR GenerateBuiltInUnaryOperator(EXPRUNARYOP expr)
        {
            Debug.Assert(expr != null);
            Debug.Assert(alwaysRewrite || currentAnonMeth != null);
            PREDEFMETH pdm;
            switch (expr.kind)
            {
                case ExpressionKind.EK_UPLUS:
                    return Visit(expr.Child);
                case ExpressionKind.EK_BITNOT: pdm = PREDEFMETH.PM_EXPRESSION_NOT; break;
                case ExpressionKind.EK_LOGNOT: pdm = PREDEFMETH.PM_EXPRESSION_NOT; break;
                case ExpressionKind.EK_NEG:
                    pdm = expr.isChecked() ? PREDEFMETH.PM_EXPRESSION_NEGATECHECKED : PREDEFMETH.PM_EXPRESSION_NEGATE;
                    break;
                default:
                    throw Error.InternalCompilerError();
            }
            EXPR origOp = expr.Child;

            return GenerateBuiltInUnaryOperator(pdm, origOp, expr);
        }
        protected virtual EXPR GenerateUserDefinedUnaryOperator(EXPRUNARYOP expr)
        {
            Debug.Assert(expr != null);
            Debug.Assert(alwaysRewrite || currentAnonMeth != null);
            PREDEFMETH pdm;
            EXPR arg = expr.Child;
            EXPRCALL call = expr.OptionalUserDefinedCall.asCALL();
            if (call != null)
            {
                // Use the actual argument of the call; it may contain user-defined
                // conversions or be a bound lambda, and that will not be in the original
                // argument stashed away in the left child of the operator.
                arg = call.GetOptionalArguments();
            }
            Debug.Assert(arg != null && arg.kind != ExpressionKind.EK_LIST);
            switch (expr.kind)
            {
                case ExpressionKind.EK_TRUE:
                case ExpressionKind.EK_FALSE:
                    return Visit(call);
                case ExpressionKind.EK_UPLUS:
                    pdm = PREDEFMETH.PM_EXPRESSION_UNARYPLUS_USER_DEFINED;
                    break;
                case ExpressionKind.EK_BITNOT: pdm = PREDEFMETH.PM_EXPRESSION_NOT_USER_DEFINED; break;
                case ExpressionKind.EK_LOGNOT: pdm = PREDEFMETH.PM_EXPRESSION_NOT_USER_DEFINED; break;
                case ExpressionKind.EK_DECIMALNEG:
                case ExpressionKind.EK_NEG:
                    pdm = expr.isChecked() ? PREDEFMETH.PM_EXPRESSION_NEGATECHECKED_USER_DEFINED : PREDEFMETH.PM_EXPRESSION_NEGATE_USER_DEFINED;
                    break;

                case ExpressionKind.EK_INC:
                case ExpressionKind.EK_DEC:
                case ExpressionKind.EK_DECIMALINC:
                case ExpressionKind.EK_DECIMALDEC:
                    pdm = PREDEFMETH.PM_EXPRESSION_CALL;
                    break;

                default:
                    throw Error.InternalCompilerError();
            }
            EXPR op = Visit(arg);
            EXPR methodInfo = GetExprFactory().CreateMethodInfo(expr.UserDefinedCallMethod);

            if (expr.kind == ExpressionKind.EK_INC || expr.kind == ExpressionKind.EK_DEC ||
                expr.kind == ExpressionKind.EK_DECIMALINC || expr.kind == ExpressionKind.EK_DECIMALDEC)
            {
                return GenerateCall(pdm, null, methodInfo, GenerateParamsArray(op, PredefinedType.PT_EXPRESSION));
            }
            return GenerateCall(pdm, op, methodInfo);
        }
Beispiel #3
0
 protected virtual EXPR VisitBITNOT(EXPRUNARYOP pExpr)
 {
     return VisitUNARYOP(pExpr);
 }
 protected override EXPR VisitUNARYOP(EXPRUNARYOP pExpr)
 {
     Debug.Assert(pExpr != null);
     Debug.Assert(alwaysRewrite || currentAnonMeth != null);
     if (pExpr.UserDefinedCallMethod != null)
     {
         return GenerateUserDefinedUnaryOperator(pExpr);
     }
     else
     {
         return GenerateBuiltInUnaryOperator(pExpr);
     }
 }
Beispiel #5
0
 protected virtual EXPR VisitDECIMALINC(EXPRUNARYOP pExpr)
 {
     return VisitUNARYOP(pExpr);
 }
Beispiel #6
0
 protected virtual EXPR VisitTRUE(EXPRUNARYOP pExpr)
 {
     return VisitUNARYOP(pExpr);
 }
Beispiel #7
0
 public EXPRUNARYOP CreateUserDefinedUnaryOperator(ExpressionKind exprKind, CType pType, EXPR pOperand, EXPR call, MethPropWithInst pmpwi)
 {
     Debug.Assert(pType != null);
     Debug.Assert(pOperand != null);
     Debug.Assert(call != null);
     Debug.Assert(pmpwi != null);
     EXPRUNARYOP rval = new EXPRUNARYOP();
     rval.kind = exprKind;
     rval.type = pType;
     rval.flags = 0;
     rval.Child = pOperand;
     // The call may be lifted, but we do not mark the outer binop as lifted.
     rval.OptionalUserDefinedCall = call;
     rval.UserDefinedCallMethod = pmpwi;
     if (call.HasError())
     {
         rval.SetError();
     }
     Debug.Assert(rval != null);
     return (rval);
 }
Beispiel #8
0
 public EXPRUNARYOP CreateUnaryOp(ExpressionKind exprKind, CType pType, EXPR pOperand)
 {
     Debug.Assert(exprKind.isUnaryOperator());
     Debug.Assert(pOperand != null);
     EXPRUNARYOP rval = new EXPRUNARYOP();
     rval.kind = exprKind;
     rval.type = pType;
     rval.flags = 0;
     rval.Child = pOperand;
     rval.OptionalUserDefinedCall = null;
     rval.UserDefinedCallMethod = null;
     Debug.Assert(rval != null);
     return (rval);
 }
 protected virtual EXPR VisitDECIMALINC(EXPRUNARYOP pExpr)
 {
     return(VisitUNARYOP(pExpr));
 }
 protected virtual EXPR VisitUPLUS(EXPRUNARYOP pExpr)
 {
     return(VisitUNARYOP(pExpr));
 }
 protected virtual EXPR VisitBITNOT(EXPRUNARYOP pExpr)
 {
     return(VisitUNARYOP(pExpr));
 }