// This is not a general purpose helper, so do not use it to make // "correct" logical operator node based on the operator, it used // here in the context of children already are bound only the // new node needs to marked bound. This is to be used only // within the context of Normalize method of BinExpr. internal Expr makeAnyLogicalExpr(Expr l, Expr r, string op) { if (op == " and ") { LogicAndExpr newe = new LogicAndExpr(l, r) { bounded_ = true }; newe.FixNewExprTableRefs(l); if (r.tableRefs_.Count > 0 && !newe.TableRefsContainedBy(r.tableRefs_)) { newe.FixNewExprTableRefs(r); } return(newe); } else { LogicOrExpr newe = new LogicOrExpr(l, r); newe.FixNewExprTableRefs(l); if (r.tableRefs_.Count > 0 && !newe.TableRefsContainedBy(r.tableRefs_)) { newe.FixNewExprTableRefs(r); } newe.bounded_ = true; return(newe); } }
// a > 3 or c > 1, b > 5 => (a > 3 or c > 1) and (b > 5) public static Expr AddAndFilter(this Expr basefilter, Expr newcond) { Debug.Assert(newcond.IsBoolean()); if (basefilter is null) { return(newcond.Clone()); } return(LogicAndExpr.MakeExpr(basefilter, newcond.Clone())); }
public static LogicAndExpr MakeExpr(Expr l, Expr r) { Debug.Assert(l.bounded_ && r.bounded_); var and = new LogicAndExpr(l, r); and.ResetAggregateTableRefs(); and.markBounded(); return(and); }
// a List<Expr> conditions merge into a LogicAndExpr public static Expr AndListToExpr(this List <Expr> andlist) { Debug.Assert(andlist.Count >= 1); if (andlist.Count == 1) { return(andlist[0]); } else { var andexpr = LogicAndExpr.MakeExpr(andlist[0], andlist[1]); for (int i = 2; i < andlist.Count; i++) { andexpr.children_[0] = LogicAndExpr.MakeExpr(andexpr.l_(), andlist[i]); } return(andexpr); } }