3#include <absl/container/fixed_array.h>
13 if (
auto i = old2new_.find(old_def); i != old2new_.end())
return i->second;
20 if (
auto extract = old_def->isa<
Extract>()) {
22 if (
auto tuple = extract->tuple()->isa<
Tuple>())
return rewrite(tuple->op(*index));
28 auto new_type = old_def->isa<
Type>() ?
nullptr :
rewrite(old_def->
type());
30 auto new_ops = absl::FixedArray<const Def*>(size);
31 for (
size_t i = 0; i != size; ++i) new_ops[i] =
rewrite(old_def->
op(i));
37 auto new_mut = old_mut->
stub(
world(), new_type);
38 map(old_mut, new_mut);
41 for (
size_t i = 0, e = old_mut->
num_ops(); i != e; ++i) new_mut->set(i,
rewrite(old_mut->
op(i)));
42 if (
auto new_imm = new_mut->immutabilize())
return map(old_mut, new_imm);
bool is_set() const
Yields true if empty or the last op is set.
T * isa_mut() const
If this is *mut*able, it will cast constness away and perform a dynamic_cast to T.
const Def * op(size_t i) const noexcept
const Def * type() const noexcept
Yields the "raw" type of this Def (maybe nullptr).
const Def * rebuild(World &w, const Def *type, Defs ops) const
Def::rebuilds this Def while using new_op as substitute for its i'th Def::op.
bool is_closed() const
Has no free_vars()?
Def * stub(World &w, const Def *type)
constexpr size_t num_ops() const noexcept
static std::optional< T > isa(const Def *def)
A (possibly paramterized) Tuple.
const Def * shape() const
virtual const Def * rewrite_mut(Def *)
const Def * map(const Def *old_def, const Def *new_def)
Map old_def to new_def and returns new_def;.
virtual const Def * rewrite_imm(const Def *)
virtual const Def * rewrite(const Def *)
Data constructor for a Sigma.