Exemplo n.º 1
0
        void UnaryDispatch(string op, Expression e)
        {
            var  ue         = (UnaryExpression)e;
            bool needsSpace = ExpressionPrecedence.TokenizerConfusable(ue.NodeType, ue.Operand.NodeType);

            Sink(op + (needsSpace ? " " : ""), e);
            NestExpression(ue.NodeType, ue.Operand);
        }
Exemplo n.º 2
0
        void NestExpression(ExpressionType?parentType, Expression child, bool parensIfEqualRank = false)
        {
            int  parentRank  = parentType == null ? 0 : ExpressionPrecedence.Rank(parentType.Value);
            bool needsParens = parentRank > 0 &&
                               (parensIfEqualRank ? parentRank - 1 : parentRank) < ExpressionPrecedence.Rank(child.NodeType);

            if (needsParens)
            {
                sink(ExprTextPart.TextOnly("("), Depth);
            }
            RawChildDispatch(child);
            if (needsParens)
            {
                sink(ExprTextPart.TextOnly(")"), Depth);
            }
        }