• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ContextFactory.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/MC/ContextFactory.h"
10 
11 #include "mcld/LD/LDContext.h"
12 
13 namespace mcld {
14 
15 //===---------------------------------------------------------------------===//
16 // LDContextFactory
ContextFactory(size_t pNum)17 ContextFactory::ContextFactory(size_t pNum)
18     : UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>(pNum) {
19 }
20 
~ContextFactory()21 ContextFactory::~ContextFactory() {
22 }
23 
produce(const sys::fs::Path & pPath)24 LDContext* ContextFactory::produce(const sys::fs::Path& pPath) {
25   LDContext* result = find(pPath);
26   if (result == NULL) {
27     result = UniqueGCFactoryBase<sys::fs::Path, LDContext, 0>::allocate();
28     new (result) LDContext();
29     f_KeyMap.insert(std::make_pair(pPath, result));
30   }
31   return result;
32 }
33 
produce(const char * pPath)34 LDContext* ContextFactory::produce(const char* pPath) {
35   return produce(sys::fs::Path(pPath));
36 }
37 
produce()38 LDContext* ContextFactory::produce() {
39   LDContext* result = allocate();
40   new (result) LDContext();
41   return result;
42 }
43 
44 }  // namespace mcld
45