StringList.cpp revision 37b74a387bb3993387029859c2d9d051c41c724e
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
17namespace mcld {
18
19typedef GCFactory<StringList, MCLD_SYMBOLS_PER_INPUT> StringListFactory;
20static llvm::ManagedStatic<StringListFactory> g_StringListFactory;
21
22//===----------------------------------------------------------------------===//
23// StringList
24//===----------------------------------------------------------------------===//
25StringList::StringList() {
26}
27
28StringList::~StringList() {
29}
30
31void StringList::push_back(StrToken* pToken) {
32  m_Tokens.push_back(pToken);
33}
34
35void 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
41StringList* StringList::create() {
42  StringList* result = g_StringListFactory->allocate();
43  new (result) StringList();
44  return result;
45}
46
47void StringList::destroy(StringList*& pStringList) {
48  g_StringListFactory->destroy(pStringList);
49  g_StringListFactory->deallocate(pStringList);
50  pStringList = NULL;
51}
52
53void StringList::clear() {
54  g_StringListFactory->clear();
55}
56
57}  // namespace mcld
58