Do cling's best at returning the currently executing file.
#included files will not be picked up as cling cannot tell where the currently running function was defined. But it does know which file was passed to MetaProcessor::executeFunction() (e.g. via .x). So at least store that. This fixes the occurrences of GetCurrentMacroName() in tutorials/ git-svn-id: http://root.cern.ch/svn/root/trunk@47421 27541ba8-7e3a-0410-8455-c3a389f83636
This commit is contained in:
parent
177d20e14c
commit
26f3d7cf75
@ -68,7 +68,15 @@ namespace cling {
|
||||
///\brief MetaProcessor's options
|
||||
///
|
||||
MetaProcessorOpts m_Options;
|
||||
|
||||
///\brief Currently executing file as passed into executeFile
|
||||
///
|
||||
llvm::StringRef m_CurrentlyExecutingFile;
|
||||
|
||||
///\brief Outermost currently executing file as passed into executeFile
|
||||
///
|
||||
llvm::StringRef m_TopExecutingFile;
|
||||
|
||||
private:
|
||||
|
||||
///\brief Handle one of the special commands in cling.
|
||||
@ -139,6 +147,22 @@ namespace cling {
|
||||
cling::StoredValueRef* result = 0,
|
||||
Interpreter::CompilationResult* compRes = 0);
|
||||
|
||||
///\brief Get the file name that is currently executing as passed to
|
||||
/// the currently active executeFile(). The returned StringRef::data() is
|
||||
/// NULL if no file is currently processed. For recursive calls to
|
||||
/// executeFile(), getCurrentlyExecutingFile() will return the nested file
|
||||
/// whereas getTopExecutingFile() returns the outer most file.
|
||||
llvm::StringRef getCurrentlyExecutingFile() const {
|
||||
return m_CurrentlyExecutingFile;
|
||||
}
|
||||
|
||||
///\brief Get the file name that is passed to the top most currently active
|
||||
/// executeFile(). The returned StringRef::data() is NULL if no file is
|
||||
/// currently processed.
|
||||
llvm::StringRef getTopExecutingFile() const {
|
||||
return m_TopExecutingFile;
|
||||
}
|
||||
|
||||
///\brief Reads prompt input from file.
|
||||
///
|
||||
///\param [in] filename - The file to read.
|
||||
|
@ -496,10 +496,17 @@ namespace cling {
|
||||
Interpreter::CompilationResult interpRes = m_Interp.loadFile(file);
|
||||
if (interpRes == Interpreter::kSuccess) {
|
||||
std::string expression = pairFuncExt.first.str() + "(" + args.str() + ")";
|
||||
m_CurrentlyExecutingFile = file;
|
||||
bool topmost = !m_TopExecutingFile.data();
|
||||
if (topmost)
|
||||
m_TopExecutingFile = file;
|
||||
if (result)
|
||||
interpRes = m_Interp.evaluate(expression, *result);
|
||||
else
|
||||
interpRes = m_Interp.execute(expression);
|
||||
m_CurrentlyExecutingFile = llvm::StringRef();
|
||||
if (topmost)
|
||||
m_TopExecutingFile = llvm::StringRef();
|
||||
}
|
||||
if (compRes) *compRes = interpRes;
|
||||
return (interpRes != Interpreter::kFailure);
|
||||
|
Loading…
Reference in New Issue
Block a user