Spicy
linker.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <map>
6 #include <memory>
7 #include <optional>
8 #include <set>
9 #include <string>
10 #include <utility>
11 #include <vector>
12 
13 #include <hilti/base/result.h>
14 #include <hilti/compiler/detail/codegen/codegen.h>
15 #include <hilti/compiler/detail/cxx/unit.h>
16 
17 namespace hilti::detail::cxx {
18 
28 class Linker {
29 public:
30  Linker(CodeGen* cg) : _codegen(cg) {}
31 
32  void add(const linker::MetaData& md);
33  void finalize();
34  Result<cxx::Unit> linkerUnit(); // only after finalize and at least one module
35 
36 private:
37  CodeGen* _codegen;
38  std::optional<cxx::Unit> _linker_unit;
39 
40  std::set<std::pair<std::string, std::string>> _modules;
41  std::map<std::string, std::vector<cxx::linker::Join>> _joins;
42  std::set<cxx::declaration::Constant> _globals;
43 };
44 
45 } // namespace hilti::detail::cxx
Definition: elements.h:18
Definition: reference.h:47
Definition: linker.h:28
Definition: codegen.h:56
Definition: result.h:67