mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This functionality doesn’t really change what we accept right now, because we eagerly import all of the methods of a class when we do *any* kind of lookup into the class. However, when we manage to stop doing that, this operation will become more important. Swift SVN r23289
83 lines
2.6 KiB
C++
83 lines
2.6 KiB
C++
//===--- SourceLoader.h - Import .swift files as 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_SEMA_SOURCELOADER_H
|
|
#define SWIFT_SEMA_SOURCELOADER_H
|
|
|
|
#include "swift/AST/ModuleLoader.h"
|
|
|
|
namespace swift {
|
|
|
|
class ASTContext;
|
|
class Module;
|
|
|
|
/// \brief Imports serialized Swift modules into an ASTContext.
|
|
class SourceLoader : public ModuleLoader {
|
|
private:
|
|
ASTContext &Ctx;
|
|
bool SkipBodies;
|
|
|
|
explicit SourceLoader(ASTContext &ctx, bool skipBodies, DependencyTracker *tracker)
|
|
: ModuleLoader(tracker), Ctx(ctx), SkipBodies(skipBodies) {}
|
|
|
|
public:
|
|
static std::unique_ptr<SourceLoader>
|
|
create(ASTContext &ctx, bool skipBodies,
|
|
DependencyTracker *tracker = nullptr) {
|
|
return std::unique_ptr<SourceLoader>{
|
|
new SourceLoader(ctx, skipBodies, tracker)
|
|
};
|
|
}
|
|
|
|
SourceLoader(const SourceLoader &) = delete;
|
|
SourceLoader(SourceLoader &&) = delete;
|
|
SourceLoader &operator=(const SourceLoader &) = delete;
|
|
SourceLoader &operator=(SourceLoader &&) = 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,
|
|
/// returns NULL.
|
|
virtual Module *
|
|
loadModule(SourceLoc importLoc,
|
|
ArrayRef<std::pair<Identifier, SourceLoc>> 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;
|
|
|
|
virtual void loadObjCMethods(
|
|
ClassDecl *classDecl,
|
|
ObjCSelector selector,
|
|
bool isInstanceMethod,
|
|
unsigned previousGeneration,
|
|
llvm::TinyPtrVector<AbstractFunctionDecl *> &methods) override
|
|
{
|
|
// Parsing populates the Objective-C method tables.
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|