AddReferencedGlobal() private method

private AddReferencedGlobal ( string name ) : string
name string
return string
コード例 #1
0
        internal override bool TryBindOuter(ScopeStatement from, PythonReference reference, out PythonVariable variable)
        {
            // Functions expose their locals to direct access
            if (TryGetVariable(reference.Name, out variable) && variable.Kind != VariableKind.Nonlocal)
            {
                variable.AccessedInNestedScope = true;

                if (variable.Kind == VariableKind.Local || variable.Kind == VariableKind.Parameter)
                {
                    from.AddFreeVariable(variable, true);

                    for (ScopeStatement scope = from.Parent; scope != this; scope = scope.Parent)
                    {
                        scope.AddFreeVariable(variable, false);
                    }

                    AddCellVariable(variable);
                    ContainsNestedFreeVariables = true;
                }
                else
                {
                    from.AddReferencedGlobal(reference.Name);
                }
                return(true);
            }
            return(false);
        }
コード例 #2
0
        internal override bool TryBindOuter(ScopeStatement from, PythonReference reference, out PythonVariable variable)
        {
            ContainsNestedFreeVariables = true;
            if (TryGetVariable(reference.Name, out variable))
            {
                Debug.Assert(variable.Kind != VariableKind.Nonlocal, "there should be no nonlocals in a comprehension");
                variable.AccessedInNestedScope = true;

                if (variable.Kind == VariableKind.Local || variable.Kind == VariableKind.Parameter)
                {
                    from.AddFreeVariable(variable, true);

                    for (ScopeStatement scope = from.Parent; scope != this; scope = scope.Parent)
                    {
                        scope.AddFreeVariable(variable, false);
                    }

                    AddCellVariable(variable);
                }
                else
                {
                    from.AddReferencedGlobal(reference.Name);
                }
                return(true);
            }
            return(false);
        }
コード例 #3
0
        internal override bool TryBindOuter(ScopeStatement from, PythonReference reference, out PythonVariable variable)
        {
            // Unbound variable
            from.AddReferencedGlobal(reference.Name);

            if (from.HasLateBoundVariableSets)
            {
                // If the context contains unqualified exec, new locals can be introduced
                // Therefore we need to turn this into a fully late-bound lookup which
                // happens when we don't have a PythonVariable.
                variable = null;
                return(false);
            }
            else
            {
                // Create a global variable to bind to.
                variable = EnsureGlobalVariable(reference.Name);
                return(true);
            }
        }
コード例 #4
0
ファイル: FunctionDefinition.cs プロジェクト: mstram/ironruby
        internal override bool TryBindOuter(ScopeStatement from, PythonReference reference, out PythonVariable variable) {
            // Functions expose their locals to direct access
            ContainsNestedFreeVariables = true;
            if (TryGetVariable(reference.Name, out variable)) {
                variable.AccessedInNestedScope = true;

                if (variable.Kind == VariableKind.Local || variable.Kind == VariableKind.Parameter) {
                    from.AddFreeVariable(variable, true);

                    for (ScopeStatement scope = from.Parent; scope != this; scope = scope.Parent) {
                        scope.AddFreeVariable(variable, false);
                    }

                    AddCellVariable(variable);
                } else {
                    from.AddReferencedGlobal(reference.Name);
                }
                return true;
            }
            return false;
        }
コード例 #5
0
ファイル: PythonAst.cs プロジェクト: Xiaoqing/main
        internal override bool TryBindOuter(ScopeStatement from, PythonReference reference, out PythonVariable variable) {
            // Unbound variable
            from.AddReferencedGlobal(reference.Name);

            if (from.HasLateBoundVariableSets) {
                // If the context contains unqualified exec, new locals can be introduced
                // Therefore we need to turn this into a fully late-bound lookup which
                // happens when we don't have a PythonVariable.
                variable = null;
                return false;
            } else {
                // Create a global variable to bind to.
                variable = EnsureGlobalVariable(reference.Name);
                return true;
            }
        }