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