1 //===- Input.h ------------------------------------------------------------===// 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 // 10 // Input class inherits MCLDFile, which is used to represent a input file 11 // 12 //===----------------------------------------------------------------------===// 13 #ifndef MCLD_MC_INPUT_H 14 #define MCLD_MC_INPUT_H 15 16 #include <mcld/Support/Path.h> 17 18 namespace mcld { 19 20 class MemoryArea; 21 class AttributeProxy; 22 class Attribute; 23 class InputFactory; 24 class LDContext; 25 26 /** \class Input 27 * \brief Input provides the information of a input file. 28 */ 29 class Input 30 { 31 friend class InputFactory; 32 public: 33 enum Type { 34 Unknown, 35 Binary, 36 Object, 37 Exec, 38 DynObj, 39 CoreFile, 40 Script, 41 Archive, 42 External 43 }; 44 45 public: 46 explicit Input(llvm::StringRef pName); 47 48 Input(llvm::StringRef pName, 49 const AttributeProxy& pAttr); 50 51 Input(llvm::StringRef pName, 52 const sys::fs::Path& pPath, 53 unsigned int pType = Unknown, 54 off_t pFileOffset = 0); 55 56 Input(llvm::StringRef pName, 57 const sys::fs::Path& pPath, 58 const AttributeProxy& pAttr, 59 unsigned int pType = Unknown, 60 off_t pFileOffset = 0); 61 62 ~Input(); 63 name()64 const std::string& name() const 65 { return m_Name; } 66 setName(const std::string & pName)67 void setName(const std::string& pName) 68 { m_Name = pName; } 69 path()70 const sys::fs::Path& path() const 71 { return m_Path; } 72 setPath(const sys::fs::Path & pPath)73 void setPath(const sys::fs::Path& pPath) 74 { m_Path = pPath; } 75 setType(unsigned int pType)76 void setType(unsigned int pType) 77 { m_Type = pType; } 78 type()79 unsigned int type() const 80 { return m_Type; } 81 isRecognized()82 bool isRecognized() const 83 { return (m_Type != Unknown); } 84 hasAttribute()85 bool hasAttribute() const 86 { return (NULL != m_pAttr); } 87 attribute()88 const Attribute* attribute() const 89 { return m_pAttr; } 90 isNeeded()91 bool isNeeded() const 92 { return m_bNeeded; } 93 setNeeded()94 void setNeeded() 95 { m_bNeeded = true; } 96 noExport()97 bool noExport() const 98 { return m_bNoExport; } 99 setNoExport()100 void setNoExport() 101 { m_bNoExport = true; } 102 fileOffset()103 off_t fileOffset() const 104 { return m_fileOffset; } 105 setFileOffset(off_t pFileOffset)106 void setFileOffset(off_t pFileOffset) 107 { m_fileOffset = pFileOffset; } 108 109 // ----- memory area ----- // setMemArea(MemoryArea * pMemArea)110 void setMemArea(MemoryArea* pMemArea) 111 { m_pMemArea = pMemArea; } 112 hasMemArea()113 bool hasMemArea() const 114 { return (NULL != m_pMemArea); } 115 memArea()116 const MemoryArea* memArea() const { return m_pMemArea; } memArea()117 MemoryArea* memArea() { return m_pMemArea; } 118 119 // ----- context ----- // setContext(LDContext * pContext)120 void setContext(LDContext* pContext) 121 { m_pContext = pContext; } 122 hasContext()123 bool hasContext() const 124 { return (NULL != m_pContext); } 125 context()126 const LDContext* context() const { return m_pContext; } context()127 LDContext* context() { return m_pContext; } 128 129 private: 130 unsigned int m_Type; 131 std::string m_Name; 132 sys::fs::Path m_Path; 133 Attribute *m_pAttr; 134 bool m_bNeeded; 135 bool m_bNoExport; 136 off_t m_fileOffset; 137 MemoryArea* m_pMemArea; 138 LDContext* m_pContext; 139 }; 140 141 } // namespace of mcld 142 143 #endif 144 145