Ejemplo n.º 1
0
        private object GetCachedValue(bool lightThrow)
        {
            if (_global == null)
            {
                _global = ((TotemContext)_context.LanguageContext).GetModuleGlobalCache(_name);
            }

            if (_global.IsCaching)
            {
                if (_global.HasValue)
                {
                    return _global.Value;
                }
            }
            else
            {
                object value;

                if (_context.TryLookupBuiltin(_name, out value))
                {
                    return value;
                }
            }

            if (lightThrow)
            {
                return LightExceptions.Throw(TotemOps.GlobalNameError(_name));
            }
            throw TotemOps.GlobalNameError(_name);
        }
Ejemplo n.º 2
0
        private object GetCachedValue(bool lightThrow)
        {
            if (_global == null)
            {
                _global = ((PythonContext)_context.LanguageContext).GetModuleGlobalCache(_name);
            }

            if (_global.IsCaching)
            {
                if (_global.HasValue)
                {
                    return(_global.Value);
                }
            }
            else
            {
                object value;

                if (_context.TryLookupBuiltin(_name, out value))
                {
                    return(value);
                }
            }

            if (lightThrow)
            {
                return(LightExceptions.Throw(PythonOps.GlobalNameError(_name)));
            }
            throw PythonOps.GlobalNameError(_name);
        }
Ejemplo n.º 3
0
        private object GetCachedValue() {
            if (_global == null) {                
                _global = ((PythonContext)_context.LanguageContext).GetModuleGlobalCache(_name);
            }

            if (_global.IsCaching) {
                if (_global.HasValue) {
                    return _global.Value;
                }
            } else {
                object value;

                if (_context.TryLookupGlobal(_name, out value)) {
                    return value;
                }
            }

            throw PythonOps.GlobalNameError(_name);
        }
Ejemplo n.º 4
0
 internal bool TryGetModuleGlobalCache(string name, out ModuleGlobalCache cache)
 {
     lock (_builtinCache)
     {
         if (!_builtinCache.TryGetValue(name, out cache))
         {
             // only cache values currently in built-ins, everything else will have
             // no caching policy and will fall back to the LanguageContext.
             
             //object value;
             //if (BuiltinModuleInstance.__dict__.TryGetValue(name, out value))
             //{
             //    _builtinCache[name] = cache = new ModuleGlobalCache(value);
             //}
         }
     }
     return cache != null;
 }