From 943faf468312855aa787c345f5bcc059896bdd0a Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Wed, 24 Apr 2013 15:09:47 +0000 Subject: [PATCH] Reuse preparation of a transaction has to happen when its state gets changed to committed. Add some asserts. Move setting of the DeclCollector's active transaction to happen after the state gets changed to committed. git-svn-id: http://root.cern.ch/svn/root/trunk@49321 27541ba8-7e3a-0410-8455-c3a389f83636 --- lib/Interpreter/IncrementalParser.cpp | 42 +++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/lib/Interpreter/IncrementalParser.cpp b/lib/Interpreter/IncrementalParser.cpp index 62b3a24f..64c94cf6 100644 --- a/lib/Interpreter/IncrementalParser.cpp +++ b/lib/Interpreter/IncrementalParser.cpp @@ -138,10 +138,11 @@ namespace cling { Transaction* NewCurT = 0; // If we are in the middle of transaction and we see another begin // transaction - it must be nested transaction. - if (OldCurT && !OldCurT->isCompleted()) { + if (OldCurT && OldCurT->getState() <= Transaction::kCommitting) { // If the last nested was empty just reuse it. Transaction* LastNestedT = OldCurT->getLastNestedTransaction(); if (LastNestedT && LastNestedT->empty()) { + assert(LastNestedT->getState() == Transaction::kCommitted && "Broken"); NewCurT = LastNestedT; NewCurT->reset(); NewCurT->setCompilationOpts(Opts); @@ -195,13 +196,6 @@ namespace cling { assert((*I)->isCompleted() && "Nested transaction not completed!?"); } - if (CurT->isNestedTransaction()) { - // TODO: Add proper logic in the case where there are multiple nested - // transaction. This now won't handle the case where there are more than - // one level 1 nested transactions. - m_Consumer->setTransaction(CurT->getParent()); - } - return CurT; } @@ -211,19 +205,6 @@ namespace cling { assert(T->getState() != Transaction::kCommitted && "Committing an already committed transaction."); - // If the transaction is empty do nothing. - if (T->empty()) { - // except it was nested transaction and we want to reuse it later on. - if (T->isNestedTransaction()) { - // We need to remove the marker from its parent. - Transaction* ParentT = T->getParent(); - for (size_t i = 0; i < ParentT->size(); ++i) - if ((*ParentT)[i].m_DGR.isNull()) - ParentT->erase(i); - } - return; - } - // Check for errors... if (T->getIssuedDiags() == Transaction::kErrors) { rollbackTransaction(T); @@ -329,7 +310,24 @@ namespace cling { } } - T->setState(Transaction::kCommitted); + T->setState(Transaction::kCommitted); + + // If the transaction is empty do nothing. + // Except it was nested transaction and we want to reuse it later on. + if (T->empty() && T->isNestedTransaction()) { + // We need to remove the marker from its parent. + Transaction* ParentT = T->getParent(); + for (size_t i = 0; i < ParentT->size(); ++i) + if ((*ParentT)[i].m_DGR.isNull()) + ParentT->erase(i); + } + + if (T->isNestedTransaction()) { + // TODO: Add proper logic in the case where there are multiple nested + // transaction. This now won't handle the case where there are more than + // one level 1 nested transactions. + m_Consumer->setTransaction(T->getParent()); + } } void IncrementalParser::rollbackTransaction(Transaction* T) const {