コード例 #1
0
ファイル: Transaction.cpp プロジェクト: Dr15Jones/root
  void Transaction::print(llvm::raw_ostream& Out, const PrintingPolicy& Policy,
                          unsigned Indent, bool PrintInstantiation) const {
    int nestedT = 0;
    for (const_iterator I = decls_begin(), E = decls_end(); I != E; ++I) {
      if (I->m_DGR.isNull()) {
        assert(hasNestedTransactions() && "DGR is null even if no nesting?");
        // print the nested decl
        Out<< "\n";
        Out<<"+====================================================+\n";
        Out<<"        Nested Transaction" << nestedT << "           \n";
        Out<<"+====================================================+\n";
        (*m_NestedTransactions)[nestedT++]->print(Out, Policy, Indent, 
                                                  PrintInstantiation);
        Out<< "\n";
        Out<<"+====================================================+\n";
        Out<<"          End Transaction" << nestedT << "            \n";
        Out<<"+====================================================+\n";
      }
      I->print(Out, Policy, Indent, PrintInstantiation);
    }

    // Print the deserialized decls if any.
    for (const_iterator I = deserialized_decls_begin(), 
           E = deserialized_decls_end(); I != E; ++I) {
      
      assert(!I->m_DGR.isNull() && "Must not contain null DGR.");
      I->print(Out, Policy, Indent, PrintInstantiation, "Deserialized");
    }
  }
コード例 #2
0
ファイル: Transaction.cpp プロジェクト: Dr15Jones/root
  void Transaction::printStructure(size_t nindent) const {
    static const char* const stateNames[kNumStates] = {
      "Collecting",
      "kCompleted",
      "RolledBack",
      "RolledBackWithErrors",
      "Committed"
    };
    assert((sizeof(stateNames) / sizeof(void*)) == kNumStates 
           && "Missing a state to print.");
    std::string indent(nindent, ' ');
    llvm::errs() << indent << "Transaction @" << this << ": \n";
    for (const_nested_iterator I = nested_begin(), E = nested_end(); 
         I != E; ++I) {
      (*I)->printStructure(nindent + 3);
    }
    llvm::errs() << indent << " state: " << stateNames[getState()]
                 << " decl groups, ";
    if (hasNestedTransactions())
      llvm::errs() << m_NestedTransactions->size();
    else
      llvm::errs() << "0";

    llvm::errs() << " nested transactions\n"
                 << indent << " wrapper: " << m_WrapperFD
                 << ", parent: " << m_Parent
                 << ", next: " << m_Next << "\n";
  }
コード例 #3
0
ファイル: Transaction.cpp プロジェクト: My-Source/root
 void Transaction::print(llvm::raw_ostream& Out, const PrintingPolicy& Policy,
                         unsigned Indent, bool PrintInstantiation) const {
   int nestedT = 0;
   for (const_iterator I = decls_begin(), E = decls_end(); I != E; ++I) {
     if (I->m_DGR.isNull()) {
       assert(hasNestedTransactions() && "DGR is null even if no nesting?");
       // print the nested decl
       Out<< "\n";
       Out<<"+====================================================+\n";
       Out<<"        Nested Transaction" << nestedT << "           \n";
       Out<<"+====================================================+\n";
       (*m_NestedTransactions)[nestedT++]->print(Out, Policy, Indent, 
                                                 PrintInstantiation);
       Out<< "\n";
       Out<<"+====================================================+\n";
       Out<<"          End Transaction" << nestedT << "            \n";
       Out<<"+====================================================+\n";
     }
     for (DeclGroupRef::const_iterator J = I->m_DGR.begin(), 
            L = I->m_DGR.end(); J != L; ++J)
       if (*J)
         (*J)->print(Out, Policy, Indent, PrintInstantiation);
       else
         Out << "<<NULL DECL>>";
   }
 }
コード例 #4
0
 Transaction::~Transaction() {
   if (hasNestedTransactions())
     for (size_t i = 0; i < m_NestedTransactions->size(); ++i) {
       assert((*m_NestedTransactions)[i]->getState() == kCommitted 
              && "All nested transactions must be committed!");
       delete (*m_NestedTransactions)[i];
     }
 }
コード例 #5
0
 void Transaction::dump() const {
   int nestedT = 0;
   for (const_iterator I = decls_begin(), E = decls_end(); I != E; ++I) {
     if (I->isNull()) {
       assert(hasNestedTransactions() && "DGR is null even if no nesting?");
       // print the nested decl
       llvm::outs()<<"+====================================================+\n";
       llvm::outs()<<"|       Nested Transaction" << nestedT << "          |\n";
       llvm::outs()<<"+====================================================+\n";
       m_NestedTransactions[nestedT++]->dump();        
       llvm::outs()<<"+====================================================+\n";
       llvm::outs()<<"|         End Transaction" << nestedT << "           |\n";
       llvm::outs()<<"+====================================================+\n";
     }
     for (DeclGroupRef::const_iterator J = I->begin(), L = I->end(); J != L;++J)
       (*J)->dump();
   }
 }
