Esempio n. 1
0
        private VariableDef CreateVariableInDeclaredScope(NameExpression name)
        {
            var reference = name.GetVariableReference(_entry.Tree);

            if (reference != null && reference.Variable != null) {
                var declNode = reference.Variable.Scope;
                var declScope = _scope.EnumerateTowardsGlobal.FirstOrDefault(s => s.Node == declNode);
                if (declScope != null) {
                    return declScope.CreateVariable(name, _curUnit, name.Name, false);
                }
            }

            return _scope.CreateVariable(name, _curUnit, name.Name, false);
        }
Esempio n. 2
0
                public override bool Walk(NameExpression node)
                {
                    var reference = node.GetVariableReference(_collector._root);

                    return WalkName(node, reference);
                }
Esempio n. 3
0
                public override bool Walk(NameExpression node)
                {
                    var reference = node.GetVariableReference(_collector._root);

                    _collector._allWrites.Add(reference);
                    _collector._allWrittenVariables.Add(reference.Variable);
                    return false;
                }
Esempio n. 4
0
            public override bool Walk(NameExpression node)
            {
                var reference = node.GetVariableReference(_root);
                if (!_inputCollector._allReads.Contains(reference) && !_inputCollector._allWrites.Contains(reference)) {
                    // this variable is referenced outside of the refactored code
                    if (node.StartIndex < _target.Start) {
                        // it's read before the extracted code, we don't care...
                    } else {
                        Debug.Assert(node.EndIndex > _target.End, "didn't reference variable in extracted range");

                        // it's read after the extracted code, if its written to in the refactored
                        // code we need to include it as an output
                        if (_inputCollector._allWrittenVariables.Contains(reference.Variable) &&
                            (_readByFollowingCodeBeforeInit == null || _readByFollowingCodeBeforeInit.Contains(reference.Variable))) {
                            // the variable is written to by the refactored code
                            _outputVars.Add(reference.Variable);
                        }
                    }
                }

                return true;
            }
Esempio n. 5
0
            public override bool Walk(NameExpression node)
            {
                var reference = node.GetVariableReference(_root);

                _allReads.Add(reference);
                _allReadVariables.Add(reference.Variable);
                return true;
            }