public IExpression Conditional(Ast.Conditional conditional)
        {
            var condition = conditional.Condition.Accept(this);
            var then = conditional.Then.Accept(this);
            var @else = conditional.Else.Accept(this);

            if (condition.Type != typeof(bool))
                throw new ExpressionsException("Condition of conditional must evaluate to a boolean", ExpressionsExceptionType.TypeMismatch);

            var commonType = ResolveExpressionCommonType(then.Type, @else.Type, false, false, true);

            return new Expressions.Conditional(condition, then, @else, commonType);
        }
Exemple #2
0
        public virtual IAstNode Conditional(Conditional conditional)
        {
            var condition = conditional.Condition.Accept(this);
            var then      = conditional.Then.Accept(this);
            var @else     = conditional.Else.Accept(this);

            if (condition == conditional.Condition && then == conditional.Then && @else == conditional.Else)
            {
                return(conditional);
            }
            else
            {
                return(new Conditional(condition, then, @else));
            }
        }