RewriteExpression() private method

private RewriteExpression ( Expression node, Stack stack ) : System.Result
node Expression
stack Stack
return System.Result
Example #1
0
            internal MemberAssignmentRewriter(MemberAssignment binding, StackSpiller spiller, Stack stack) :
                base(binding, spiller)
            {
                Result result = spiller.RewriteExpression(binding.Expression, stack);

                _action = result.Action;
                _rhs    = result.Node;
            }
            internal MemberAssignmentRewriter(MemberAssignment memberBinding, StackSpiller stackSpiller, Stack stack) :
                base(memberBinding, stackSpiller)
            {
                var result = stackSpiller.RewriteExpression(memberBinding.Expression, stack);

                RewriteAction = result.Action;
                _rhs          = result.Node;
            }
            internal void Add(Expression node)
            {
                Debug.Assert(!_done);

                if (node == null)
                {
                    _expressions[_expressionsCount++] = null;
                    return;
                }

                Result exp = _self.RewriteExpression(node, _stack);
                _action |= exp.Action;
                _stack = Stack.NonEmpty;

                // track items in case we need to copy or spill stack
                _expressions[_expressionsCount++] = exp.Node;
            }
            /// <summary>
            ///     Adds a child <paramref name="expression" /> to the rewriter, causing
            ///     it to be rewritten using the parent stack spiller, and the evaluation
            ///     stack state and rewrite action to be updated accordingly.
            /// </summary>
            /// <param name="expression">The child expression to add.</param>
            internal void Add(Expression expression)
            {
                Debug.Assert(!_done);

                var exp = _self.RewriteExpression(expression, _stack);

                Action |= exp.Action;
                _stack  = Stack.NonEmpty;

                if (exp.Action == RewriteAction.SpillStack)
                {
                    _lastSpillIndex = _expressionsCount;
                }

                // Track items in case we need to copy or spill stack.
                _expressions[_expressionsCount++] = exp.Node;
            }
 internal MemberAssignmentRewriter(MemberAssignment binding, StackSpiller spiller, Stack stack) :
     base(binding, spiller)
 {
     Result result = spiller.RewriteExpression(binding.Expression, stack);
     _action = result.Action;
     _rhs = result.Node;
 }