Spicy
global-optimizer.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <bitset>
6 #include <map>
7 #include <memory>
8 #include <tuple>
9 #include <utility>
10 #include <vector>
11 
12 #include <hilti/ast/id.h>
13 #include <hilti/compiler/unit.h>
14 
15 namespace hilti {
16 
18 public:
19  using ModuleID = ID;
20  using StructID = ID;
21  using FieldID = ID;
22 
23  struct Uses {
24  bool hook = false;
25  bool declared = false;
26  bool defined = false;
27  bool referenced = false;
28  };
29 
30  using Functions = std::map<std::tuple<ModuleID, StructID, FieldID>, Uses>;
31 
32  GlobalOptimizer(std::vector<Unit>* units, const std::shared_ptr<Context> ctx)
33  : _units(units), _ctx(std::move(ctx)) {}
34  ~GlobalOptimizer() { _units = nullptr; }
35 
36  void run();
37 
38 private:
39  std::vector<Unit>* _units = nullptr;
40  std::shared_ptr<Context> _ctx;
41  // Storage for field declaration and their uses.
42  Functions _hooks;
43 };
44 
45 } // namespace hilti
Definition: global-optimizer.h:17
Definition: global-optimizer.h:23
Definition: id.h:18