Exemplo n.º 1
0
        public override Expression Visit(Expression node)
        {
            if (node.NodeType == ExpressionType.NewArrayInit)
            {
                var a = node as NewArrayExpression;
                _count = a.Expressions.Count;
                return(base.Visit(node));
            }
            else if (node.NodeType == ExpressionType.MemberAccess)
            {
                var v = base.Visit(node);
                if (_InCommand != "")
                {
                    var a = _stack.Pop() as IList;
                    foreach (var c in a)
                    {
                        if (_inBmp == null)
                        {
                            _inBmp = qexpression(_InCommand, RDBExpression.Equal, c);
                        }
                        else
                        {
                            _inBmp = _inBmp.Or(qexpression(_InCommand, RDBExpression.Equal, c));
                        }
                    }
                }

                return(v);
            }
            else
            {
                return(base.Visit(node));
            }
        }
Exemplo n.º 2
0
        protected override Expression VisitBinary(BinaryExpression b)
        {
            _leftmode = true;
            var m = this.Visit(b.Left);

            if (m == null) // VB.net sty;e linq for string compare
            {
                return(b.Right);
            }
            ExpressionType t = b.NodeType;

            if (t == ExpressionType.Equal || t == ExpressionType.NotEqual ||
                t == ExpressionType.LessThan || t == ExpressionType.LessThanOrEqual ||
                t == ExpressionType.GreaterThan || t == ExpressionType.GreaterThanOrEqual)
            {
                _stack.Push(b.NodeType);
            }

            _leftmode = false;
            this.Visit(b.Right);
            t = b.NodeType;
            if (t == ExpressionType.Equal || t == ExpressionType.NotEqual ||
                t == ExpressionType.LessThanOrEqual || t == ExpressionType.LessThan ||
                t == ExpressionType.GreaterThanOrEqual || t == ExpressionType.GreaterThan
                )
            {
                // binary expression
                object         lval  = _stack.Pop();
                ExpressionType lop   = (ExpressionType)_stack.Pop();
                string         lname = (string)_stack.Pop();
                if (_stack.Count > 0)
                {
                    lname += "_" + (string)_stack.Pop();
                }
                RDBExpression exp = RDBExpression.Equal;
                if (lop == ExpressionType.LessThan)
                {
                    exp = RDBExpression.Less;
                }
                else if (lop == ExpressionType.LessThanOrEqual)
                {
                    exp = RDBExpression.LessEqual;
                }
                else if (lop == ExpressionType.GreaterThan)
                {
                    exp = RDBExpression.Greater;
                }
                else if (lop == ExpressionType.GreaterThanOrEqual)
                {
                    exp = RDBExpression.GreaterEqual;
                }
                else if (lop == ExpressionType.NotEqual)
                {
                    exp = RDBExpression.NotEqual;
                }

                _bitmap.Push(qexpression(lname, exp, lval));
            }

            if (t == ExpressionType.And || t == ExpressionType.AndAlso ||
                t == ExpressionType.Or || t == ExpressionType.OrElse)
            {
                if (_bitmap.Count > 1)
                {
                    // do bitmap operations
                    WAHBitArray right = (WAHBitArray)_bitmap.Pop();
                    WAHBitArray left  = (WAHBitArray)_bitmap.Pop();

                    if (t == ExpressionType.And || t == ExpressionType.AndAlso)
                    {
                        _bitmap.Push(right.And(left));
                    }
                    if (t == ExpressionType.Or || t == ExpressionType.OrElse)
                    {
                        _bitmap.Push(right.Or(left));
                    }
                }
                else
                {
                    // single bitmap operation
                }
            }
            return(b);
        }
Exemplo n.º 3
0
        protected override Expression VisitBinary(BinaryExpression b)
        {
            var m = this.Visit(b.Left);

            if (m == null) // VB.net sty;e linq for string compare
            {
                return(b.Right);
            }
            ExpressionType t = b.NodeType;

            if (t == ExpressionType.Equal || t == ExpressionType.NotEqual ||
                t == ExpressionType.LessThan || t == ExpressionType.LessThanOrEqual ||
                t == ExpressionType.GreaterThan || t == ExpressionType.GreaterThanOrEqual)
            {
                _stack.Push(b.NodeType);
            }


            this.Visit(b.Right);
            t = b.NodeType;
            if (t == ExpressionType.Equal || t == ExpressionType.NotEqual ||
                t == ExpressionType.LessThanOrEqual || t == ExpressionType.LessThan ||
                t == ExpressionType.GreaterThanOrEqual || t == ExpressionType.GreaterThan
                )
            {
                // binary expression
                object         lv  = _stack.Pop();
                ExpressionType lo  = (ExpressionType)_stack.Pop();
                object         ln  = _stack.Pop();
                RDBExpression  exp = RDBExpression.Equal;
                // FEATURE : add contains , between, startswith
                if (lo == ExpressionType.LessThan)
                {
                    exp = RDBExpression.Less;
                }
                else if (lo == ExpressionType.LessThanOrEqual)
                {
                    exp = RDBExpression.LessEqual;
                }
                else if (lo == ExpressionType.GreaterThan)
                {
                    exp = RDBExpression.Greater;
                }
                else if (lo == ExpressionType.GreaterThanOrEqual)
                {
                    exp = RDBExpression.GreaterEqual;
                }
                else if (lo == ExpressionType.NotEqual)
                {
                    exp = RDBExpression.NotEqual;
                }

                _bitmap.Push(qexpression("" + ln, exp, lv));
            }

            if (t == ExpressionType.And || t == ExpressionType.AndAlso ||
                t == ExpressionType.Or || t == ExpressionType.OrElse)
            {
                if (_bitmap.Count > 1)
                {
                    // do bitmap operations
                    WAHBitArray r = (WAHBitArray)_bitmap.Pop();
                    WAHBitArray l = (WAHBitArray)_bitmap.Pop();

                    if (t == ExpressionType.And || t == ExpressionType.AndAlso)
                    {
                        _bitmap.Push(r.And(l));
                    }
                    if (t == ExpressionType.Or || t == ExpressionType.OrElse)
                    {
                        _bitmap.Push(r.Or(l));
                    }
                }
                else
                {
                    // single bitmap operation
                }
            }
            return(b);
        }
Exemplo n.º 4
0
 private static WAHBitArray DoBitOperation(WAHBitArray bits, WAHBitArray c, OPERATION op, int maxsize)
 {
     if (bits != null)
     {
         switch (op)
         {
             case OPERATION.AND:
                 bits = c.And(bits);
                 break;
             case OPERATION.OR:
                 bits = c.Or(bits);
                 break;
             case OPERATION.ANDNOT:
                 bits = c.And(bits.Not(maxsize));
                 break;
         }
     }
     else
         bits = c;
     return bits;
 }