mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This replaces the obscure, inefficient lookup into extensions with something more straightforward: walk all of the known extensions (available as a simple list), then eliminate any declarations that have been shadowed by other declarations. The shadowing rules still need to consider the module re-export DAG, but we'll leave that for later. As part of this, keep track of the last time we loaded extensions for a given nominal type. If the list of extensions is out-of-date with respect to the global generation count (which tracks resolved module imports), ask the modules to load any additional extensions. Only the Clang module importer can currently load extensions in this manner. Swift SVN r5223
68 lines
2.3 KiB
C++
68 lines
2.3 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"
|
|
|
|
namespace swift {
|
|
|
|
class ASTContext;
|
|
class Module;
|
|
|
|
/// \brief Imports serialized Swift modules into an ASTContext.
|
|
class SerializedModuleLoader : public ModuleLoader {
|
|
private:
|
|
ASTContext &Ctx;
|
|
|
|
explicit SerializedModuleLoader(ASTContext &ctx) : Ctx(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(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) override;
|
|
|
|
/// \brief Load extensions to the given nominal type.
|
|
///
|
|
/// \param nominal The nominal type whose extensions should be loaded.
|
|
///
|
|
/// \param previousGeneration The previous generation number. The AST already
|
|
/// contains extensions loaded from any generation up to and including this
|
|
/// one.
|
|
virtual void loadExtensions(NominalTypeDecl *nominal,
|
|
unsigned previousGeneration) override;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|