mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Parsable interface and type reconstruction support for opaque types.
When printing a swiftinterface, represent opaque result types using an attribute that refers to the mangled name of the defining decl for the opaque type. To turn this back into a reference to the right decl's implicit OpaqueTypeDecl, use type reconstruction. Since type reconstruction doesn't normally concern itself with non-type decls, set up a lookup table in SourceFiles and ModuleFiles to let us handle the mapping from mangled name to opaque type decl in type reconstruction. (Since we're invoking type reconstruction during type checking, when the module hasn't yet been fully validated, we need to plumb a LazyResolver into the ASTBuilder in an unsightly way. Maybe there's a better way to do this... Longer term, at least, this surface design gives space for doing things more the right way--a more request-ified decl validator ought to be able to naturally lazily service this request without the LazyResolver reference, and if type reconstruction in the future learns how to reconstruct non-type decls, then the lookup tables can go away.)
This commit is contained in:
@@ -388,6 +388,10 @@ private:
|
||||
class LocalDeclTableInfo;
|
||||
using SerializedLocalDeclTable =
|
||||
llvm::OnDiskIterableChainedHashTable<LocalDeclTableInfo>;
|
||||
|
||||
using OpaqueReturnTypeDeclTableInfo = LocalDeclTableInfo;
|
||||
using SerializedOpaqueReturnTypeDeclTable =
|
||||
llvm::OnDiskIterableChainedHashTable<OpaqueReturnTypeDeclTableInfo>;
|
||||
|
||||
class NestedTypeDeclsTableInfo;
|
||||
using SerializedNestedTypeDeclsTable =
|
||||
@@ -408,6 +412,7 @@ private:
|
||||
std::unique_ptr<SerializedDeclTable> OperatorMethodDecls;
|
||||
std::unique_ptr<SerializedExtensionTable> ExtensionDecls;
|
||||
std::unique_ptr<SerializedLocalDeclTable> LocalTypeDecls;
|
||||
std::unique_ptr<SerializedOpaqueReturnTypeDeclTable> OpaqueReturnTypeDecls;
|
||||
std::unique_ptr<SerializedNestedTypeDeclsTable> NestedTypeDecls;
|
||||
std::unique_ptr<SerializedDeclMemberNamesTable> DeclMemberNames;
|
||||
|
||||
@@ -705,6 +710,10 @@ public:
|
||||
|
||||
/// Searches the module's local type decls for the given mangled name.
|
||||
TypeDecl *lookupLocalType(StringRef MangledName);
|
||||
|
||||
/// Search the module's opaque return type decls for the one corresponding to
|
||||
/// the given mangled name.
|
||||
OpaqueTypeDecl *lookupOpaqueResultType(StringRef MangledName);
|
||||
|
||||
/// Searches the module's nested type decls table for the given member of
|
||||
/// the given type.
|
||||
@@ -785,6 +794,9 @@ public:
|
||||
|
||||
/// Adds all local type decls to the given vector.
|
||||
void getLocalTypeDecls(SmallVectorImpl<TypeDecl*> &Results);
|
||||
|
||||
/// Add all opaque return type decls in the module to the given vector.
|
||||
void getOpaqueReturnTypeDecls(SmallVectorImpl<OpaqueTypeDecl*> &Results);
|
||||
|
||||
/// Adds all top-level decls to the given vector.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user