summaryrefslogtreecommitdiff
path: root/include/mcld/LD/SymbolTableFactory.h
blob: 6196603f7821c9a430878fa1f1414eeca8935d1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//===- SymbolTableFactory.h -----------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef MCLD_SYMBOL_TABLE_FACTORY_H
#define MCLD_SYMBOL_TABLE_FACTORY_H
#ifdef ENABLE_UNITTEST
#include <gtest.h>
#endif
#include "mcld/LD/InputSymbolTable.h"
#include "mcld/LD/OutputSymbolTable.h"

namespace mcld
{

class StringTable;
class StrSymPool;

/** \class SymbolTableFactory
 *  \brief SymbolTableFactory manages SymbolTableIFs.
 *
 *  SymbolTableFactory is responsed for construction and destruction of
 *  SymbolTableIF. Since different MCLDFiles have different type of
 *  SymbolTableIF, SymbolTableFactory separates the construction of
 *  SymbolTableIF into createInputTable() and createOutputTable().
 *
 *  @see SymbolTableIF InputSymbolTable OutputSymbolTable
 */
class SymbolTableFactory
{
public:
  /// SymbolTableFactory - constructor
  //  @param pNumOfSymbolTables is the most appropriate number of created
  //  symbol tables.
  //  @param pStorage the real storage of created symbols
  explicit SymbolTableFactory(size_t pNumOfSymbolTables,
                              StrSymPool& pStrSymPool);
  /// ~SymbolTableFactory - destructor
  //  destructor destroys all created symbol tables.
  ~SymbolTableFactory();

  /// createInputTable - create a symbol table for an input file
  //  @param pEntireStringTable the string table of created Symbols.
  //  @param pDynamicStringTable the string table of created Dynamic Symbols.
  //  @param pReserve Created symbol table must reserve pReserve number of
  //  storages of symbol for creating symbols.
  SymbolTableIF *createInputTable(StringTable &pEntireStringTable,
                                  StringTable &pDynamicStringTable,
                                  size_t pReserve=256);

  /// createOutputTable - create a symbol table for an output file
  //  @param pEntireStringTable the string table of created Symbols.
  //  @param pDynamicStringTable the string table of created Dynamic Symbols.
  //  @param pReserve Created symbol table must reserve pReserve number of
  //  storages of symbol for creating symbols.
  SymbolTableIF *createOutputTable(StringTable &pEntireStringTable,
                                   StringTable &pDynamicStringTable,
                                   size_t pReserve=256);
private:
  StrSymPool &m_StrSymPool;
  GCFactory<InputSymbolTable, 0> m_InputFactory;
  GCFactory<OutputSymbolTable, 0> m_OutputFactory;

};

} // namespace of mcld

#endif