Add Interpreter::loadLibrary and Interpreter::loadHeader.
Refactor Interpreter::loadFile to call into these methods.
This commit is contained in:
parent
4b4fe0ec9e
commit
eb32d6eae4
@ -569,9 +569,29 @@ namespace cling {
|
||||
///
|
||||
std::string lookupFileOrLibrary(llvm::StringRef file);
|
||||
|
||||
///\brief Loads header file or shared library.
|
||||
///\brief Loads a shared library.
|
||||
///
|
||||
///\param [in] filename - The file to loaded.
|
||||
///\param [in] lookup - Whether to try to resolve the filepath
|
||||
///
|
||||
///\returns kMoreInputExpected is returned when file could not be found
|
||||
/// otherwise kSuccess or kFailure
|
||||
///
|
||||
CompilationResult loadLibrary(const std::string& filename,
|
||||
bool lookup = true);
|
||||
|
||||
///\brief Loads header file
|
||||
///
|
||||
///\param [in] filename - The file to loaded.
|
||||
///\param [out] T - Transaction containing the loaded file.
|
||||
///\returns result of the compilation.
|
||||
///
|
||||
CompilationResult loadHeader(const std::string& filename,
|
||||
Transaction** T = 0);
|
||||
|
||||
///\brief Loads header file or shared library.
|
||||
///
|
||||
///\param [in] filename - The file to be loaded.
|
||||
///\param [in] allowSharedLib - Whether to try to load the file as shared
|
||||
/// library.
|
||||
///\param [out] T - Transaction containing the loaded file.
|
||||
|
@ -1159,13 +1159,15 @@ namespace cling {
|
||||
}
|
||||
|
||||
Interpreter::CompilationResult
|
||||
Interpreter::loadFile(const std::string& filename,
|
||||
bool allowSharedLib /*=true*/,
|
||||
Transaction** T /*= 0*/) {
|
||||
Interpreter::loadLibrary(const std::string& filename, bool lookup) {
|
||||
DynamicLibraryManager* DLM = getDynamicLibraryManager();
|
||||
std::string canonicalLib = DLM->lookupLibrary(filename);
|
||||
if (allowSharedLib && !canonicalLib.empty()) {
|
||||
switch (DLM->loadLibrary(canonicalLib, /*permanent*/false, /*resolved*/true)) {
|
||||
std::string canonicalLib;
|
||||
if (lookup)
|
||||
canonicalLib = DLM->lookupLibrary(filename);
|
||||
|
||||
const std::string &library = lookup ? canonicalLib : filename;
|
||||
if (!library.empty()) {
|
||||
switch (DLM->loadLibrary(library, /*permanent*/false, /*resolved*/true)) {
|
||||
case DynamicLibraryManager::kLoadLibSuccess: // Intentional fall through
|
||||
case DynamicLibraryManager::kLoadLibAlreadyLoaded:
|
||||
return kSuccess;
|
||||
@ -1177,7 +1179,12 @@ namespace cling {
|
||||
return kFailure;
|
||||
}
|
||||
}
|
||||
return kMoreInputExpected;
|
||||
}
|
||||
|
||||
Interpreter::CompilationResult
|
||||
Interpreter::loadHeader(const std::string& filename,
|
||||
Transaction** T /*= 0*/) {
|
||||
std::string code;
|
||||
code += "#include \"" + filename + "\"";
|
||||
|
||||
@ -1267,6 +1274,18 @@ namespace cling {
|
||||
}
|
||||
}
|
||||
|
||||
Interpreter::CompilationResult
|
||||
Interpreter::loadFile(const std::string& filename,
|
||||
bool allowSharedLib /*=true*/,
|
||||
Transaction** T /*= 0*/) {
|
||||
if (allowSharedLib) {
|
||||
CompilationResult result = loadLibrary(filename, true);
|
||||
if (result!=kMoreInputExpected)
|
||||
return result;
|
||||
}
|
||||
return loadHeader(filename, T);
|
||||
}
|
||||
|
||||
static void runAndRemoveStaticDestructorsImpl(IncrementalExecutor &executor,
|
||||
std::vector<const Transaction*> &transactions,
|
||||
unsigned int begin, unsigned int end) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user