public override void ExitCase2Expr(MiniSqlParserParser.Case2ExprContext context) { Expr elseResult = null; var results = new List <Expr>(); var conditions = new List <Predicate>(); var branchCount = context.K_WHEN().Length; var comments = this.GetComments(context); if (context.K_ELSE() != null) { elseResult = (Expr)_stack.Pop(); } for (int i = 0; i < branchCount; ++i) { results.Insert(0, (Expr)_stack.Pop()); conditions.Insert(0, (Predicate)_stack.Pop()); } var node = new CaseExpr(conditions, results, elseResult, comments); _stack.Push(node); }
public override void VisitAfter(CaseExpr expr) { if (expr.IsSimpleCase) { if (IsPlaceHolderExpr(expr.SearchExpr)) { expr.SearchExpr = Place((PlaceHolderExpr)expr.SearchExpr); } for (int i = 0; i < expr.Comparisons.Count; ++i) { if (IsPlaceHolderExpr((Expr)expr.Comparisons[i]) || IsPlaceHolderExpr(expr.Results[i])) { expr.SetBranch(i , Place((PlaceHolderExpr)expr.Comparisons[i]) , Place((PlaceHolderExpr)expr.Results[i])); } } } else { for (int i = 0; i < expr.Conditions.Count; ++i) { if (IsPlaceHolderPredicate((Predicate)expr.Conditions[i]) || IsPlaceHolderExpr(expr.Results[i])) { expr.SetBranch(i , Place((PlaceHolderPredicate)expr.Conditions[i]) , Place((PlaceHolderExpr)expr.Results[i])); } } } if (IsPlaceHolderExpr(expr.ElseResult)) { expr.ElseResult = Place((PlaceHolderExpr)expr.ElseResult); } }
virtual public void VisitOnElse(CaseExpr expr) { }
virtual public void VisitOnThen(CaseExpr expr, int i) { }
virtual public void VisitAfter(CaseExpr expr) { }
virtual public void VisitBefore(CaseExpr expr) { }
public override void VisitAfter(CaseExpr expr) { bool isReferenceEqual = true; Expr elseResult = null; if (expr.ElseResult != null) { elseResult = (Expr)_stack.Pop(); isReferenceEqual = isReferenceEqual && object.ReferenceEquals(expr.ElseResult, elseResult); } var results = new List <Expr>(); for (var i = expr.Results.Count - 1; i >= 0; --i) { var result = (Expr)_stack.Pop(); results.Insert(0, result); isReferenceEqual = isReferenceEqual && object.ReferenceEquals(expr.Results[i], result); } if (expr.IsSimpleCase) { var comparisons = new List <Expr>(); for (var i = expr.Comparisons.Count - 1; i >= 0; --i) { var comparison = (Expr)_stack.Pop(); comparisons.Insert(0, comparison); isReferenceEqual = isReferenceEqual && object.ReferenceEquals(expr.Comparisons[i], comparison); } Expr searchExpr = (Expr)_stack.Pop(); if (isReferenceEqual && object.ReferenceEquals(expr.SearchExpr, searchExpr)) { _stack.Push(expr); return; } var node = new CaseExpr(searchExpr, comparisons, results, elseResult, expr.Comments.Clone()); _stack.Push(node); } else { var conditions = new List <Predicate>(); for (var i = expr.Conditions.Count - 1; i >= 0; --i) { var condition = (Predicate)_stack.Pop(); conditions.Insert(0, condition); isReferenceEqual = isReferenceEqual && object.ReferenceEquals(expr.Conditions[i], condition); } if (isReferenceEqual) { _stack.Push(expr); return; } var node = new CaseExpr(conditions, results, elseResult, expr.Comments.Clone()); _stack.Push(node); } }
public void VisitOnElse(CaseExpr expr) { _visitor.VisitOnElse(expr); }
public void VisitOnThen(CaseExpr expr, int i) { _visitor.VisitOnThen(expr, i); }
public void VisitAfter(CaseExpr expr) { _visitor.VisitAfter(expr); }
public void VisitBefore(CaseExpr expr) { _visitor.VisitBefore(expr); }
public sealed override void VisitAfter(CaseExpr expr) { --_caseNestLevel; }
public sealed override void VisitBefore(CaseExpr expr) { ++_caseNestLevel; }