1 //===- SectionsCmd.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_SCRIPT_SECTIONSCMD_H 10 #define MCLD_SCRIPT_SECTIONSCMD_H 11 12 #include <mcld/Script/ScriptCommand.h> 13 #include <llvm/Support/DataTypes.h> 14 #include <vector> 15 16 namespace mcld 17 { 18 19 class Module; 20 21 /** \class SectionsCmd 22 * \brief This class defines the interfaces to SECTIONS command. 23 */ 24 25 class SectionsCmd : public ScriptCommand 26 { 27 public: 28 typedef std::vector<ScriptCommand*> SectionCommands; 29 typedef SectionCommands::const_iterator const_iterator; 30 typedef SectionCommands::iterator iterator; 31 typedef SectionCommands::const_reference const_reference; 32 typedef SectionCommands::reference reference; 33 34 public: 35 SectionsCmd(); 36 ~SectionsCmd(); 37 begin()38 const_iterator begin() const { return m_SectionCommands.begin(); } begin()39 iterator begin() { return m_SectionCommands.begin(); } end()40 const_iterator end() const { return m_SectionCommands.end(); } end()41 iterator end() { return m_SectionCommands.end(); } 42 front()43 const_reference front() const { return m_SectionCommands.front(); } front()44 reference front() { return m_SectionCommands.front(); } back()45 const_reference back() const { return m_SectionCommands.back(); } back()46 reference back() { return m_SectionCommands.back(); } 47 size()48 size_t size() const { return m_SectionCommands.size(); } 49 empty()50 bool empty() const { return m_SectionCommands.empty(); } 51 52 void dump() const; 53 classof(const ScriptCommand * pCmd)54 static bool classof(const ScriptCommand* pCmd) 55 { 56 return pCmd->getKind() == ScriptCommand::SECTIONS; 57 } 58 59 void activate(Module& pModule); 60 61 void push_back(ScriptCommand* pCommand); 62 63 private: 64 SectionCommands m_SectionCommands; 65 }; 66 67 } // namespace of mcld 68 69 #endif 70