Exemplo n.º 1
0
        public override void SetMember(Node node, AnalysisUnit unit, string name, IAnalysisSet value) {
            var variable = Scope.CreateVariable(node, unit, name, false);
            if (variable.AddTypes(unit, value, true, ProjectEntry)) {
                ModuleDefinition.EnqueueDependents();
            }

            variable.AddAssignment(node, unit);
        }
Exemplo n.º 2
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();

        }