2014-08-21 12:23:43 +02:00
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Manasij Mukherjee <manasij7479@gmail.com>
// author: Vassil Vassilev <vvasilev@cern.ch>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
# ifndef CLING_MULTIPLEX_INTERPRETER_CALLBACKS_H
# define CLING_MULTIPLEX_INTERPRETER_CALLBACKS_H
# include "cling/Interpreter/InterpreterCallbacks.h"
namespace cling {
class MultiplexInterpreterCallbacks : public InterpreterCallbacks {
private :
2015-01-15 15:13:14 +01:00
std : : vector < std : : unique_ptr < InterpreterCallbacks > > m_Callbacks ;
2014-08-21 12:23:43 +02:00
public :
MultiplexInterpreterCallbacks ( Interpreter * interp )
: InterpreterCallbacks ( interp , true , true , true ) { }
2015-01-15 15:13:14 +01:00
void addCallback ( std : : unique_ptr < InterpreterCallbacks > newCb ) {
m_Callbacks . push_back ( std : : move ( newCb ) ) ;
2014-08-21 12:23:43 +02:00
}
void InclusionDirective ( clang : : SourceLocation HashLoc ,
const clang : : Token & IncludeTok ,
llvm : : StringRef FileName , bool IsAngled ,
clang : : CharSourceRange FilenameRange ,
const clang : : FileEntry * File ,
llvm : : StringRef SearchPath ,
llvm : : StringRef RelativePath ,
2014-08-21 16:00:26 +02:00
const clang : : Module * Imported ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-21 12:23:43 +02:00
cb - > InclusionDirective ( HashLoc , IncludeTok , FileName , IsAngled ,
FilenameRange , File , SearchPath , RelativePath ,
Imported ) ;
}
bool FileNotFound ( llvm : : StringRef FileName ,
2014-08-21 16:00:26 +02:00
llvm : : SmallVectorImpl < char > & RecoveryPath ) override {
2014-08-21 12:23:43 +02:00
bool result = false ;
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-21 12:23:43 +02:00
result = cb - > FileNotFound ( FileName , RecoveryPath ) | | result ;
return result ;
}
2014-11-06 10:54:01 -06:00
bool LookupObject ( clang : : LookupResult & LR , clang : : Scope * S ) override {
2014-08-21 12:23:43 +02:00
bool result = false ;
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-21 12:23:43 +02:00
result = cb - > LookupObject ( LR , S ) | | result ;
return result ;
}
2014-08-21 16:00:26 +02:00
bool LookupObject ( const clang : : DeclContext * DC ,
clang : : DeclarationName DN ) override {
2014-08-21 12:23:43 +02:00
bool result = false ;
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-21 12:23:43 +02:00
result = cb - > LookupObject ( DC , DN ) | | result ;
return result ;
}
2014-08-21 16:00:26 +02:00
bool LookupObject ( clang : : TagDecl * T ) override {
2014-08-21 12:23:43 +02:00
bool result = false ;
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-21 12:23:43 +02:00
result = cb - > LookupObject ( T ) | | result ;
return result ;
}
2014-08-21 16:00:26 +02:00
void TransactionCommitted ( const Transaction & T ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > TransactionCommitted ( T ) ;
}
}
2014-08-21 16:00:26 +02:00
void TransactionUnloaded ( const Transaction & T ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > TransactionUnloaded ( T ) ;
}
}
2015-10-21 21:55:08 -05:00
void TransactionRollback ( const Transaction & T ) override {
for ( auto & & cb : m_Callbacks ) {
cb - > TransactionRollback ( T ) ;
}
}
2014-08-21 16:00:26 +02:00
void DeclDeserialized ( const clang : : Decl * D ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > DeclDeserialized ( D ) ;
}
}
2014-08-21 16:00:26 +02:00
void TypeDeserialized ( const clang : : Type * Ty ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > TypeDeserialized ( Ty ) ;
}
}
2014-08-21 16:00:26 +02:00
void LibraryLoaded ( const void * Lib , llvm : : StringRef Name ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > LibraryLoaded ( Lib , Name ) ;
}
}
2014-08-21 16:00:26 +02:00
void LibraryUnloaded ( const void * Lib , llvm : : StringRef Name ) override {
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks ) {
2014-08-21 12:23:43 +02:00
cb - > LibraryUnloaded ( Lib , Name ) ;
}
}
2014-08-23 15:18:27 +02:00
void SetIsRuntime ( bool val ) override {
InterpreterCallbacks : : SetIsRuntime ( val ) ;
2015-01-15 15:13:14 +01:00
for ( auto & & cb : m_Callbacks )
2014-08-23 15:18:27 +02:00
cb - > SetIsRuntime ( val ) ;
}
2014-08-21 12:23:43 +02:00
} ;
} // end namespace cling
# endif // CLING_MULTIPLEX_INTERPRETER_CALLBACKS_H