public static UnifiedExpression CreateUnaryExpression(XElement node)
        {
            Contract.Requires(node != null);
            Contract.Requires(node.Name() == "unary_expression");

            /*
             * unary_expression
             * : postfix_expression
             | '++' unary_expression
             | '--' unary_expression
             | unary_operator cast_expression
             | 'sizeof' unary_expression
             | 'sizeof' '(' type_name ')'
             */
            var first = node.FirstElement();

            if (first.Name == "postfix_expression")
            {
                return
                    (CreatePostfixExpression(
                         node.Element("postfix_expression")));
            }
            if (first.Value == "sizeof")
            {
                var expression = node.NthElement(1).Name == "unary_expression" ?
                                 CreateUnaryExpression
                                 (
                    node
                    .
                    NthElement
                    (
                        1))
                                                                                 : CreateTypeName(node.NthElement(2));
                UnifiedSizeof.Create(expression);
            }
            if (first.Name == "unary_operator")
            {
                return(UnifiedProgramGeneratorHelper.CreatePrefixUnaryExpression
                       (
                           node, CreateCastExpression,
                           Sign2PrefixUnaryOperator));
            }
            return(UnifiedProgramGeneratorHelper.CreatePrefixUnaryExpression(
                       node, CreateUnaryExpression, Sign2PrefixUnaryOperator));
        }
Пример #2
0
 public UnifiedElement VisitSizeOfExpression(
     SizeOfExpression sizeOfExpression, object data)
 {
     return(UnifiedSizeof.Create(sizeOfExpression.Type.TryAcceptForExpression(this)));
 }