From da3a51f5f8410bb1a2416fbd34ec5aaa2b89c0aa Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Fri, 19 Oct 2012 13:29:03 +0000 Subject: [PATCH] Make the transaction class single list. git-svn-id: http://root.cern.ch/svn/root/trunk@46676 27541ba8-7e3a-0410-8455-c3a389f83636 --- include/cling/Interpreter/Transaction.h | 16 ++++++++++++++-- lib/Interpreter/IncrementalParser.cpp | 1 + lib/Interpreter/IncrementalParser.h | 12 ++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/cling/Interpreter/Transaction.h b/include/cling/Interpreter/Transaction.h index 6e271338..92526fb7 100644 --- a/include/cling/Interpreter/Transaction.h +++ b/include/cling/Interpreter/Transaction.h @@ -70,15 +70,24 @@ namespace cling { /// llvm::Module* m_Module; - ///\brief The wrapper function produced by the intepreter if any, + ///\brief The wrapper function produced by the intepreter if any. /// clang::FunctionDecl* m_WrapperFD; + ///\brief Next transaction in if any. + const Transaction* m_Next; + + protected: + + ///\brief Sets the next transaction in the list. + /// + void setNext(Transaction* T) { m_Next = T; } + public: Transaction(const CompilationOptions& Opts, llvm::Module* M) : m_Completed(false), m_Parent(0), m_State(kUnknown), m_IssuedDiags(kNone), - m_Opts(Opts), m_Module(M), m_WrapperFD(0) + m_Opts(Opts), m_Module(M), m_WrapperFD(0), m_Next(0) { } ~Transaction(); @@ -223,6 +232,8 @@ namespace cling { const clang::FunctionDecl* getWrapperFD() const { return m_WrapperFD; } clang::FunctionDecl* getWrapperFD() { return m_WrapperFD; } + const Transaction* getNext() const { return m_Next; } + ///\brief Prints out all the declarations in the transaction. /// void dump() const; @@ -236,6 +247,7 @@ namespace cling { void print(llvm::raw_ostream& Out, const clang::PrintingPolicy& Policy, unsigned Indent = 0, bool PrintInstantiation = false) const; + friend class IncrementalParser; }; } // end namespace cling diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index cd26892e..e6e8e523 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -113,6 +113,7 @@ namespace cling { return; } + getLastTransaction()->setNext(NewCurT); m_Transactions.push_back(NewCurT); } diff --git a/lib/Interpreter/IncrementalParser.h b/lib/Interpreter/IncrementalParser.h index 13880fb5..2d1edae6 100644 --- a/lib/Interpreter/IncrementalParser.h +++ b/lib/Interpreter/IncrementalParser.h @@ -136,6 +136,18 @@ namespace cling { return m_Transactions.back(); } + ///\brief Returns the first transaction the incremental parser saw. + /// + Transaction* getFirstTransaction() { + return m_Transactions.front(); + } + + ///\brief Returns the first transaction the incremental parser saw. + /// + const Transaction* getFirstTransaction() const { + return m_Transactions.front(); + } + /// \} ///\brief Compiles the given input with the given compilation options.