@@ -309,27 +309,52 @@ struct ModuleInterfaceLoaderOptions {
309
309
ModuleInterfaceLoaderOptions () = default ;
310
310
};
311
311
312
+ class ModuleInterfaceCheckerImpl : public ModuleInterfaceChecker {
313
+ friend class ModuleInterfaceLoader ;
314
+ ASTContext &Ctx;
315
+ std::string CacheDir;
316
+ std::string PrebuiltCacheDir;
317
+ ModuleInterfaceLoaderOptions Opts;
318
+
319
+ public:
320
+ explicit ModuleInterfaceCheckerImpl (ASTContext &Ctx,
321
+ StringRef cacheDir,
322
+ StringRef prebuiltCacheDir,
323
+ ModuleInterfaceLoaderOptions Opts)
324
+ : Ctx(Ctx), CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
325
+ Opts(Opts) {}
326
+
327
+ std::vector<std::string>
328
+ getCompiledModuleCandidatesForInterface (StringRef moduleName,
329
+ StringRef interfacePath) override ;
330
+
331
+ // / Given a list of potential ready-to-use compiled modules for \p interfacePath,
332
+ // / check if any one of them is up-to-date. If so, emit a forwarding module
333
+ // / to the candidate binary module to \p outPath.
334
+ bool tryEmitForwardingModule (StringRef moduleName,
335
+ StringRef interfacePath,
336
+ ArrayRef<std::string> candidates,
337
+ StringRef outPath) override ;
338
+ bool isCached (StringRef DepPath);
339
+ };
340
+
312
341
// / A ModuleLoader that runs a subordinate \c CompilerInvocation and
313
342
// / \c CompilerInstance to convert .swiftinterface files to .swiftmodule
314
343
// / files on the fly, caching the resulting .swiftmodules in the module cache
315
344
// / directory, and loading the serialized .swiftmodules from there.
316
345
class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
317
346
friend class unittest ::ModuleInterfaceLoaderTest;
318
347
explicit ModuleInterfaceLoader (
319
- ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir ,
348
+ ASTContext &ctx, ModuleInterfaceCheckerImpl &InterfaceChecker ,
320
349
DependencyTracker *tracker, ModuleLoadingMode loadMode,
321
350
ArrayRef<std::string> PreferInterfaceForModules,
322
- bool IgnoreSwiftSourceInfoFile, ModuleInterfaceLoaderOptions Opts)
323
- : SerializedModuleLoaderBase(ctx, tracker, loadMode,
324
- IgnoreSwiftSourceInfoFile),
325
- CacheDir(cacheDir), PrebuiltCacheDir(prebuiltCacheDir),
326
- PreferInterfaceForModules(PreferInterfaceForModules),
327
- Opts(Opts) {}
351
+ bool IgnoreSwiftSourceInfoFile)
352
+ : SerializedModuleLoaderBase(ctx, tracker, loadMode, IgnoreSwiftSourceInfoFile),
353
+ InterfaceChecker(InterfaceChecker),
354
+ PreferInterfaceForModules(PreferInterfaceForModules){}
328
355
329
- std::string CacheDir;
330
- std::string PrebuiltCacheDir;
356
+ ModuleInterfaceCheckerImpl &InterfaceChecker;
331
357
ArrayRef<std::string> PreferInterfaceForModules;
332
- ModuleInterfaceLoaderOptions Opts;
333
358
334
359
std::error_code findModuleFilesInDirectory (
335
360
ImportPath::Element ModuleID,
@@ -343,17 +368,14 @@ class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
343
368
bool isCached (StringRef DepPath) override ;
344
369
public:
345
370
static std::unique_ptr<ModuleInterfaceLoader>
346
- create (ASTContext &ctx, StringRef cacheDir, StringRef prebuiltCacheDir ,
371
+ create (ASTContext &ctx, ModuleInterfaceCheckerImpl &InterfaceChecker ,
347
372
DependencyTracker *tracker, ModuleLoadingMode loadMode,
348
373
ArrayRef<std::string> PreferInterfaceForModules = {},
349
- ModuleInterfaceLoaderOptions Opts = ModuleInterfaceLoaderOptions(),
350
374
bool IgnoreSwiftSourceInfoFile = false ) {
351
375
return std::unique_ptr<ModuleInterfaceLoader>(
352
- new ModuleInterfaceLoader (ctx, cacheDir, prebuiltCacheDir,
353
- tracker, loadMode,
354
- PreferInterfaceForModules,
355
- IgnoreSwiftSourceInfoFile,
356
- Opts));
376
+ new ModuleInterfaceLoader (ctx, InterfaceChecker, tracker, loadMode,
377
+ PreferInterfaceForModules,
378
+ IgnoreSwiftSourceInfoFile));
357
379
}
358
380
359
381
// / Append visible module names to \p names. Note that names are possibly
@@ -373,18 +395,6 @@ class ModuleInterfaceLoader : public SerializedModuleLoaderBase {
373
395
StringRef ModuleName, StringRef InPath, StringRef OutPath,
374
396
bool SerializeDependencyHashes, bool TrackSystemDependencies,
375
397
ModuleInterfaceLoaderOptions Opts);
376
-
377
- std::vector<std::string>
378
- getCompiledModuleCandidatesForInterface (StringRef moduleName,
379
- StringRef interfacePath) override ;
380
-
381
- // / Given a list of potential ready-to-use compiled modules for \p interfacePath,
382
- // / check if any one of them is up-to-date. If so, emit a forwarding module
383
- // / to the candidate binary module to \p outPath.
384
- bool tryEmitForwardingModule (StringRef moduleName,
385
- StringRef interfacePath,
386
- ArrayRef<std::string> candidates,
387
- StringRef outPath) override ;
388
398
};
389
399
390
400
struct InterfaceSubContextDelegateImpl : InterfaceSubContextDelegate {
0 commit comments