Esempio n. 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();
Esempio n. 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));
Esempio n. 3
0
        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)));
        }
Esempio n. 4
0
 public UnaryLogic(UnaryLogicOperator @operator, BonsaiExpression expression) : base(typeof(bool))
 {
     Operator   = @operator;
     Expression = expression;
 }
Esempio n. 5
0
 public Comparison(ComparisonOperator @operator, BonsaiExpression left, BonsaiExpression right) : base(typeof(bool))
 {
     Operator = @operator;
     Left     = AssertNotNull(left);
     Right    = AssertNotNull(right);
 }
Esempio n. 6
0
 public static string Emit(BonsaiExpression exp, Emitter top, Emitter next) => Switch <string> .On(exp)
 .Match <Constant>(constant =>
Esempio n. 7
0
 public In(BonsaiExpression needle, BonsaiExpression haystack) : base(typeof(bool))
 {
     Needle   = needle;
     Haystack = haystack;
 }
Esempio n. 8
0
 public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) =>
 exp is In @in
Esempio n. 9
0
 public BinaryLogic(BinaryLogicOperator @operator, BonsaiExpression left, BonsaiExpression right) : base(typeof(bool))
 {
     Operator = @operator;
     Left     = AssertNotNull(left);
     Right    = AssertNotNull(right);
 }
Esempio n. 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 =>
Esempio n. 11
0
 public virtual string Emit(BonsaiExpression exp, Emitter top, Emitter next) => next(exp);
Esempio n. 12
0
 public virtual BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) => next(exp);
Esempio n. 13
0
 public override string Emit(BonsaiExpression exp, Emitter top, Emitter next) => SqlEmitter.Emit(exp, top, next);
Esempio n. 14
0
 public override BonsaiExpression PostProcess(BonsaiExpression exp, PostProcessor top, PostProcessor next) => RootCompiler.PostProcess(exp, top, next);