Exemple #1
0
 public static BonsaiExpression PostProcess(BonsaiExpression expression, PostProcessor top, PostProcessor next) =>
 Switch <BonsaiExpression> .On(expression)
 .Match <BinaryLogic>(x => new BinaryLogic(x.Operator, top(x.Left), top(x.Right)))
 .Match <Column>(x => x)
 .Match <Comparison>(x => new Comparison(x.Operator, top(x.Left), top(x.Right)))
 .Match <Constant>(x => x)
 .Match <UnaryLogic>(x => new UnaryLogic(x.Operator, top(x.Expression)))
 .Match <List>(x => new List(x.Values.Select(top.Invoke), x.ElementType, x.Type))
 .OrThrow();
Exemple #2
0
        public override string Emit(BonsaiExpression exp, Emitter top, Emitter next) => Switch <string> .On(exp)
        .Match <In>(@in =>
        {
            var list = top(@in.Haystack);

            return(list != string.Empty
                    ? $"{top(@in.Needle)} IN ({list})"
                    : "0 <> 0");
        })
        .Else(() => next(exp));
        public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next)
        {
            return(Switch <BonsaiExpression> .On(exp)
                   .Match <Comparison>(x =>
            {
                if (x.Left is Column)
                {
                    return next(x);
                }

                if (x.Right is Column)
                {
                    return new Comparison(x.Operator, top(x.Right), top(x.Left));
                }

                return next(x);
            })
                   .Else(() => next(exp)));
        }
Exemple #4
0
 public UnaryLogic(UnaryLogicOperator @operator, BonsaiExpression expression) : base(typeof(bool))
 {
     Operator   = @operator;
     Expression = expression;
 }
Exemple #5
0
 public Comparison(ComparisonOperator @operator, BonsaiExpression left, BonsaiExpression right) : base(typeof(bool))
 {
     Operator = @operator;
     Left     = AssertNotNull(left);
     Right    = AssertNotNull(right);
 }
Exemple #6
0
 public static string Emit(BonsaiExpression exp, Emitter top, Emitter next) => Switch <string> .On(exp)
 .Match <Constant>(constant =>
Exemple #7
0
 public In(BonsaiExpression needle, BonsaiExpression haystack) : base(typeof(bool))
 {
     Needle   = needle;
     Haystack = haystack;
 }
Exemple #8
0
 public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) =>
 exp is In @in
Exemple #9
0
 public BinaryLogic(BinaryLogicOperator @operator, BonsaiExpression left, BonsaiExpression right) : base(typeof(bool))
 {
     Operator = @operator;
     Left     = AssertNotNull(left);
     Right    = AssertNotNull(right);
 }
Exemple #10
0
 /// <summary>
 /// Expects PostCompilers.NormalizeComparisons to have been applied.
 /// </summary>
 public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) =>
 Switch <BonsaiExpression> .On(exp)
 .Match <Comparison>(x =>
Exemple #11
0
 public virtual string Emit(BonsaiExpression exp, Emitter top, Emitter next) => next(exp);
Exemple #12
0
 public virtual BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) => next(exp);
Exemple #13
0
 public override string Emit(BonsaiExpression exp, Emitter top, Emitter next) => SqlEmitter.Emit(exp, top, next);
Exemple #14
0
 public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) => RootCompiler.PostProcess(exp, top, next);