1 //===- StringList.cpp ----------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #include "mcld/Script/StringList.h" 10 11 #include "mcld/Script/StrToken.h" 12 #include "mcld/Support/GCFactory.h" 13 #include "mcld/Support/raw_ostream.h" 14 15 #include <llvm/Support/ManagedStatic.h> 16 17 namespace mcld { 18 19 typedef GCFactory<StringList, MCLD_SYMBOLS_PER_INPUT> StringListFactory; 20 static llvm::ManagedStatic<StringListFactory> g_StringListFactory; 21 22 //===----------------------------------------------------------------------===// 23 // StringList 24 //===----------------------------------------------------------------------===// StringList()25StringList::StringList() { 26 } 27 ~StringList()28StringList::~StringList() { 29 } 30 push_back(StrToken * pToken)31void StringList::push_back(StrToken* pToken) { 32 m_Tokens.push_back(pToken); 33 } 34 dump() const35void StringList::dump() const { 36 for (const_iterator it = begin(), ie = end(); it != ie; ++it) 37 mcld::outs() << (*it)->name() << "\t"; 38 mcld::outs() << "\n"; 39 } 40 create()41StringList* StringList::create() { 42 StringList* result = g_StringListFactory->allocate(); 43 new (result) StringList(); 44 return result; 45 } 46 destroy(StringList * & pStringList)47void StringList::destroy(StringList*& pStringList) { 48 g_StringListFactory->destroy(pStringList); 49 g_StringListFactory->deallocate(pStringList); 50 pStringList = NULL; 51 } 52 clear()53void StringList::clear() { 54 g_StringListFactory->clear(); 55 } 56 57 } // namespace mcld 58