22 for (
size_t i = 0, e =
num_ptrns(); i != e; ++i) {
41 auto ops =
DefVec(n, [&](
size_t i) {
return ptrn(i)->
type(world, def2fields); });
43 if (std::ranges::all_of(ptrns_, [](
auto&& b) {
return b->is_anonymous(); })) {
44 if (decl_)
return type_ = decl_->
set(ops);
57 if (
auto infer = decl_->isa<
Infer>()) {
58 if (infer->is_set()) {
59 if (infer->op() != sigma)
60 error(infer->loc(),
"inferred different sigma '{}' for '{}'", infer->op(), sigma);
72 sigma->set(0, ops[0]);
73 for (
size_t i = 1; i != n; ++i) {
74 if (
auto infer = infers_[i - 1]) infer->set(sigma->var(n, i - 1)->set(
ptrn(i - 1)->
sym()));
75 sigma->set(i, ops[i]);
78 auto var = sigma->var()->as<
Var>();
80 sigma->reset(0, ops[0]);
81 for (
size_t i = 1; i != n; ++i) sigma->reset(i, rw.rewrite(ops[i]));
84 if (
auto imm = sigma->immutabilize())
return type_ = imm;
T * isa_mut() const
If this is *mut*able, it will cast constness away and perform a dynamic_cast to T.
Def * set(size_t i, const Def *def)
Successively set from left to right.
const Def * proj(nat_t a, nat_t i) const
Similar to World::extract while assuming an arity of a, but also works on Sigmas and Arrays.
void bind(Scopes &, const Def *, bool rebind=false) const override
const Def * type(World &, Def2Fields &) const override
This node is a hole in the IR that is inferred by its context later on.
Infer * set(const Def *op)
virtual void bind(Scopes &, const Def *, bool rebind=false) const =0
virtual const Def * type(World &, Def2Fields &) const =0
void bind(Scope *, Dbg, const Def *, bool rebind=false)
Sigma * set(size_t i, const Def *def)
const Def * type(World &, Def2Fields &) const override
const Ptrn * ptrn(size_t i) const
void bind(Scopes &, const Def *, bool rebind=false) const override
This is a thin wrapper for absl::InlinedVector<T, N, A> which in turn is a drop-in replacement for st...
The World represents the whole program and manages creation of Thorin nodes (Defs).
Sigma * mut_sigma(Ref type, size_t size)
void error(const Def *def, const char *fmt, Args &&... args)
auto assert_emplace(C &container, Args &&... args)
Invokes emplace on container, asserts that insertion actually happened, and returns the iterator.
DefMap< Vector< Sym > > Def2Fields
Vector< const Def * > DefVec