StrToken.cpp revision f33f6de54db174aa679a4b6d1e040d37e95541c0
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 13using namespace mcld; 14 15typedef GCFactory<StrToken, MCLD_SYMBOLS_PER_INPUT> StrTokenFactory; 16static llvm::ManagedStatic<StrTokenFactory> g_StrTokenFactory; 17 18//===----------------------------------------------------------------------===// 19// StrToken 20//===----------------------------------------------------------------------===// 21StrToken::StrToken() 22 : m_Kind(Unknown) 23{ 24} 25 26StrToken::StrToken(Kind pKind, const std::string& pString) 27 : m_Kind(pKind), m_Name(pString) 28{ 29} 30 31StrToken::~StrToken() 32{ 33} 34 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 42void StrToken::destroy(StrToken*& pStrToken) 43{ 44 g_StrTokenFactory->destroy(pStrToken); 45 g_StrTokenFactory->deallocate(pStrToken); 46 pStrToken = NULL; 47} 48 49void StrToken::clear() 50{ 51 g_StrTokenFactory->clear(); 52} 53