Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 1 | //===- SectionData.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 | #ifndef MCLD_LD_SECTION_DATA_H |
| 10 | #define MCLD_LD_SECTION_DATA_H |
| 11 | #ifdef ENABLE_UNITTEST |
| 12 | #include <gtest.h> |
| 13 | #endif |
| 14 | |
| 15 | #include <llvm/ADT/ilist.h> |
| 16 | #include <llvm/ADT/ilist_node.h> |
| 17 | #include <llvm/Support/DataTypes.h> |
| 18 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 19 | #include <mcld/Config/Config.h> |
| 20 | #include <mcld/Support/Allocators.h> |
| 21 | #include <mcld/Fragment/Fragment.h> |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 22 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 23 | namespace mcld { |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 24 | |
| 25 | class LDSection; |
| 26 | |
| 27 | /** \class SectionData |
| 28 | * \brief SectionData provides a container for all Fragments. |
| 29 | */ |
| 30 | class SectionData |
| 31 | { |
| 32 | private: |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 33 | friend class Chunk<SectionData, MCLD_SECTIONS_PER_INPUT>; |
| 34 | |
| 35 | SectionData(); |
| 36 | explicit SectionData(LDSection &pSection); |
| 37 | |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 38 | SectionData(const SectionData &); // DO NOT IMPLEMENT |
| 39 | SectionData& operator=(const SectionData &); // DO NOT IMPLEMENT |
| 40 | |
| 41 | public: |
| 42 | typedef llvm::iplist<Fragment> FragmentListType; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 43 | |
| 44 | typedef FragmentListType::reference reference; |
| 45 | typedef FragmentListType::const_reference const_reference; |
| 46 | |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 47 | typedef FragmentListType::iterator iterator; |
| 48 | typedef FragmentListType::const_iterator const_iterator; |
| 49 | |
| 50 | typedef FragmentListType::reverse_iterator reverse_iterator; |
| 51 | typedef FragmentListType::const_reverse_iterator const_reverse_iterator; |
| 52 | |
| 53 | public: |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 54 | static SectionData* Create(LDSection& pSection); |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 55 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 56 | static void Destroy(SectionData*& pSection); |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 57 | |
Shih-wei Liao | d0fbbb2 | 2013-01-03 06:23:31 -0800 | [diff] [blame^] | 58 | static void Clear(); |
| 59 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 60 | const LDSection& getSection() const { return *m_pSection; } |
| 61 | LDSection& getSection() { return *m_pSection; } |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 62 | |
| 63 | FragmentListType &getFragmentList() { return m_Fragments; } |
| 64 | const FragmentListType &getFragmentList() const { return m_Fragments; } |
| 65 | |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 66 | size_t size() const { return m_Fragments.size(); } |
| 67 | |
| 68 | bool empty() const { return m_Fragments.empty(); } |
| 69 | |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 70 | reference front () { return m_Fragments.front(); } |
| 71 | const_reference front () const { return m_Fragments.front(); } |
| 72 | reference back () { return m_Fragments.back(); } |
| 73 | const_reference back () const { return m_Fragments.back(); } |
| 74 | |
| 75 | const_iterator begin () const { return m_Fragments.begin(); } |
| 76 | iterator begin () { return m_Fragments.begin(); } |
| 77 | const_iterator end () const { return m_Fragments.end(); } |
| 78 | iterator end () { return m_Fragments.end(); } |
| 79 | const_reverse_iterator rbegin() const { return m_Fragments.rbegin(); } |
| 80 | reverse_iterator rbegin() { return m_Fragments.rbegin(); } |
| 81 | const_reverse_iterator rend () const { return m_Fragments.rend(); } |
| 82 | reverse_iterator rend () { return m_Fragments.rend(); } |
| 83 | |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 84 | private: |
| 85 | FragmentListType m_Fragments; |
Shih-wei Liao | 22add6f | 2012-12-15 17:21:00 -0800 | [diff] [blame] | 86 | LDSection* m_pSection; |
Shih-wei Liao | cedee4b | 2012-08-02 23:13:03 -0700 | [diff] [blame] | 87 | |
| 88 | }; |
| 89 | |
| 90 | } // namespace of mcld |
| 91 | |
| 92 | #endif |
| 93 | |