Home | History | Annotate | Download | only in MC
      1 //===- MCLDInput.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/MCLDInput.h>
     10 #include <mcld/MC/Attribute.h>
     11 #include <mcld/LD/LDContext.h>
     12 #include <mcld/Support/MemoryArea.h>
     13 
     14 using namespace mcld;
     15 
     16 //===----------------------------------------------------------------------===//
     17 // mcld::Input
     18 //===----------------------------------------------------------------------===//
     19 Input::Input(llvm::StringRef pName)
     20   : m_Type(Unknown),
     21     m_Name(pName.data()),
     22     m_Path(),
     23     m_pAttr(NULL),
     24     m_bNeeded(false),
     25     m_fileOffset(0),
     26     m_pMemArea(NULL),
     27     m_pContext(NULL) {
     28 }
     29 
     30 Input::Input(llvm::StringRef pName, const AttributeProxy& pProxy)
     31   : m_Type(Unknown),
     32     m_Name(pName.data()),
     33     m_Path(),
     34     m_pAttr(const_cast<Attribute*>(pProxy.attr())),
     35     m_bNeeded(false),
     36     m_fileOffset(0),
     37     m_pMemArea(NULL),
     38     m_pContext(NULL) {
     39 }
     40 
     41 Input::Input(llvm::StringRef pName,
     42         const sys::fs::Path& pPath,
     43         unsigned int pType,
     44         off_t pFileOffset)
     45   : m_Type(pType),
     46     m_Name(pName.data()),
     47     m_Path(pPath),
     48     m_pAttr(NULL),
     49     m_bNeeded(false),
     50     m_fileOffset(pFileOffset),
     51     m_pMemArea(NULL),
     52     m_pContext(NULL) {
     53 }
     54 
     55 Input::Input(llvm::StringRef pName,
     56         const sys::fs::Path& pPath,
     57         const AttributeProxy& pProxy,
     58         unsigned int pType,
     59         off_t pFileOffset)
     60   : m_Type(pType),
     61     m_Name(pName.data()),
     62     m_Path(pPath),
     63     m_pAttr(const_cast<Attribute*>(pProxy.attr())),
     64     m_bNeeded(false),
     65     m_fileOffset(pFileOffset),
     66     m_pMemArea(NULL),
     67     m_pContext(NULL) {
     68 }
     69 
     70 Input::~Input()
     71 {
     72   // Attribute is deleted by AttributeFactory
     73   // MemoryArea is deleted by MemoryAreaFactory
     74   if (NULL != m_pMemArea)
     75     m_pMemArea->clear();
     76 }
     77 
     78