System.Dynamic.BindingRestrictions.MergedRestriction.GetExpression C# (CSharp) Method

GetExpression() private method

private GetExpression ( ) : Expression
return System.Linq.Expressions.Expression
            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();
                    }
                }
            }
        }
BindingRestrictions.MergedRestriction