public IPythonType GetBuiltinType(BuiltinTypeId id) { IPythonType res; lock (_builtinTypes) { if (!_builtinTypes.TryGetValue(id, out res)) { var bm = ImportModule(BuiltinModuleName) as AstBuiltinsPythonModule; res = bm?.GetAnyMember($"__{id}") as IPythonType; if (res == null) { var name = SharedDatabaseState.GetBuiltinTypeName(id, _factory.Configuration.Version); if (string.IsNullOrEmpty(name)) { Debug.Assert(id == BuiltinTypeId.Unknown, $"no name for {id}"); if (!_builtinTypes.TryGetValue(BuiltinTypeId.Unknown, out res)) { _builtinTypes[BuiltinTypeId.Unknown] = res = new AstPythonType("<unknown>"); } } else { res = new AstPythonType(name); } } _builtinTypes[id] = res; } } return(res); }
public IPythonType GetBuiltinType(BuiltinTypeId id) { IPythonType res; lock (_builtinTypes) { if (!_builtinTypes.TryGetValue(id, out res)) { _builtinTypes[id] = res = _builtinModule?.GetAnyMember(SharedDatabaseState.GetBuiltinTypeName(id, _factory.Configuration.Version)) as IPythonType ?? new AstPythonType(id.ToString()); } } return(res); }
public KnownTypesView(IPythonInterpreter interpreter, Version version) { int count = (int)BuiltinTypeIdExtensions.LastTypeId; _children = new IAnalysisItemView[count]; for (int value = 1; value <= count; ++value) { var expectedName = SharedDatabaseState.GetBuiltinTypeName((BuiltinTypeId)value, version); string name = string.Format("{0} ({1})", expectedName, Enum.GetName(typeof(BuiltinTypeId), value) ); IPythonType type; try { type = interpreter.GetBuiltinType((BuiltinTypeId)value); if (expectedName != type.Name) { name = string.Format("{2} ({1}/{0})", expectedName, Enum.GetName(typeof(BuiltinTypeId), value), type.Name ); } } catch { type = null; } if (type != null) { _children[value - 1] = new ClassView( null, name, type ); } else { _children[value - 1] = new NullMember(name); } } }
public IPythonType GetBuiltinType(BuiltinTypeId id) { if (id == BuiltinTypeId.Unknown) { return(null); } if (_typeDb == null) { throw new KeyNotFoundException(string.Format("{0} ({1})", id, (int)id)); } var name = SharedDatabaseState.GetBuiltinTypeName(id, _typeDb.LanguageVersion); var res = _typeDb.BuiltinModule.GetAnyMember(name) as IPythonType; if (res == null) { throw new KeyNotFoundException(string.Format("{0} ({1})", id, (int)id)); } return(res); }
public FallbackBuiltinPythonType(PythonLanguageVersion version, BuiltinTypeId typeId) { DeclaringModule = version.Is3x() ? FallbackBuiltinModule.Instance3x : FallbackBuiltinModule.Instance2x; Name = SharedDatabaseState.GetBuiltinTypeName(typeId, version.ToVersion()); TypeId = typeId; }
public CPythonBuiltinModule(SharedDatabaseState typeDb, string moduleName, string filename, bool isBuiltin) : base(typeDb, moduleName, filename, isBuiltin) { }
public CPythonBuiltinModule(SharedDatabaseState typeDb, string moduleName, string filename, bool isBuiltin) : base(typeDb, moduleName, filename, isBuiltin) { }