Files
swift-mirror/include/swift/AST/ModuleLoader.h
Jordan Rose 2877bd0854 Add support for dependency file generation with -emit-dependencies.
This performs very conservative dependency generation for each compile task
within a full compilation. Any source file, swiftmodule, or Objective-C
header file that is /touched/ gets added to the dependencies list, which
is written out on a per-input basis at the end of compilation.

This does /not/ handle dependencies for the aggregated swiftmodule, swiftdoc,
generated header, or linked binary. This is just the minimum needed to get
Xcode to recognize what needs to be rebuilt when a header or Swift source
file changes. We can revisit this later.

This finishes <rdar://problem/14899639> for now.

Swift SVN r18045
2014-05-14 00:34:11 +00:00

97 lines
3.0 KiB
C++

//===--- ModuleLoader.h - Module Loader Interface ----------- -*- 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
//
//===----------------------------------------------------------------------===//
//
// This file implements an abstract interface for loading modules.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_AST_MODULE_LOADER_H
#define SWIFT_AST_MODULE_LOADER_H
#include "swift/AST/Identifier.h"
#include "swift/Basic/LLVM.h"
#include "swift/Basic/SourceLoc.h"
namespace swift {
class Module;
class NominalTypeDecl;
enum class KnownProtocolKind : uint8_t;
class DependencyTracker {
virtual void anchor();
protected:
DependencyTracker() = default;
public:
virtual ~DependencyTracker() = default;
virtual void addDependency(StringRef file) {}
};
/// \brief Abstract interface that loads named modules into the AST.
class ModuleLoader {
DependencyTracker * const dependencyTracker;
virtual void anchor();
protected:
ModuleLoader(DependencyTracker *tracker) : dependencyTracker(tracker) {}
void addDependency(StringRef file) {
if (dependencyTracker)
dependencyTracker->addDependency(file);
}
public:
virtual ~ModuleLoader() = default;
/// \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,
ArrayRef<std::pair<Identifier, SourceLoc>> path) = 0;
/// \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) { }
/// \brief Load decls that provide conformances to the given compiler-known
/// protocol.
///
/// \param kind The known protocol whose decls should be loaded.
///
/// \param previousGeneration The previous generation number. The AST already
/// contains decls conforming to this protocol loaded from any generation up
/// to and including this one.
virtual void loadDeclsConformingTo(KnownProtocolKind kind,
unsigned previousGeneration) { }
/// \brief Verify all modules loaded by this loader.
virtual void verifyAllModules() { }
};
} // namespace swift
#endif