Exemplo n.º 1
0
        /// <summary>
        /// Looks up a global variable.  If the variable is not defined in the
        /// global scope then built-ins is consulted.
        /// </summary>
        internal bool TryLookupBuiltin(string name, out object value)
        {
            object builtins;

            if (!GlobalDict.TryGetValue("__builtins__", out builtins))
            {
                value = null;
                return(false);
            }

            PythonModule builtinsScope = builtins as PythonModule;

            if (builtinsScope != null && builtinsScope.__dict__.TryGetValue(name, out value))
            {
                return(true);
            }

            PythonDictionary dict = builtins as PythonDictionary;

            if (dict != null && dict.TryGetValue(name, out value))
            {
                return(true);
            }

            value = null;
            return(false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets a variable from the global scope.
 /// </summary>
 internal bool TryGetGlobalVariable(string name, out object res)
 {
     return(GlobalDict.TryGetValue(name, out res));
 }
Exemplo n.º 3
0
 internal bool TryGetGlobalVariable(string name, out object?res)
 => GlobalDict.TryGetValue(name, out res);