ModuleLoader.h revision 3d3589db579f7695667b913c5043dd264ebe546f
1//===--- ModuleLoader.h - Module Loader Interface ---------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10//  This file defines the ModuleLoader interface, which is responsible for
11//  loading named modules.
12//
13//===----------------------------------------------------------------------===//
14#ifndef LLVM_CLANG_LEX_MODULE_LOADER_H
15#define LLVM_CLANG_LEX_MODULE_LOADER_H
16
17#include "clang/Basic/SourceLocation.h"
18#include "llvm/ADT/ArrayRef.h"
19
20namespace clang {
21
22class IdentifierInfo;
23
24/// \brief An opaque key that is used to describe the module and can be
25/// interpreted by the module loader itself.
26typedef void *ModuleKey;
27
28/// \brief A sequence of identifier/location pairs used to describe a particular
29/// module or submodule, e.g., std.vector.
30typedef llvm::ArrayRef<std::pair<IdentifierInfo*, SourceLocation> > ModuleIdPath;
31
32/// \brief Abstract interface for a module loader.
33///
34/// This abstract interface describes a module loader, which is responsible
35/// for resolving a module name (e.g., "std") to an actual module file, and
36/// then loading that module.
37class ModuleLoader {
38public:
39  virtual ~ModuleLoader();
40
41  /// \brief Attempt to load the given module.
42  ///
43  /// This routine attempts to load the module described by the given
44  /// parameters.
45  ///
46  /// \param ImportLoc The location of the 'import' keyword.
47  /// \param Path The identifiers (and their locations) of the module
48  /// "path", e.g., "std.vector" would be split into "std" and "vector".
49  ///
50  /// \returns If successful, a non-NULL module key describing this module.
51  /// Otherwise, returns NULL to indicate that the module could not be
52  /// loaded.
53  virtual ModuleKey loadModule(SourceLocation ImportLoc, ModuleIdPath Path) = 0;
54};
55
56}
57
58#endif
59