コード例 #6
0
ファイル: Transaction.cpp プロジェクト: My-Source/root
  void Transaction::append(DelayCallInfo DCI) {
    if (!DCI.m_DGR.isNull() && getState() == kCommitting) {
      // We are committing and getting enw decls in.
      // Move them into a sub transaction that will be processed
      // recursively at the end of of commitTransaction.
      Transaction* subTransactionWhileCommitting = 0;
      if (hasNestedTransactions()
          && m_NestedTransactions->back()->getState() == kCollecting)
        subTransactionWhileCommitting = m_NestedTransactions->back();
      else {
        // FIXME: is this correct (Axel says "yes")
        CompilationOptions Opts(getCompilationOpts());
        Opts.DeclarationExtraction = 0;
        Opts.ValuePrinting = CompilationOptions::VPDisabled;
        Opts.ResultEvaluation = 0;
        Opts.DynamicScoping = 0;
        subTransactionWhileCommitting
          = new Transaction(Opts, getModule());
        addNestedTransaction(subTransactionWhileCommitting);
      }
      subTransactionWhileCommitting->append(DCI);
      return;
    }

    assert(DCI.m_DGR.isNull()
           || (getState() == kCollecting || getState() == kCompleted)
           || "Cannot append declarations in current state.");
    bool checkForWrapper = !m_WrapperFD;
    assert(checkForWrapper = true && "Check for wrappers with asserts");
    // register the wrapper if any.
    if (checkForWrapper && !DCI.m_DGR.isNull() && DCI.m_DGR.isSingleDecl()) {
      if (FunctionDecl* FD = dyn_cast<FunctionDecl>(DCI.m_DGR.getSingleDecl()))
        if (utils::Analyze::IsWrapper(FD)) {
          assert(!m_WrapperFD && "Two wrappers in one transaction?");
          m_WrapperFD = FD;
        }
    }

    // Lazy create the container on first append.
    if (!m_DeclQueue)
      m_DeclQueue.reset(new DeclQueue());
    m_DeclQueue->push_back(DCI);
  }
コード例 #7
0
ファイル: Transaction.cpp プロジェクト: Dr15Jones/root
 void Transaction::removeNestedTransaction(Transaction* nested) {
   assert(hasNestedTransactions() && "Does not contain nested transactions");
   int nestedPos = -1;
   for (size_t i = 0; i < m_NestedTransactions->size(); ++i)
     if ((*m_NestedTransactions)[i] == nested) {
       nestedPos = i;
       break;
     }
   assert(nestedPos > -1 && "Not found!?");
   m_NestedTransactions->erase(m_NestedTransactions->begin() + nestedPos);
   // We need to remove the marker too.
   int markerPos = -1;
   for (iterator I = decls_begin(), E = decls_end(); I != E; ++I) {
     if (I->m_DGR.isNull() && I->m_Call == kCCINone) {
       ++markerPos;
       if (nestedPos == markerPos) {
         erase(I); // Safe because of the break stmt.
         break;
       }
     }
   }
   if (!m_NestedTransactions->size())
     m_NestedTransactions.reset(0);
 }
コード例 #8
0
 void Transaction::removeNestedTransaction(Transaction* nested) {
   assert(hasNestedTransactions() && "Does not contain nested transactions");
   int nestedPos = -1;
   for (size_t i = 0; i < m_NestedTransactions->size(); ++i)
     if ((*m_NestedTransactions)[i] == nested) {
       nestedPos = i;
       break;
     }
   assert(nestedPos > -1 && "Not found!?");
   m_NestedTransactions->erase(m_NestedTransactions->begin() + nestedPos);
   // We need to remove the marker too.
   int markerPos = -1;
   for (size_t i = 0; i < size(); ++i) {
     if ((*this)[i].m_DGR.isNull() && (*this)[i].m_Call == kCCINone) {
       ++markerPos;
       if (nestedPos == markerPos) {
         erase(i);
         break;
       }
     }
   }
   if (!m_NestedTransactions->size())
     m_NestedTransactions.reset(0);
 }
コード例 #9
0
ファイル: Transaction.cpp プロジェクト: My-Source/root
 Transaction::~Transaction() {
   if (hasNestedTransactions())
     for (size_t i = 0; i < m_NestedTransactions->size(); ++i)
       delete (*m_NestedTransactions)[i];
 }