1 //===- MCLDInfo.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/MCLDInfo.h> 10 #include <mcld/Support/FileSystem.h> 11 #include <mcld/MC/InputFactory.h> 12 #include <mcld/MC/AttributeFactory.h> 13 #include <mcld/MC/ContextFactory.h> 14 #include <mcld/Config/Config.h> 15 #include <string> 16 17 using namespace mcld; 18 19 //========================== 20 // MCLDInfo 21 MCLDInfo::MCLDInfo(const std::string& pTripleString, 22 size_t pAttrNum, 23 size_t pInputNum) 24 : m_Options(), 25 m_pBitcode(0), 26 m_Triple(pTripleString), 27 m_pStrSymPool(0) 28 { 29 m_pAttrFactory = new AttributeFactory(pAttrNum); 30 m_pCntxtFactory = new ContextFactory(pInputNum); 31 m_pMemAreaFactory = new MemoryAreaFactory(pInputNum); 32 m_pInputFactory = new InputFactory(pInputNum, *m_pAttrFactory); 33 m_pInputTree = new InputTree(*m_pInputFactory); 34 m_pOutput = new mcld::Output(); 35 } 36 37 MCLDInfo::~MCLDInfo() 38 { 39 delete m_pOutput; 40 delete m_pAttrFactory; 41 delete m_pCntxtFactory; 42 delete m_pMemAreaFactory; 43 delete m_pInputFactory; 44 delete m_pInputTree; 45 } 46 47 void MCLDInfo::setBitcode(const Input& pInput) 48 { 49 m_pBitcode = const_cast<Input*>(&pInput); 50 } 51 52 Input& MCLDInfo::bitcode() 53 { 54 assert((0 != m_pBitcode) && "default bitcode is not set"); 55 return *m_pBitcode; 56 } 57 58 const Input& MCLDInfo::bitcode() const 59 { 60 assert((0 != m_pBitcode) && "default bitcode is not set"); 61 return *m_pBitcode; 62 } 63 64 const char* MCLDInfo::version() 65 { 66 return mcld::internal::version; 67 } 68