示例#1
0
 public virtual Expression VisitTernaryExpression(TernaryExpression expression)
 {
     if (expression == null) return null;
     expression.Operand1 = this.VisitExpression(expression.Operand1);
     expression.Operand2 = this.VisitExpression(expression.Operand2);
     expression.Operand3 = this.VisitExpression(expression.Operand3);
     return expression;
 }
示例#2
0
 public override Expression VisitTernaryExpression(TernaryExpression expression)
 {
     if (expression == null) return null;
     return base.VisitTernaryExpression((TernaryExpression)expression.Clone());
 }
示例#3
0
 private Expression ParseConditional(Expression condition, TokenSet followers){
   Debug.Assert(this.currentToken == Token.Conditional);
   this.GetNextToken();
   Expression trueExpr = this.ParseExpression(followers|Token.Colon);
   if (trueExpr == null) //Supply a dummy
     trueExpr = new Literal(null, null, this.scanner.CurrentSourceContext);
   Expression falseExpr;
   if (this.currentToken == Token.Colon){
     this.GetNextToken();
     falseExpr = this.ParseExpression(followers);
   }else{
     this.Skip(Token.Colon); //gives appropriate error message
     if (!followers[this.currentToken])
       //Assume that only the : is missing. Go ahead as if it were specified.
       falseExpr = this.ParseExpression(followers);
     else
       falseExpr = null;
   }
   if (falseExpr == null) //Supply a dummy
     falseExpr = new Literal(null, null, this.scanner.CurrentSourceContext);
   TernaryExpression result = new TernaryExpression(condition, trueExpr, falseExpr, NodeType.Conditional, null);
   result.SourceContext = condition.SourceContext;
   result.SourceContext.EndPos = falseExpr.SourceContext.EndPos;
   this.SkipTo(followers);
   return result;
 }
示例#4
0
		public override Expression VisitTernaryExpression(TernaryExpression ternaryExpression)
		{
      ternaryExpression = (TernaryExpression)ternaryExpression.Clone();

			ternaryExpression.Operand1 = simplify(ternaryExpression.Operand1);
			ternaryExpression.Operand2 = simplify(ternaryExpression.Operand2);
			ternaryExpression.Operand3 = simplify(ternaryExpression.Operand3);
			return ternaryExpression;
		}
示例#5
0
 public override Expression VisitTernaryExpression(TernaryExpression expression)
 {
     Write("(");
     this.VisitExpression(expression.Operand1);
     Write(" ? ");
     this.VisitExpression(expression.Operand2);
     Write(" : ");
     this.VisitExpression(expression.Operand3);
     Write(")");
     return expression;
 }
 public EventingVisitor(Action<TernaryExpression> visitTernaryExpression) { VisitedTernaryExpression += visitTernaryExpression; } public event Action<TernaryExpression> VisitedTernaryExpression; public override Expression VisitTernaryExpression(TernaryExpression expression) { if (VisitedTernaryExpression != null) VisitedTernaryExpression(expression); return base.VisitTernaryExpression(expression); }