private IMember GetOrCreate(BuiltinTypeId typeId) { if (typeId.IsVirtualId()) { switch (typeId) { case BuiltinTypeId.Str: typeId = LanguageVersion.Is3x() ? BuiltinTypeId.Unicode : BuiltinTypeId.Bytes; break; case BuiltinTypeId.StrIterator: typeId = LanguageVersion.Is3x() ? BuiltinTypeId.UnicodeIterator : BuiltinTypeId.BytesIterator; break; default: typeId = BuiltinTypeId.Unknown; break; } } lock (_cachedInstances) { if (!_cachedInstances.TryGetValue(typeId, out var value)) { _cachedInstances[typeId] = value = new FallbackBuiltinPythonType(this, typeId); } return(value); } }
private PythonType(string name, Location location, BuiltinTypeId typeId) : base(typeId.GetMemberId(), location) { Check.ArgumentNotNull(nameof(location), location.Module); _name = name ?? throw new ArgumentNullException(nameof(name)); _typeId = typeId; }
/// <summary> /// Implements iteration over list-like typed collection such as List[T] /// or Sequence[T]. Similar to the Iterator[T]. The iterator does not /// track items in the collection, it repeats the same item endlessly. /// </summary> public TypingIteratorType(IPythonType itemType, BuiltinTypeId iteratorType, IPythonInterpreter interpreter) : base(iteratorType, interpreter) { ItemTypes = new[] { itemType }; Repeat = true; Name = $"Iterator[{itemType.Name}]"; }
/// <summary> /// Gets a well known built-in type such as int, list, dict, etc... /// </summary> /// <param name="id">The built-in type to get</param> /// <returns>An IPythonType representing the type.</returns> /// <exception cref="KeyNotFoundException"> /// The requested type cannot be resolved by this interpreter. /// </exception> public IPythonType GetBuiltinType(BuiltinTypeId id) { if (id < 0 || id > BuiltinTypeIdExtensions.LastTypeId) { throw new KeyNotFoundException("(BuiltinTypeId)({0})".FormatInvariant((int)id)); } lock (_lock) { if (_builtinTypes.TryGetValue(id, out var res) && res != null) { return(res); } var bm = ModuleResolution.BuiltinsModule; var typeName = id.GetTypeName(LanguageVersion); if (typeName != null) { res = bm.GetMember(typeName) as IPythonType; } if (res == null) { res = bm.GetAnyMember("__{0}__".FormatInvariant(id)) as IPythonType; if (res == null) { return(_builtinTypes[BuiltinTypeId.Unknown]); } } _builtinTypes[id] = res; return(res); } }
/// <summary> /// Implements iteration over tuple-like typed collection such as Tuple[T1, T2, T3, ...] /// The iterator goes along declared items types and stops when there are no more types. /// </summary> public TypingIteratorType(IReadOnlyList <IPythonType> itemTypes, BuiltinTypeId iteratorType, IPythonInterpreter interpreter) : base(iteratorType, interpreter) { Check.ArgumentOutOfRange(nameof(itemTypes), () => itemTypes.Count == 0); ItemTypes = itemTypes; Name = $"Iterator[{CodeFormatter.FormatSequence(string.Empty, '(', itemTypes)}]"; }
private IPythonType GetOrCreate(BuiltinTypeId typeId) { if (typeId.IsVirtualId()) { switch (typeId) { case BuiltinTypeId.Str: typeId = BuiltinTypeId.Str; break; case BuiltinTypeId.StrIterator: typeId = BuiltinTypeId.StrIterator; break; default: typeId = BuiltinTypeId.Unknown; break; } } lock (_cachedInstances) { if (!_cachedInstances.TryGetValue(typeId, out var value)) { _cachedInstances[typeId] = value = new FallbackBuiltinPythonType(this, typeId); } return(value); } }
public IPythonType GetBuiltinType(BuiltinTypeId id) { if (id < 0 || id > BuiltinTypeIdExtensions.LastTypeId) { throw new KeyNotFoundException("(BuiltinTypeId)({0})".FormatInvariant((int)id)); } IPythonType res; lock (_builtinTypes) { if (!_builtinTypes.TryGetValue(id, out res)) { var bm = ImportModule(BuiltinModuleName) as AstBuiltinsPythonModule; res = bm?.GetAnyMember("__{0}__".FormatInvariant(id)) as IPythonType; if (res == null) { var name = id.GetTypeName(_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)) { 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); }
/// <summary> /// Creates type info for a list-like strongly typed collection, such as List[T]. /// </summary> /// <param name="typeName">Type name.</param> /// <param name="typeId">Collection type id. Can be used when list is used to simulate other collections, like a set.</param> /// <param name="itemType">List item type.</param> /// <param name="interpreter">Python interpreter.</param> /// <param name="isMutable">Tells of list represents a mutable collection.</param> /// <param name="formatName">If true, type will append item type names to the base type name.</param> public TypingListType(string typeName, BuiltinTypeId typeId, IPythonType itemType, IPythonInterpreter interpreter, bool isMutable, bool formatName = true) : base(typeId, interpreter.ModuleResolution.GetSpecializedModule("typing"), isMutable) { ItemType = itemType; Name = formatName ? $"{typeName}[{itemType.Name}]" : typeName; QualifiedName = formatName ? $"typing:{typeName}[{itemType.QualifiedName}]" : $"typing:{typeName}"; }
public CPythonType(IMemberContainer parent, ITypeDatabaseReader typeDb, string typeName, Dictionary<string, object> typeTable, BuiltinTypeId typeId) { Debug.Assert(parent is CPythonType || parent is CPythonModule); Debug.Assert(!typeId.IsVirtualId()); _typeName = typeName; _typeId = typeId; _module = GetDeclaringModule(parent); object value; if (typeTable.TryGetValue("is_hidden", out value)) { _includeInModule = !Convert.ToBoolean(value); } else { _includeInModule = true; } if (typeTable.TryGetValue("doc", out value)) { _doc = value as string; } if (typeTable.TryGetValue("builtin", out value)) { _isBuiltin = Convert.ToBoolean(value); } else { _isBuiltin = true; } if (typeTable.TryGetValue("bases", out value)) { var basesList = (List<object>)value; if (basesList != null) { _bases = new List<IPythonType>(); foreach (var baseType in basesList) { typeDb.LookupType(baseType, StoreBase); } } } if (typeTable.TryGetValue("mro", out value)) { var mroList = (List<object>)value; if (mroList != null && mroList.Count >= 1) { _mro = new IPythonType[mroList.Count]; // Many scraped types have invalid MRO entries because they // report their own module/name incorrectly. Since the first // item in the MRO is always self, we set it now. If the MRO // has a resolvable entry it will replace this one. _mro[0] = this; for (int i = 0; i < mroList.Count; ++i) { var capturedI = i; typeDb.LookupType(mroList[i], t => _mro[capturedI] = t); } } } if (typeTable.TryGetValue("members", out value)) { var membersTable = (Dictionary<string, object>)value; if (membersTable != null) { LoadMembers(typeDb, membersTable); } } _hasLocation = PythonTypeDatabase.TryGetLocation(typeTable, ref _line, ref _column); }
/// <summary> /// Implements iteration over tuple-like typed collection such as Tuple[T1, T2, T3, ...] /// The iterator goes along declared items types and stops when there are no more types. /// </summary> public TypingIteratorType(IReadOnlyList <IPythonType> itemTypes, BuiltinTypeId iteratorType, IPythonInterpreter interpreter) : base(iteratorType, interpreter.ModuleResolution.GetSpecializedModule("typing")) { ItemTypes = itemTypes; Name = $"Iterator[{CodeFormatter.FormatSequence(string.Empty, '(', itemTypes)}]"; QualifiedName = $"typing:Iterator[{CodeFormatter.FormatSequence(string.Empty, '(', itemTypes.Select(t => t.QualifiedName))}]"; }
public AndConstraint <PythonTypeAssertions> HaveType(BuiltinTypeId typeId, string because = "", params object[] reasonArgs) { var languageVersionIs3X = Is3X(_scope); AssertTypeIds(new[] { Subject.TypeId }, new[] { typeId }, $"{_moduleName}.{_name}", languageVersionIs3X, because, reasonArgs); return(new AndConstraint <PythonTypeAssertions>(this)); }
private string[] GetMembersOf(BuiltinTypeId typeId) { if (!_cachedMembers.TryGetValue(typeId, out var members)) { _cachedMembers[typeId] = members = Analyzer.Interpreter.GetBuiltinType(typeId).GetMemberNames(ModuleContext).ToArray(); } return(members.ToArray()); }
public AndConstraint <MemberAssertions> HaveType(BuiltinTypeId typeId, string because = "", params object[] reasonArgs) { Execute.Assertion.ForCondition(Type != null) .BecauseOf(because, reasonArgs) .FailWith($"Expected {GetQuotedName(Subject)} to have type{{reason}}"); Type.TypeId.Should().Be(typeId, because, reasonArgs); return(new AndConstraint <MemberAssertions>(this)); }
/// <summary> /// Implements iteration over list-like typed collection such as List[T] /// or Sequence[T]. Similar to the Iterator[T]. The iterator does not /// track items in the collection, it repeats the same item endlessly. /// </summary> public TypingIteratorType(IPythonType itemType, BuiltinTypeId iteratorType, IPythonInterpreter interpreter) : base(iteratorType, interpreter.ModuleResolution.GetSpecializedModule("typing")) { ItemTypes = new[] { itemType }; Repeat = true; Name = $"Iterator[{itemType.Name}]"; QualifiedName = $"typing:Iterator[{itemType.QualifiedName}]"; }
public PythonType( string name, Location location, Func <string, string> documentationProvider, BuiltinTypeId typeId = BuiltinTypeId.Unknown ) : this(name, location, typeId) { _documentationProvider = documentationProvider; }
private IPythonType CreateListType(string typeName, BuiltinTypeId typeId, IReadOnlyList <IPythonType> typeArgs, bool isMutable) { if (typeArgs.Count == 1) { return(TypingTypeFactory.CreateListType(Interpreter, typeName, typeId, typeArgs[0], isMutable)); } // TODO: report wrong number of arguments return(Interpreter.UnknownType); }
public PythonType( string name, Location location, string documentation, BuiltinTypeId typeId = BuiltinTypeId.Unknown ) : this(name, location, typeId) { Documentation = documentation; }
public static IMember __iter__(IPythonInterpreter interpreter, BuiltinTypeId contentTypeId) { var fn = new PythonFunctionType(@"__iter__", interpreter.ModuleResolution.BuiltinsModule, null, string.Empty, LocationInfo.Empty); var o = new PythonFunctionOverload(fn.Name, interpreter.ModuleResolution.BuiltinsModule, _ => fn.Location); o.AddReturnValue(PythonTypeIterator.FromTypeId(interpreter, contentTypeId)); fn.AddOverload(o); return(fn); }
public NameProtocol(ProtocolInfo self, string name, string documentation = null, BuiltinTypeId typeId = BuiltinTypeId.Object) : base(self) { _name = name; _doc = documentation; _typeId = typeId; _richDescription = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(WellKnownRichDescriptionKinds.Type, _name) }; }
public bool TrySetTypeId(BuiltinTypeId typeId) { if (_typeId != BuiltinTypeId.Unknown) { return(false); } _typeId = typeId; return(true); }
private string[] GetMembersOf(BuiltinTypeId typeId) { string[] members; if (!_cachedMembers.TryGetValue(typeId, out members)) { _cachedMembers[typeId] = members = Analyzer.Types[typeId].GetMemberNames(ModuleContext).ToArray(); } return(members.ToArray()); }
public AstPythonBuiltinType( PythonAst ast, IPythonModule declModule, ClassDefinition def, string doc ) : base(ast, declModule, def, doc, null) { _typeId = BuiltinTypeId.Unknown; }
public PythonClassType( ClassDefinition classDefinition, Location location, BuiltinTypeId builtinTypeId = BuiltinTypeId.Type ) : base(classDefinition.Name, location, classDefinition.GetDocumentation(), builtinTypeId) { Check.ArgumentNotNull(nameof(location), location.Module); location.Module.AddAstNode(this, classDefinition); }
public NameProtocol(ProtocolInfo self, IPythonType type) : base(self) { _name = type.Name; _doc = type.Documentation; _typeId = type.TypeId; _richDescription = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>(WellKnownRichDescriptionKinds.Type, _name) }; }
public PythonClassType( ClassDefinition classDefinition, IPythonModule declaringModule, LocationInfo location, BuiltinTypeId builtinTypeId = BuiltinTypeId.Type ) : base(classDefinition.Name, declaringModule, classDefinition.GetDocumentation(), location, builtinTypeId) { ClassDefinition = classDefinition; }
public PythonClassType( ClassDefinition classDefinition, IPythonType declaringType, Location location, BuiltinTypeId builtinTypeId = BuiltinTypeId.Type ) : base(classDefinition.Name, location, classDefinition.GetDocumentation(), builtinTypeId) { location.Module.AddAstNode(this, classDefinition); DeclaringType = declaringType; }
public IPythonType GetBuiltinType(BuiltinTypeId id) { var res = GetTypeFromType(Remote.GetBuiltinType(id)); if (res == null) { throw new KeyNotFoundException(string.Format("{0} ({1})", id, (int)id)); } return(res); }
public IPythonType GetBuiltinType(BuiltinTypeId id) { var res = _builtinModule.GetAnyMember(id.GetTypeName(PythonLanguageVersion.V37)) as IPythonType; if (res == null) { throw new KeyNotFoundException("{0} ({1})".FormatInvariant(id, (int)id)); } return(res); }
/// <summary> /// Creates type info for an collection. /// </summary> /// <param name="collectionTypeId">Collection type id, such as <see cref="BuiltinTypeId.List"/>.</param> /// <param name="declaringModule">Declaring module.</param> /// <param name="isMutable">Indicates if collection is mutable (like list) or immutable (like tuple).</param> public PythonCollectionType( BuiltinTypeId collectionTypeId, IPythonModule declaringModule, bool isMutable ) : base(collectionTypeId, declaringModule) { TypeId = collectionTypeId; IteratorType = new PythonIteratorType(collectionTypeId.GetIteratorTypeId(), declaringModule); IsMutable = isMutable; }
public PythonType( string name, Location location, string documentation, BuiltinTypeId typeId = BuiltinTypeId.Unknown ) : this(name, location, typeId) { BaseName = name ?? throw new ArgumentNullException(nameof(name)); Documentation = documentation; }
public CJType(IMemberContainer parent, ITypeDatabaseReader typeDb, string typeName, Dictionary<string, object> typeTable, BuiltinTypeId typeId) { Debug.Assert(parent is CJType || parent is CJModule); _typeName = typeName; _typeId = typeId; _module = GetDeclaringModule(parent); object value; if (typeTable.TryGetValue("is_hidden", out value)) { _includeInModule = !Convert.ToBoolean(value); } else { _includeInModule = true; } if (typeTable.TryGetValue("doc", out value)) { _doc = value as string; } if (typeTable.TryGetValue("builtin", out value)) { _isBuiltin = Convert.ToBoolean(value); } else { _isBuiltin = true; } if (typeTable.TryGetValue("bases", out value)) { var basesList = value as List<object>; if (basesList != null) { _bases = new List<IJType>(); foreach (var baseType in basesList) { typeDb.LookupType(baseType, StoreBase); } } } if (typeTable.TryGetValue("mro", out value)) { var mroList = value as List<object>; if (mroList != null) { _mro = new List<CJType>(); foreach (var mroType in mroList) { typeDb.LookupType(mroType, StoreMro); } } } object membersData; if (typeTable.TryGetValue("members", out membersData)) { var membersTable = membersData as Dictionary<string, object>; if (membersTable != null) { LoadMembers(typeDb, membersTable); } } _hasLocation = JTypeDatabase.TryGetLocation(typeTable, ref _line, ref _column); }
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 = 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; }
IPythonType IKnownPythonTypes.this[BuiltinTypeId id] { get { return _types[(int)id]; } }
public IJType GetBuiltinType(BuiltinTypeId id) { string name = ((ITypeDatabaseReader)_typeDb).GetBuiltinTypeName(id); if (name == null) { return null; } var res = _typeDb.BuiltinModule.GetAnyMember(name) as IJType; Debug.Assert(res != null); return res; }
string ITypeDatabaseReader.GetBuiltinTypeName(BuiltinTypeId id) { return _sharedState.GetBuiltinTypeName(id); }
public string GetBuiltinTypeName(BuiltinTypeId id) { string name; switch (id) { case BuiltinTypeId.Bool: name = "bool"; break; case BuiltinTypeId.Complex: name = "complex"; break; case BuiltinTypeId.Dict: name = "dict"; break; case BuiltinTypeId.Float: name = "float"; break; case BuiltinTypeId.Int: name = "int"; break; case BuiltinTypeId.List: name = "list"; break; case BuiltinTypeId.Long: name = "long"; break; case BuiltinTypeId.Object: name = "object"; break; case BuiltinTypeId.Set: name = "set"; break; case BuiltinTypeId.Str: if (_is3x) { name = "str"; } else { name = "unicode"; } break; case BuiltinTypeId.Bytes: if (_is3x) { name = "bytes"; } else { name = "str"; } break; case BuiltinTypeId.Tuple: name = "tuple"; break; case BuiltinTypeId.Type: name = "type"; break; case BuiltinTypeId.BuiltinFunction: name = "builtin_function"; break; case BuiltinTypeId.BuiltinMethodDescriptor: name = "builtin_method_descriptor"; break; case BuiltinTypeId.DictKeys: name = "dict_keys"; break; case BuiltinTypeId.DictValues: name = "dict_values"; break; case BuiltinTypeId.DictItems: name = "dict_items"; break; case BuiltinTypeId.Function: name = "function"; break; case BuiltinTypeId.Generator: name = "generator"; break; case BuiltinTypeId.NoneType: name = "NoneType"; break; case BuiltinTypeId.Ellipsis: name = "ellipsis"; break; case BuiltinTypeId.Module: name = "module_type"; break; case BuiltinTypeId.ListIterator: name = "list_iterator"; break; case BuiltinTypeId.TupleIterator: name = "tuple_iterator"; break; case BuiltinTypeId.SetIterator: name = "set_iterator"; break; case BuiltinTypeId.StrIterator: name = "str_iterator"; break; case BuiltinTypeId.BytesIterator: name = "bytes_iterator"; break; case BuiltinTypeId.CallableIterator: name = "callable_iterator"; break; default: return null; } return name; }
public void RecursiveTuples() { var code = @"class A(object): def __init__(self): self.top = None def fn(self, x, y): top = self.top if x > y: self.fn(y, x) return self.top = x, y, top def pop(self): self.top = self.top[2] def original(self, item=None): if item == None: item = self.top if item[2] != None: self.original(item[2]) x, y, _ = item a=A() a.fn(1, 2) a.fn(3, 4) a.fn(5, 6) a.fn(7, 8) a.fn(9, 10) a.fn(11, 12) a.fn(13, 14) x1, y1, _1 = a.top a.original() "; var entry = ProcessText(code); var expectedIntType1 = new[] { BuiltinTypeId.Int }; var expectedIntType2 = new[] { BuiltinTypeId.Int }; var expectedTupleType1 = new[] { BuiltinTypeId.Tuple, BuiltinTypeId.NoneType }; var expectedTupleType2 = new[] { BuiltinTypeId.Tuple, BuiltinTypeId.NoneType }; if (this is StdLibAnalysisTest) { expectedIntType1 = new BuiltinTypeId[0]; expectedIntType2 = new BuiltinTypeId[0]; expectedTupleType1 = new[] { BuiltinTypeId.NoneType }; } AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("x1", code.IndexOf("x1, y1, _1 =")), expectedIntType1); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("y1", code.IndexOf("x1, y1, _1 =")), expectedIntType1); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("_1", code.IndexOf("x1, y1, _1 =")), expectedTupleType1); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("x", code.IndexOf("x, y, _ =")), expectedIntType2); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("y", code.IndexOf("x, y, _ =")), expectedIntType2); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("_", code.IndexOf("x, y, _ =")), expectedTupleType2); AssertUtil.ContainsExactly(entry.GetTypeIdsByIndex("self.top", code.IndexOf("if item ==")), expectedTupleType2); }
public FallbackBuiltinPythonType(PythonLanguageVersion version, BuiltinTypeId typeId) { DeclaringModule = version.Is3x() ? FallbackBuiltinModule.Instance3x : FallbackBuiltinModule.Instance2x; Name = SharedDatabaseState.GetBuiltinTypeName(typeId, version.ToVersion()); TypeId = typeId; }
public IPythonType GetBuiltinType(BuiltinTypeId id) { throw new KeyNotFoundException(); }
public static string GetBuiltinTypeName(BuiltinTypeId id, Version languageVersion) { string name; switch (id) { case BuiltinTypeId.Bool: name = "bool"; break; case BuiltinTypeId.Complex: name = "complex"; break; case BuiltinTypeId.Dict: name = "dict"; break; case BuiltinTypeId.Float: name = "float"; break; case BuiltinTypeId.Int: name = "int"; break; case BuiltinTypeId.List: name = "list"; break; case BuiltinTypeId.Long: name = languageVersion.Major == 3 ? "int" : "long"; break; case BuiltinTypeId.Object: name = "object"; break; case BuiltinTypeId.Set: name = "set"; break; case BuiltinTypeId.Str: name = "str"; break; case BuiltinTypeId.Unicode: name = languageVersion.Major == 3 ? "str" : "unicode"; break; case BuiltinTypeId.Bytes: name = languageVersion.Major == 3 ? "bytes" : "str"; break; case BuiltinTypeId.Tuple: name = "tuple"; break; case BuiltinTypeId.Type: name = "type"; break; case BuiltinTypeId.BuiltinFunction: name = "builtin_function"; break; case BuiltinTypeId.BuiltinMethodDescriptor: name = "builtin_method_descriptor"; break; case BuiltinTypeId.DictKeys: name = "dict_keys"; break; case BuiltinTypeId.DictValues: name = "dict_values"; break; case BuiltinTypeId.DictItems: name = "dict_items"; break; case BuiltinTypeId.Function: name = "function"; break; case BuiltinTypeId.Generator: name = "generator"; break; case BuiltinTypeId.NoneType: name = "NoneType"; break; case BuiltinTypeId.Ellipsis: name = "ellipsis"; break; case BuiltinTypeId.Module: name = "module_type"; break; case BuiltinTypeId.ListIterator: name = "list_iterator"; break; case BuiltinTypeId.TupleIterator: name = "tuple_iterator"; break; case BuiltinTypeId.SetIterator: name = "set_iterator"; break; case BuiltinTypeId.StrIterator: name = "str_iterator"; break; case BuiltinTypeId.UnicodeIterator: name = languageVersion.Major == 3 ? "str_iterator" : "unicode_iterator"; break; case BuiltinTypeId.BytesIterator: name = languageVersion.Major == 3 ? "bytes_iterator" : "str_iterator"; break; case BuiltinTypeId.CallableIterator: name = "callable_iterator"; break; case BuiltinTypeId.Property: name = "property"; break; case BuiltinTypeId.ClassMethod: name = "classmethod"; break; case BuiltinTypeId.StaticMethod: name = "staticmethod"; break; case BuiltinTypeId.FrozenSet: name = "frozenset"; break; case BuiltinTypeId.Unknown: default: return null; } return name; }
public string GetBuiltinTypeName(BuiltinTypeId id) { return GetBuiltinTypeName(id, _langVersion); }
BuiltinClassInfo IKnownClasses.this[BuiltinTypeId id] { get { return _classInfos[(int)id]; } }
public IPythonType GetBuiltinType(BuiltinTypeId id) { var res = GetTypeFromType(Remote.GetBuiltinType(id)); if (res == null) { throw new KeyNotFoundException(string.Format("{0} ({1})", id, (int)id)); } return res; }