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#include <mcld/LinkerConfig.h>
11#include <mcld/MC/AttributeSet.h>
12#include <mcld/AttributeOption.h>
13
14using namespace mcld;
15
16//===----------------------------------------------------------------------===//
17// InputFactory
18//===----------------------------------------------------------------------===//
19InputFactory::InputFactory(size_t pNum, const LinkerConfig& pConfig)
20  : GCFactory<Input,0>(pNum) {
21
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
28InputFactory::~InputFactory()
29{
30  delete m_pAttrSet;
31  delete m_pLast;
32}
33
34Input* InputFactory::produce(llvm::StringRef pName,
35                             const sys::fs::Path& pPath,
36                             unsigned int pType,
37                             off_t pFileOffset)
38{
39  Input* result = Alloc::allocate();
40  new (result) Input(pName, pPath, *m_pLast, pType, pFileOffset);
41  return result;
42}
43
44