Beispiel #1
0
        internal PythonVariable DefineDeleted(string name)
        {
            PythonVariable variable = _currentScope.EnsureVariable(name);

            variable.RegisterDeletion();
            return(variable);
        }
Beispiel #2
0
        internal virtual void AddFreeVariable(PythonVariable variable, bool accessedInScope)
        {
            Debug.Assert(variable?.Kind is VariableKind.Local or VariableKind.Parameter);

            if (_freeVars == null)
            {
                _freeVars = new List <PythonVariable>();
            }

            if (!_freeVars.Contains(variable))
            {
                _freeVars.Add(variable);
                if (TryGetVariable(variable.Name, out PythonVariable nonlocal) &&
                    nonlocal.Kind is VariableKind.Nonlocal &&
                    nonlocal.MaybeDeleted)
                {
                    variable.RegisterDeletion();
                }
            }
        }