mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
...and use it for shadowed modules (e.g. the Clang module "Foundation" referenced by the Swift module "Foundation"), so that we can actually find "NSString" when building AppKit. Additionally, record shadowed modules as dependencies, so that they can be loaded when the adapter module is loaded. Swift SVN r6522
93 lines
3.1 KiB
C++
93 lines
3.1 KiB
C++
//===--- SerializedModuleLoader.h - Import Swift modules --------*- c++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_SERIALIZATION_MODULELOADER_H
|
|
#define SWIFT_SERIALIZATION_MODULELOADER_H
|
|
|
|
#include "swift/AST/ModuleLoader.h"
|
|
#include "llvm/ADT/OwningPtr.h"
|
|
|
|
namespace swift {
|
|
class ASTContext;
|
|
class Module;
|
|
class ModuleFile;
|
|
|
|
/// \brief Imports serialized Swift modules into an ASTContext.
|
|
class SerializedModuleLoader : public ModuleLoader {
|
|
private:
|
|
ASTContext &Ctx;
|
|
|
|
std::vector<llvm::OwningPtr<ModuleFile>> LoadedModuleFiles;
|
|
|
|
explicit SerializedModuleLoader(ASTContext &ctx);
|
|
|
|
public:
|
|
/// \brief Create a new importer that can load serialized Swift modules
|
|
/// into the given ASTContext.
|
|
static SerializedModuleLoader *create(ASTContext &ctx) {
|
|
return new SerializedModuleLoader(ctx);
|
|
}
|
|
|
|
~SerializedModuleLoader();
|
|
|
|
SerializedModuleLoader(const SerializedModuleLoader &) = delete;
|
|
SerializedModuleLoader(SerializedModuleLoader &&) = delete;
|
|
SerializedModuleLoader &operator=(const SerializedModuleLoader &) = delete;
|
|
SerializedModuleLoader &operator=(SerializedModuleLoader &&) = delete;
|
|
|
|
/// \brief Import a module with the given module path.
|
|
///
|
|
/// \param importLoc The location of the 'import' keyword.
|
|
///
|
|
/// \param path A sequence of (identifier, location) pairs that denote
|
|
/// the dotted module name to load, e.g., AppKit.NSWindow.
|
|
///
|
|
/// \returns the module referenced, if it could be loaded. Otherwise,
|
|
/// emits a diagnostic and returns NULL.
|
|
virtual Module *
|
|
loadModule(SourceLoc importLoc, Module::AccessPathTy path,
|
|
bool isStdlibImport) override;
|
|
|
|
/// \brief Look for declarations associated with the given name.
|
|
///
|
|
/// \param module The module to search.
|
|
///
|
|
/// \param accessPath The access path used to refer to the name within this
|
|
/// (top-level) module.
|
|
///
|
|
/// \param name The name we're searching for.
|
|
///
|
|
/// \param lookupKind Whether we're performing qualified vs. unqualified
|
|
/// lookup.
|
|
///
|
|
/// \param result Will be populated with the results of name lookup.
|
|
virtual void lookupValue(Module *module,
|
|
Module::AccessPathTy accessPath, Identifier name,
|
|
NLKind lookupKind,
|
|
SmallVectorImpl<ValueDecl*> &result) override;
|
|
|
|
/// \brief Look for a declaration of the given operator.
|
|
///
|
|
/// \returns The operator decl, or null if this module does not define the
|
|
/// operator in question.
|
|
virtual OperatorDecl *lookupOperator(Module *module, Identifier name,
|
|
DeclKind fixity) override;
|
|
|
|
virtual void
|
|
getReexportedModules(Module *module,
|
|
SmallVectorImpl<Module *> &exports) override;
|
|
};
|
|
|
|
} // end namespace swift
|
|
|
|
#endif
|