Ejemplo n.º 1
0
            internal override Expression GetExpression()
            {
                // We could optimize this better, e.g. common subexpression elimination
                // But for now, it's good enough.

                var testBuilder = new TestBuilder();

                // Visit the tree, left to right.
                // Use an explicit stack so we don't stack overflow.
                //
                // Left-most node is on top of the stack, so we always expand the
                // left most node each iteration.
                var stack = new Stack <BindingRestrictions>();
                BindingRestrictions top = this;

                for (; ;)
                {
                    if (top is MergedRestriction m)
                    {
                        stack.Push(m._right);
                        top = m._left;
                    }
                    else
                    {
                        testBuilder.Append(top);
                        if (stack.Count == 0)
                        {
                            return(testBuilder.ToExpression());
                        }

                        top = stack.Pop();
                    }
                }
            }
Ejemplo n.º 2
0
 public Expression ToExpression()
 {
     if (this == Empty)
     {
         return Expression.Constant(true);
     }
     TestBuilder builder = new TestBuilder();
     Stack<BindingRestrictions> stack = new Stack<BindingRestrictions>();
     stack.Push(this);
     do
     {
         BindingRestrictions restrictions = stack.Pop();
         MergedRestriction restriction = restrictions as MergedRestriction;
         if (restriction != null)
         {
             stack.Push(restriction.Right);
             stack.Push(restriction.Left);
         }
         else
         {
             builder.Append(restrictions);
         }
     }
     while (stack.Count > 0);
     return builder.ToExpression();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates the <see cref="Expression"/> representing the binding restrictions.
        /// </summary>
        /// <returns>The expression tree representing the restrictions.</returns>
        public Expression ToExpression()
        {
            // We could optimize this better, e.g. common subexpression elimination
            // But for now, it's good enough.

            if (this == Empty)
            {
                return(Expression.Constant(true));
            }

            var testBuilder = new TestBuilder();

            // Visit the tree, left to right.
            // Use an explicit stack so we don't stack overflow.
            //
            // Left-most node is on top of the stack, so we always expand the
            // left most node each iteration.
            var stack = new Stack <BindingRestrictions>();

            stack.Push(this);
            do
            {
                var top = stack.Pop();
                var m   = top as MergedRestriction;
                if (m != null)
                {
                    stack.Push(m.Right);
                    stack.Push(m.Left);
                }
                else
                {
                    testBuilder.Append(top);
                }
            } while (stack.Count > 0);

            return(testBuilder.ToExpression());
        }
        /// <summary>
        /// Creates the <see cref="Expression"/> representing the binding restrictions.
        /// </summary>
        /// <returns>The expression tree representing the restrictions.</returns>
        public Expression ToExpression() {
            // We could optimize this better, e.g. common subexpression elimination
            // But for now, it's good enough.

            if (this == Empty) {
                return Expression.Constant(true);
            }

            var testBuilder = new TestBuilder();

            // Visit the tree, left to right.
            // Use an explicit stack so we don't stack overflow.
            //
            // Left-most node is on top of the stack, so we always expand the
            // left most node each iteration.
            var stack = new Stack<BindingRestrictions>();
            stack.Push(this);
            do {
                var top = stack.Pop();
                var m = top as MergedRestriction;
                if (m != null) {
                    stack.Push(m.Right);
                    stack.Push(m.Left);
                } else {
                    testBuilder.Append(top);
                }
            } while (stack.Count > 0);

            return testBuilder.ToExpression();
        }
Ejemplo n.º 5
0
            internal override Expression GetExpression()
            {
                // We could optimize this better, e.g. common subexpression elimination
                // But for now, it's good enough.

                var testBuilder = new TestBuilder();

                // Visit the tree, left to right.
                // Use an explicit stack so we don't stack overflow.
                //
                // Left-most node is on top of the stack, so we always expand the
                // left most node each iteration.
                var stack = new Stack<BindingRestrictions>();
                BindingRestrictions top = this;
                for (;;)
                {
                    var m = top as MergedRestriction;
                    if (m != null)
                    {
                        stack.Push(m.Right);
                        top = m.Left;
                    }
                    else
                    {
                        testBuilder.Append(top);
                        if (stack.Count == 0)
                        {
                            return testBuilder.ToExpression();
                        }

                        top = stack.Pop();
                    }
                }
            }