sun::semantic_analysis::TypeRegistry
class · Source (opens in a new tab)
class sun::semantic_analysis::TypeRegistryTypeRegistry - Per-compilation-unit registry for class and interface types.
This replaces the static caches in Types class to avoid cross-test pollution. One exists per compilation, as part of its AnalysisResults, next to the DeclarationTable whose declarations its types are created for.
Public Functions
- TypeRegistry
- clear
- findSpecialization
- getClass
- getEnum
- getGenericInterface
- getInterface
- getSpecializedClass
- getSpecializedInterface
- operator=
- specialize
TypeRegistry
TypeRegistry(DeclarationTable &declarations)
public · function · Source (opens in a new tab)
sun::semantic_analysis::TypeRegistry::TypeRegistry(DeclarationTable &declarations)Creates nominal types tied to declarations, which must outlive this registry.
Related: DeclarationTable
TypeRegistry(const TypeRegistry &)=delete
public · function · Source (opens in a new tab)
sun::semantic_analysis::TypeRegistry::TypeRegistry(const TypeRegistry &)=deleteNon-copyable to prevent accidental duplication.
TypeRegistry(TypeRegistry &&)=default
public · function · Source (opens in a new tab)
sun::semantic_analysis::TypeRegistry::TypeRegistry(TypeRegistry &&)=defaultMovable.
clear
public · function · Source (opens in a new tab)
void sun::semantic_analysis::TypeRegistry::clear()Clear all caches (useful for REPL reset).
findSpecialization
public · function · Source (opens in a new tab)
DeclarationId sun::semantic_analysis::TypeRegistry::findSpecialization(const SpecializationKey &key) constReturn an existing instance without allocating a declaration.
Related: DeclarationId, SpecializationKey
getClass
getClass(DeclarationId id, const QualifiedName &name)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::ClassType > sun::semantic_analysis::TypeRegistry::getClass(DeclarationId id, const QualifiedName &name)Bind the current source name to a source class's existing identity.
Related: sun::types::ClassType, DeclarationId, QualifiedName
getClass(DeclarationId id)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::ClassType > sun::semantic_analysis::TypeRegistry::getClass(DeclarationId id)Get a source class before its source name has been assigned.
Related: sun::types::ClassType, DeclarationId
getEnum
getEnum(DeclarationId id)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::EnumType > sun::semantic_analysis::TypeRegistry::getEnum(DeclarationId id)Get a source enum before its source name has been assigned.
Related: sun::types::EnumType, DeclarationId
getEnum(DeclarationId id, const QualifiedName &name)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::EnumType > sun::semantic_analysis::TypeRegistry::getEnum(DeclarationId id, const QualifiedName &name)Bind the current source name to a source enum's existing identity.
Related: sun::types::EnumType, DeclarationId, QualifiedName
getGenericInterface
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::InterfaceType > sun::semantic_analysis::TypeRegistry::getGenericInterface(DeclarationId declaration, const QualifiedName &name, std::vector< std::string > typeParams)Intern a generic interface template by its source declaration.
Related: sun::types::InterfaceType, DeclarationId, QualifiedName
getInterface
getInterface(DeclarationId id)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::InterfaceType > sun::semantic_analysis::TypeRegistry::getInterface(DeclarationId id)Get a source interface before its source name has been assigned.
Related: sun::types::InterfaceType, DeclarationId
getInterface(DeclarationId id, const QualifiedName &name)
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::InterfaceType > sun::semantic_analysis::TypeRegistry::getInterface(DeclarationId id, const QualifiedName &name)Bind the current source name to a source interface's identity.
Related: sun::types::InterfaceType, DeclarationId, QualifiedName
getSpecializedClass
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::ClassType > sun::semantic_analysis::TypeRegistry::getSpecializedClass(DeclarationId id, const QualifiedName &name, const QualifiedName &source, const std::vector< sun::types::TypePtr > &arguments)Configure the class attached to an interned specialization.
Related: sun::types::ClassType, DeclarationId, QualifiedName, sun::types::TypePtr
getSpecializedInterface
public · function · Source (opens in a new tab)
std::shared_ptr< sun::types::InterfaceType > sun::semantic_analysis::TypeRegistry::getSpecializedInterface(DeclarationId id, const QualifiedName &name, const QualifiedName &source, const std::vector< sun::types::TypePtr > &arguments)Configure the interface attached to an interned specialization.
Related: sun::types::InterfaceType, DeclarationId, QualifiedName, sun::types::TypePtr
operator=
operator=(const TypeRegistry &)=delete
public · function · Source (opens in a new tab)
TypeRegistry & sun::semantic_analysis::TypeRegistry::operator=(const TypeRegistry &)=deleteDisallows assignment so ownership and object identity cannot be duplicated.
Related: TypeRegistry
operator=(TypeRegistry &&)=delete
public · function · Source (opens in a new tab)
TypeRegistry & sun::semantic_analysis::TypeRegistry::operator=(TypeRegistry &&)=deleteDisallows move assignment because the declaration table cannot be rebound.
Related: TypeRegistry
specialize
public · function · Source (opens in a new tab)
DeclarationId sun::semantic_analysis::TypeRegistry::specialize(const SpecializationKey &key)Intern an instance before resolving its members or body.
Related: DeclarationId, SpecializationKey
Private Functions
nominalType
private · function · Source (opens in a new tab)
template <typename T>
std::shared_ptr< T > sun::semantic_analysis::TypeRegistry::nominalType(DeclarationId id, DeclarationKind kind)Looks up the class, interface, or enum type for a declaration identity.
Related: DeclarationId, DeclarationKind
Private Fields
declarations_
private · variable · Source (opens in a new tab)
DeclarationTable& sun::semantic_analysis::TypeRegistry::declarations_No documentation comment.
Related: DeclarationTable
nominalTypes_
private · variable · Source (opens in a new tab)
std::unordered_map<DeclarationId, std::shared_ptr<sun::types::NominalType> > sun::semantic_analysis::TypeRegistry::nominalTypes_No documentation comment.
Related: DeclarationId, sun::types::NominalType
specializations_
private · variable · Source (opens in a new tab)
std::unordered_map<SpecializationKey, DeclarationId, SpecializationKeyHash> sun::semantic_analysis::TypeRegistry::specializations_No documentation comment.
Related: SpecializationKey, DeclarationId, SpecializationKeyHash