MimIR 0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
prefix_cleanup.cpp
Go to the documentation of this file.
2
3#include <mim/lam.h>
4
5namespace mim {
6
7void PrefixCleanup::apply(std::string prefix) {
8 prefix_ = prefix;
9 name_ += " \"" + prefix_ + " \"";
10}
11
13 auto new_mut = rewrite(old_mut)->as_mut();
14 if (old_mut->is_external()) {
15 if (old_mut->sym().view().starts_with(prefix_))
16 DLOG("internalized: `{}`", old_mut);
17 else
18 new_mut->make_external();
19 }
20}
21
22} // namespace mim
Base class for all Defs.
Definition def.h:251
T * as_mut() const
Asserts that this is a mutable, casts constness away and performs a static_cast to T.
Definition def.h:494
bool is_external() const noexcept
Definition def.h:467
Sym sym() const
Definition def.h:507
void rewrite_external(Def *) final
void apply(std::string)
virtual const Def * rewrite(const Def *)
Definition rewrite.cpp:27
std::string name_
Definition pass.h:76
#define DLOG(...)
Vaporizes to nothingness in Debug build.
Definition log.h:95
Definition ast.h:14