SectionsCmd.h revision 37b74a387bb3993387029859c2d9d051c41c724e
187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//===- SectionsCmd.h ------------------------------------------------------===//
287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//                     The MCLinker Project
487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines// This file is distributed under the University of Illinois Open Source
687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines// License. See LICENSE.TXT for details.
787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//===----------------------------------------------------------------------===//
937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#ifndef MCLD_SCRIPT_SECTIONSCMD_H_
1037b74a387bb3993387029859c2d9d051c41c724eStephen Hines#define MCLD_SCRIPT_SECTIONSCMD_H_
1137b74a387bb3993387029859c2d9d051c41c724eStephen Hines
1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Script/ScriptCommand.h"
1387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
1487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <llvm/Support/DataTypes.h>
1537b74a387bb3993387029859c2d9d051c41c724eStephen Hines
1687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <vector>
1787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
1837b74a387bb3993387029859c2d9d051c41c724eStephen Hinesnamespace mcld {
1987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
2087f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass Module;
2187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
2287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines/** \class SectionsCmd
2387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines *  \brief This class defines the interfaces to SECTIONS command.
2487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines */
2587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
2637b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass SectionsCmd : public ScriptCommand {
2737b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
2887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef std::vector<ScriptCommand*> SectionCommands;
2987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef SectionCommands::const_iterator const_iterator;
3087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef SectionCommands::iterator iterator;
3187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef SectionCommands::const_reference const_reference;
3287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef SectionCommands::reference reference;
3387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
3437b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
3587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  SectionsCmd();
3687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  ~SectionsCmd();
3787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
3837b74a387bb3993387029859c2d9d051c41c724eStephen Hines  const_iterator begin() const { return m_SectionCommands.begin(); }
3937b74a387bb3993387029859c2d9d051c41c724eStephen Hines  iterator begin() { return m_SectionCommands.begin(); }
4037b74a387bb3993387029859c2d9d051c41c724eStephen Hines  const_iterator end() const { return m_SectionCommands.end(); }
4137b74a387bb3993387029859c2d9d051c41c724eStephen Hines  iterator end() { return m_SectionCommands.end(); }
4287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
4387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  const_reference front() const { return m_SectionCommands.front(); }
4437b74a387bb3993387029859c2d9d051c41c724eStephen Hines  reference front() { return m_SectionCommands.front(); }
4537b74a387bb3993387029859c2d9d051c41c724eStephen Hines  const_reference back() const { return m_SectionCommands.back(); }
4637b74a387bb3993387029859c2d9d051c41c724eStephen Hines  reference back() { return m_SectionCommands.back(); }
4787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
4887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  size_t size() const { return m_SectionCommands.size(); }
4987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  bool empty() const { return m_SectionCommands.empty(); }
5187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  void dump() const;
5387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5437b74a387bb3993387029859c2d9d051c41c724eStephen Hines  static bool classof(const ScriptCommand* pCmd) {
5587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines    return pCmd->getKind() == ScriptCommand::SECTIONS;
5687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  }
5787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  void activate(Module& pModule);
5987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  void push_back(ScriptCommand* pCommand);
6187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6237b74a387bb3993387029859c2d9d051c41c724eStephen Hines private:
6387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  SectionCommands m_SectionCommands;
6487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines};
6587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6637b74a387bb3993387029859c2d9d051c41c724eStephen Hines}  // namespace mcld
6787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6837b74a387bb3993387029859c2d9d051c41c724eStephen Hines#endif  // MCLD_SCRIPT_SECTIONSCMD_H_
69