1 //===- InputFactory.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/InputFactory.h"
10 
11 #include "mcld/LinkerConfig.h"
12 #include "mcld/AttributeOption.h"
13 #include "mcld/MC/AttributeSet.h"
14 
15 namespace mcld {
16 
17 //===----------------------------------------------------------------------===//
18 // InputFactory
19 //===----------------------------------------------------------------------===//
InputFactory(size_t pNum,const LinkerConfig & pConfig)20 InputFactory::InputFactory(size_t pNum, const LinkerConfig& pConfig)
21     : GCFactory<Input, 0>(pNum) {
22   m_pAttrSet = new AttributeSet(16, pConfig.attribute().predefined());
23   m_pLast = new AttributeProxy(*m_pAttrSet,
24                                pConfig.attribute().predefined(),
25                                pConfig.attribute().constraint());
26 }
27 
~InputFactory()28 InputFactory::~InputFactory() {
29   delete m_pAttrSet;
30   delete m_pLast;
31 }
32 
produce(llvm::StringRef pName,const sys::fs::Path & pPath,unsigned int pType,off_t pFileOffset)33 Input* InputFactory::produce(llvm::StringRef pName,
34                              const sys::fs::Path& pPath,
35                              unsigned int pType,
36                              off_t pFileOffset) {
37   Input* result = Alloc::allocate();
38   new (result) Input(pName, pPath, *m_pLast, pType, pFileOffset);
39   return result;
40 }
41 
produce(llvm::StringRef pName,const char * pPath,unsigned int pType,off_t pFileOffset)42 Input* InputFactory::produce(llvm::StringRef pName,
43                              const char* pPath,
44                              unsigned int pType,
45                              off_t pFileOffset) {
46   Input* result = Alloc::allocate();
47   new (result) Input(pName, sys::fs::Path(pPath), *m_pLast, pType, pFileOffset);
48   return result;
49 }
50 
51 }  // namespace mcld
52