2012-09-05 13:37:39 +04:00
//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author: Vassil Vassilev <vvasilev@cern.ch>
2014-01-07 14:08:37 +04:00
//
// 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.
2012-09-05 13:37:39 +04:00
//------------------------------------------------------------------------------
2014-03-27 20:30:09 +04:00
# ifndef CLING_TRANSACTION_UNLOADER
# define CLING_TRANSACTION_UNLOADER
2012-09-05 13:37:39 +04:00
2013-10-21 23:35:33 +04:00
namespace llvm {
class ExecutionEngine ;
}
2012-09-05 13:37:39 +04:00
namespace clang {
2014-03-07 18:07:02 +04:00
class CodeGenerator ;
2014-03-28 17:53:34 +04:00
class CompilerInstance ;
2014-02-27 13:47:36 +04:00
class Decl ;
2012-09-05 13:37:39 +04:00
class Sema ;
}
namespace cling {
class Transaction ;
///\brief A simple eraser class that removes already created AST Nodes.
///
2014-03-27 20:30:09 +04:00
class TransactionUnloader {
2012-09-05 13:37:39 +04:00
private :
clang : : Sema * m_Sema ;
2014-03-07 18:07:02 +04:00
clang : : CodeGenerator * m_CodeGen ;
2013-10-21 23:35:33 +04:00
llvm : : ExecutionEngine * m_EEngine ;
2012-09-05 13:37:39 +04:00
public :
2014-03-27 20:30:09 +04:00
TransactionUnloader ( clang : : Sema * S , clang : : CodeGenerator * CG ,
llvm : : ExecutionEngine * EE ) ;
~ TransactionUnloader ( ) ;
2012-09-05 13:37:39 +04:00
///\brief Rolls back given transaction from the AST.
///
/// Removing includes reseting various internal stuctures in the compiler to
2014-02-27 13:47:36 +04:00
/// their previous states. For example it resets the lookup tables if the
2014-03-27 20:22:30 +04:00
/// declaration has name and can be looked up; Unloads the redeclaration
2012-09-05 13:37:39 +04:00
/// chain if the declaration was redeclarable and so on.
/// Note1: that the code generated for the declaration is not removed yet.
/// Note2: does not do dependency analysis.
///
///\param[in] T - The transaction to be removed.
///\returns true on success.
///
2013-10-30 00:17:39 +04:00
bool RevertTransaction ( Transaction * T ) ;
2014-02-27 13:47:36 +04:00
2014-03-27 20:22:30 +04:00
///\brief Unloads a single decl. It must not be in any other transaction.
2014-02-27 13:47:36 +04:00
/// This doesn't do dependency tracking. Use with caution.
///
///\param[in] D - The decl to be removed.
///
///\returns true on success
///
2014-03-27 20:22:30 +04:00
bool UnloadDecl ( clang : : Decl * D ) ;
2012-09-05 13:37:39 +04:00
} ;
} // end namespace cling
# endif // CLING_AST_NODE_ERASER