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