1
2
3
4
5
6 #ifndef CMAJOR_SYMBOLS_FUNCTION_INDEX_INCLUDED
7 #define CMAJOR_SYMBOLS_FUNCTION_INDEX_INCLUDED
8 #include <cmajor/symbols/SymbolsApi.hpp>
9 #include <soulng/util/BinaryWriter.hpp>
10 #include <boost/uuid/uuid.hpp>
11 #include <boost/functional/hash.hpp>
12 #include <unordered_map>
13 #include <mutex>
14
15 namespace cmajor { namespace symbols {
16
17 using namespace soulng::util;
18
19 class Module;
20 class FunctionSymbol;
21
22 class FunctionIndex
23 {
24 public:
25 FunctionIndex(Module* module_);
26 void AddFunction(const boost::uuids::uuid& functionId, FunctionSymbol* functionSymbol);
27 void SetMainFunctionId(const boost::uuids::uuid& functionId);
28 const boost::uuids::uuid& GetMainFunctionId() const { return mainFunctionId; }
29 void Write(BinaryWriter& writer);
30 private:
31 Module* module;
32 std::unordered_map<boost::uuids::uuid, FunctionSymbol*, boost::boost::hash<boost::uuids::uuid>>functionMap;
33 boost::uuids::uuid mainFunctionId;
34 };
35
36 } }
37
38 #endif // CMAJOR_SYMBOLS_FUNCTION_INDEX_INCLUDED