Example #1
0
        internal void EnsureModuleVariables(PythonAnalyzer state) {
            var entry = ProjectEntry;

            _scope.SetModuleVariable("__builtins__", state.ClassInfos[BuiltinTypeId.Dict].Instance);
            _scope.SetModuleVariable("__file__", GetStr(state, entry.FilePath));
            _scope.SetModuleVariable("__name__", GetStr(state, Name));
            _scope.SetModuleVariable("__package__", GetStr(state, ParentPackage?.Name));
            if (state.LanguageVersion.Is3x()) {
                _scope.SetModuleVariable("__cached__", GetStr(state));
                if (ModulePath.IsInitPyFile(entry.FilePath)) {
                    _scope.SetModuleVariable("__path__", state.ClassInfos[BuiltinTypeId.List].Instance);
                }
                _scope.SetModuleVariable("__spec__", state.ClassInfos[BuiltinTypeId.Object].Instance);
            }
            ModuleDefinition.EnqueueDependents();

        }