122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===- GroupReader.h ------------------------------------------------------===//
222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//                     The MCLinker Project
422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// This file is distributed under the University of Illinois Open Source
622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao// License. See LICENSE.TXT for details.
722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//
822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao//===----------------------------------------------------------------------===//
937b74a387bb3993387029859c2d9d051c41c724eStephen Hines#ifndef MCLD_LD_GROUPREADER_H_
1037b74a387bb3993387029859c2d9d051c41c724eStephen Hines#define MCLD_LD_GROUPREADER_H_
1122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
1237b74a387bb3993387029859c2d9d051c41c724eStephen Hines#include "mcld/Module.h"
1322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
1437b74a387bb3993387029859c2d9d051c41c724eStephen Hinesnamespace mcld {
1522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass Archive;
1622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass ArchiveReader;
1737b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass BinaryReader;
1822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass DynObjReader;
1937b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass InputBuilder;
2022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass LinkerConfig;
2122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liaoclass ObjectReader;
2222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
2322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao/** \class GroupReader
2422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao *  \brief GroupReader handles the Group Node in InputTree
2522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao *
2622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao *  Group Node is the root of sub-tree in InputTree which includes the iputs in
2722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao *  the command line options --start-group and --end-group options
2822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao */
2937b74a387bb3993387029859c2d9d051c41c724eStephen Hinesclass GroupReader {
3037b74a387bb3993387029859c2d9d051c41c724eStephen Hines public:
3122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  GroupReader(Module& pModule,
3222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao              ObjectReader& pObjectReader,
3322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao              DynObjReader& pDynObjReader,
34f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines              ArchiveReader& pArchiveReader,
35f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines              BinaryReader& pBinaryReader);
3622add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
3722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  ~GroupReader();
3822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
3922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// readGroup - handle the input sub-tree wich its root is pRoot
4022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// @param pRoot - the root Group node of the sub-tree
4122add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  bool readGroup(Module::input_iterator pRoot,
4287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines                 Module::input_iterator pEnd,
4322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                 InputBuilder& pBuilder,
4422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao                 const LinkerConfig& pConfig);
4522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
4637b74a387bb3993387029859c2d9d051c41c724eStephen Hines private:
4722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// ArchiveListEntry - record the Archive and the corresponding input iterator
4822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  /// of the archive node
4922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  struct ArchiveListEntry {
5022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao    ArchiveListEntry(Archive& pArchive, Module::input_iterator pIterator)
5137b74a387bb3993387029859c2d9d051c41c724eStephen Hines        : archive(pArchive), input(pIterator) {}
5222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao    Archive& archive;
5322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao    Module::input_iterator input;
5422add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  };
5522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
5637b74a387bb3993387029859c2d9d051c41c724eStephen Hines private:
5722add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  Module& m_Module;
5822add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  ObjectReader& m_ObjectReader;
5922add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  DynObjReader& m_DynObjReader;
6022add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao  ArchiveReader& m_ArchiveReader;
61f7ac0f19a1c8d0ad14bcf6456ce368b830fea886Stephen Hines  BinaryReader& m_BinaryReader;
6222add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao};
6322add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6437b74a387bb3993387029859c2d9d051c41c724eStephen Hines}  // namespace mcld
6522add6ff3426df1a85089fe6a6e1597ee3b6f300Shih-wei Liao
6637b74a387bb3993387029859c2d9d051c41c724eStephen Hines#endif  // MCLD_LD_GROUPREADER_H_
67