@@ -22,23 +22,35 @@ namespace swift {
2222// / for the purpose of determining dependencies, but does not attempt to
2323// / load the module files.
2424class SwiftModuleScanner : public SerializedModuleLoaderBase {
25- public:
26- enum ScannerKind { MDS_plain, MDS_placeholder };
27-
2825private:
29- // / The kind of scanner this is (LLVM-style RTTI)
30- const ScannerKind kind;
31-
32- // / The module we're scanning dependencies of.
33- Identifier moduleName;
34-
3526 // / Scan the given interface file to determine dependencies.
3627 llvm::ErrorOr<ModuleDependencyInfo>
37- scanInterfaceFile (Twine moduleInterfacePath, bool isFramework ,
38- bool isTestableImport);
28+ scanInterfaceFile (Identifier moduleID, Twine moduleInterfacePath ,
29+ bool isFramework, bool isTestableImport);
3930
40- InterfaceSubContextDelegate &astDelegate;
31+ // / Scan the given serialized module file to determine dependencies.
32+ llvm::ErrorOr<ModuleDependencyInfo>
33+ scanBinaryModuleFile (Identifier moduleID, Twine binaryModulePath,
34+ bool isFramework, bool isTestableImport,
35+ bool isCandidateForTextualModule);
36+
37+ std::error_code findModuleFilesInDirectory (
38+ ImportPath::Element ModuleID, const SerializedModuleBaseName &BaseName,
39+ SmallVectorImpl<char > *ModuleInterfacePath,
40+ SmallVectorImpl<char > *ModuleInterfaceSourcePath,
41+ std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
42+ std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
43+ std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
44+ bool SkipBuildingInterface, bool IsFramework,
45+ bool IsTestableDependencyLookup) override ;
46+
47+ virtual void collectVisibleTopLevelModuleNames (
48+ SmallVectorImpl<Identifier> &names) const override {
49+ llvm_unreachable (" Not used" );
50+ }
4151
52+ // / AST delegate to be used for textual interface scanning
53+ InterfaceSubContextDelegate &astDelegate;
4254 // / Location where pre-built modules are to be built into.
4355 std::string moduleOutputPath;
4456 // / Location where pre-built SDK modules are to be built into.
@@ -51,37 +63,19 @@ class SwiftModuleScanner : public SerializedModuleLoaderBase {
5163 std::optional<ModuleDependencyInfo> dependencies;
5264
5365 SwiftModuleScanner (ASTContext &ctx, ModuleLoadingMode LoadMode,
54- Identifier moduleName,
5566 InterfaceSubContextDelegate &astDelegate,
5667 StringRef moduleOutputPath, StringRef sdkModuleOutputPath,
57- std::vector<std::string> swiftModuleClangCC1CommandLineArgs,
58- ScannerKind kind = MDS_plain)
68+ std::vector<std::string> swiftModuleClangCC1CommandLineArgs)
5969 : SerializedModuleLoaderBase(ctx, nullptr , LoadMode,
6070 /* IgnoreSwiftSourceInfoFile=*/ true ),
61- kind (kind), moduleName(moduleName), astDelegate(astDelegate),
71+ astDelegate (astDelegate),
6272 moduleOutputPath(moduleOutputPath),
6373 sdkModuleOutputPath(sdkModuleOutputPath),
6474 swiftModuleClangCC1CommandLineArgs(swiftModuleClangCC1CommandLineArgs) {}
6575
66- std::error_code findModuleFilesInDirectory (
67- ImportPath::Element ModuleID, const SerializedModuleBaseName &BaseName,
68- SmallVectorImpl<char > *ModuleInterfacePath,
69- SmallVectorImpl<char > *ModuleInterfaceSourcePath,
70- std::unique_ptr<llvm::MemoryBuffer> *ModuleBuffer,
71- std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
72- std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
73- bool SkipBuildingInterface, bool IsFramework,
74- bool IsTestableDependencyLookup) override ;
75-
76- virtual void collectVisibleTopLevelModuleNames (
77- SmallVectorImpl<Identifier> &names) const override {
78- llvm_unreachable (" Not used" );
79- }
80-
81- ScannerKind getKind () const { return kind; }
82- static bool classof (const SwiftModuleScanner *MDS) {
83- return MDS->getKind () == MDS_plain;
84- }
76+ // / Perform a filesystem search for a Swift module with a given name
77+ llvm::SmallVector<std::pair<ModuleDependencyID, ModuleDependencyInfo>, 1 >
78+ lookupSwiftModule (Identifier moduleName, bool isTestableImport);
8579};
8680} // namespace swift
8781
0 commit comments