1 //===- StrToken.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/StrToken.h> 10 #include <mcld/Support/GCFactory.h> 11 #include <llvm/Support/ManagedStatic.h> 12 13 using namespace mcld; 14 15 typedef GCFactory<StrToken, MCLD_SYMBOLS_PER_INPUT> StrTokenFactory; 16 static llvm::ManagedStatic<StrTokenFactory> g_StrTokenFactory; 17 18 //===----------------------------------------------------------------------===// 19 // StrToken 20 //===----------------------------------------------------------------------===// StrToken()21StrToken::StrToken() 22 : m_Kind(Unknown) 23 { 24 } 25 StrToken(Kind pKind,const std::string & pString)26StrToken::StrToken(Kind pKind, const std::string& pString) 27 : m_Kind(pKind), m_Name(pString) 28 { 29 } 30 ~StrToken()31StrToken::~StrToken() 32 { 33 } 34 create(const std::string & pString)35StrToken* StrToken::create(const std::string& pString) 36 { 37 StrToken* result = g_StrTokenFactory->allocate(); 38 new (result) StrToken(String, pString); 39 return result; 40 } 41 destroy(StrToken * & pStrToken)42void StrToken::destroy(StrToken*& pStrToken) 43 { 44 g_StrTokenFactory->destroy(pStrToken); 45 g_StrTokenFactory->deallocate(pStrToken); 46 pStrToken = NULL; 47 } 48 clear()49void StrToken::clear() 50 { 51 g_StrTokenFactory->clear(); 52 } 53