MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
unload.cpp
Go to the documentation of this file.
1#include "mim/phase/unload.h"
2
3#include "mim/driver.h"
4
5namespace mim {
6
7void Unload::apply(std::string plugin) {
8 plugin_str_ = std::move(plugin);
9 name_ += " \"" + plugin_str_ + "\"";
10 if (auto mangled = Annex::mangle(plugin_str_))
11 plugin_ = *mangled;
12 else
13 fe::throwf("invalid plugin name `{}`", plugin_str_);
14}
15
17 auto& flags2entry = world().annexes().flags2entry();
18 auto& sym2flags = world().annexes().sym2flags();
19 for (auto i = flags2entry.begin(); i != flags2entry.end();) {
20 auto [flags, entry] = *i;
21
22 if (Annex::flags2plugin(flags) == plugin_) {
23 i = flags2entry.erase(i);
24 sym2flags.erase(entry.sym);
25 } else
26 ++i;
27 }
28
29 // we could also literally unload the shared object now, but it's probably not worth the trouble
30}
31
32} // namespace mim
std::string name_
Definition phase.h:123
World & world()
Definition phase.h:77
void apply(std::string)
Definition unload.cpp:7
void start() final
Actual entry.
Definition unload.cpp:16
auto & flags2entry()
An annex's flags map to its full name and its Def.
Definition world.h:222
auto & sym2flags()
Definition world.h:228
Annexes & annexes()
Definition world.h:281
Definition ast.h:16
static std::optional< plugin_t > mangle(std::string_view plugin)
Mangles s into a dense 48-bit representation.
Definition plugin.cpp:5
static constexpr plugin_t flags2plugin(flags_t f)
Definition plugin.h:228