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