Esempio n. 1
0
 public virtual void Visit(ConditionalExpression conditionalExpression)
 {
     VisitDynamic(conditionalExpression.Condition);
     WriteSpace().Write("?").WriteSpace();
     VisitDynamic(conditionalExpression.Left);
     WriteSpace().Write(":").WriteSpace();
     VisitDynamic(conditionalExpression.Right);
 }
 private static ConditionalExpression Clone(ConditionalExpression expression)
 {
     return new ConditionalExpression(Clone(expression.Condition), Clone(expression.Left), Clone(expression.Right));
 }
Esempio n. 3
0
        protected void Visit(ConditionalExpression conditionalExpression)
        {
            // First, dispatch to resolve type of node at deeper level
            Visit((Node)conditionalExpression);

            var leftType = conditionalExpression.Left.TypeInference.TargetType;
            var rightType = conditionalExpression.Right.TypeInference.TargetType;

            if (leftType == null || (leftType is ScalarType && !(rightType is ScalarType)))
            {
                conditionalExpression.Left = Cast(leftType, rightType, conditionalExpression.Left);
            }
            else
            {
                conditionalExpression.Right = Cast(rightType, leftType, conditionalExpression.Right);
            }
        }
Esempio n. 4
0
        public override Node Visit(ConditionalExpression conditionalExpression)
        {
            // First, dispatch to resolve type of node at deeper level
            base.Visit(conditionalExpression);

            var leftType = conditionalExpression.Left.TypeInference.TargetType;
            var rightType = conditionalExpression.Right.TypeInference.TargetType;

            if (leftType == null || (leftType is ScalarType && !(rightType is ScalarType)))
            {
                conditionalExpression.Left = Cast(leftType, rightType, conditionalExpression.Left);
            }
            else
            {
                conditionalExpression.Right = Cast(rightType, leftType, conditionalExpression.Right);
            }

            return conditionalExpression;
        }
Esempio n. 5
0
        protected virtual void Visit(ConditionalExpression conditionalExpression)
        {
            Visit((Node)conditionalExpression);

            // Type inference for conditional expression is using the left result
            var leftType = conditionalExpression.Left.TypeInference.TargetType;
            var rightType = conditionalExpression.Right.TypeInference.TargetType;

            conditionalExpression.TypeInference.TargetType = leftType;
            
            if (leftType == null || (leftType is ScalarType && !(rightType is ScalarType)))
            {
                conditionalExpression.TypeInference.TargetType = rightType;
            }
        }
        /// <summary>
        /// Visits the specified conditional expression.
        /// </summary>
        /// <param name="conditionalExpression">The conditional expression.</param>
        public override Node Visit(ConditionalExpression conditionalExpression)
        {
            base.Visit(conditionalExpression);

            // Type inference for conditional expression is using the left result
            var leftType = conditionalExpression.Left.TypeInference.TargetType;
            var rightType = conditionalExpression.Right.TypeInference.TargetType;

            conditionalExpression.TypeInference.TargetType = leftType;
            
            if (leftType == null || (leftType is ScalarType && !(rightType is ScalarType)))
            {
                conditionalExpression.TypeInference.TargetType = rightType;
            }

            return conditionalExpression;
        }