Example #1
0
        Expression ConvertUnaryOperator(InvocationExpression invocation, UnaryOperatorType op, bool?isChecked = null)
        {
            if (invocation.Arguments.Count < 1)
            {
                return(NotSupported(invocation));
            }

            Expression expr = Convert(invocation.Arguments.ElementAt(0));

            if (expr == null)
            {
                return(null);
            }

            UnaryOperatorExpression uoe = new UnaryOperatorExpression(op, expr);

            if (isChecked != null)
            {
                uoe.AddAnnotation(isChecked.Value ? AddCheckedBlocks.CheckedAnnotation : AddCheckedBlocks.UncheckedAnnotation);
            }

            switch (invocation.Arguments.Count)
            {
            case 1:
                return(uoe);

            case 2:
                Match m = getMethodFromHandlePattern.Match(invocation.Arguments.ElementAt(1));
                if (m.Success)
                {
                    return(uoe.WithAnnotation(m.Get <AstNode>("method").Single().Annotation <IMethod>()));
                }
                else
                {
                    return(null);
                }

            default:
                return(NotSupported(invocation));
            }
        }
Example #2
0
        Expression ConvertUnaryOperator(InvocationExpression invocation, UnaryOperatorType op, bool? isChecked = null)
        {
            if (invocation.Arguments.Count < 1)
                return NotSupported(invocation);

            Expression expr = Convert(invocation.Arguments.ElementAt(0));
            if (expr == null)
                return null;

            UnaryOperatorExpression uoe = new UnaryOperatorExpression(op, expr);
            if (isChecked != null)
                uoe.AddAnnotation(isChecked.Value ? AddCheckedBlocks.CheckedAnnotation : AddCheckedBlocks.UncheckedAnnotation);

            switch (invocation.Arguments.Count) {
                case 1:
                    return uoe;
                case 2:
                    Match m = getMethodFromHandlePattern.Match(invocation.Arguments.ElementAt(1));
                    if (m.Success)
                        return uoe.WithAnnotation(m.Get<AstNode>("method").Single().Annotation<MethodReference>());
                    else
                        return null;
                default:
                    return NotSupported(invocation);
            }
        }