11 if (
auto i = old2new_.find(old_def); i != old2new_.end())
return i->second;
18 if (
auto extract = old_def->isa<
Extract>()) {
20 if (
auto tuple = extract->tuple()->isa<
Tuple>())
return rewrite(tuple->op(*index));
26 auto new_type = old_def->isa<
Type>() ?
nullptr :
rewrite(old_def->
type());
28 for (
size_t i = 0, e = new_ops.size(); i != e; ++i) new_ops[i] =
rewrite(old_def->
op(i));
34 auto new_mut = old_mut->
stub(
world(), new_type);
35 map(old_mut, new_mut);
38 for (
size_t i = 0, e = old_mut->
num_ops(); i != e; ++i) new_mut->set(i,
rewrite(old_mut->
op(i)));
39 if (
auto new_imm = new_mut->immutabilize())
return map(old_mut, new_imm);
48 for (
size_t i = 0, e = result.size(); i != e; ++i) result[i] = rw.rewrite(mut->
op(i));
bool is_set() const
Yields true if empty or the last op is set.
const Def * op(size_t i) const
T * isa_mut() const
If this is *mut*able, it will cast constness away and perform a dynamic_cast to T.
Def * stub(World &w, Ref type)
Ref var(nat_t a, nat_t i)
Ref rebuild(World &w, Ref type, Defs ops) const
Def::rebuilds this Def while using new_op as substitute for its i'th Def::op.
static std::optional< T > isa(Ref def)
A (possibly paramterized) Tuple.
const Def * shape() const
Helper class to retrieve Infer::arg if present.
virtual Ref rewrite_imm(Ref)
Ref map(Ref old_def, Ref new_def)
Map old_def to new_def and returns new_def;.
virtual Ref rewrite_mut(Def *)
Data constructor for a Sigma.
Vector< const Def * > DefVec
DefVec rewrite(Def *mut, Ref arg)