Example #1
0
                internal bool WalkName(NameExpression node, PythonReference reference)
                {
                    if (_collector.ReadFromExtractedCode(reference.Variable))
                    {
                        if ((!_collector._inputCollector._allReads.Contains(reference) &&
                             !_collector._inputCollector._allWrites.Contains(reference)))
                        {
                            // the variable is assigned outside the refactored code
                            if (node.StartIndex < _collector._target.StartIncludingIndentation)
                            {
                                // it's assigned before the extracted code
                                _collector._inputVars.Add(reference.Variable);
                            }
                            else
                            {
                                Debug.Assert(node.EndIndex > _collector._target.End);
                                // it's assigned afterwards, we don't care...
                            }
                        }
                        else if (_collector._readBeforeInitialized.Contains(reference.Variable) &&
                                 _collector._inputCollector._allWrites.Contains(reference) &&
                                 _collector._inLoop)
                        {
                            // we read an un-initialized value, so it needs to be passed in.  If we
                            // write to it as well then we need to pass it back out for future calls.
                            _collector._outputVars.Add(reference.Variable);
                        }
                    }

                    return(false);
                }