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 //===----------------------------------------------------------------------===// 21 StrToken::StrToken() 22 : m_Kind(Unknown) 23 { 24 } 25 26 StrToken::StrToken(Kind pKind, const std::string& pString) 27 : m_Kind(pKind), m_Name(pString) 28 { 29 } 30 31 StrToken::~StrToken() 32 { 33 } 34 35 StrToken* StrToken::create(const std::string& pString) 36 { 37 StrToken* result = g_StrTokenFactory->allocate(); 38 new (result) StrToken(String, pString); 39 return result; 40 } 41 42 void StrToken::destroy(StrToken*& pStrToken) 43 { 44 g_StrTokenFactory->destroy(pStrToken); 45 g_StrTokenFactory->deallocate(pStrToken); 46 pStrToken = NULL; 47 } 48 49 void StrToken::clear() 50 { 51 g_StrTokenFactory->clear(); 52 } 53