Namespaces | |
| namespace | phase |
Classes | |
| class | ClosLit |
| Lightweight, non-owning view onto a closure literal (env_type, fn, env); see isa_clos_lit. More... | |
Enumerations | |
%clos.BufPtr | |
| enum class | BufPtr : flags_t |
%clos.alloc_jmpbuf | |
| enum class | alloc_jmpbuf : flags_t |
%clos.setjmp | |
| enum class | setjmp : flags_t |
%clos.longjmp | |
| enum class | longjmp : flags_t |
%clos.clos_conv_prep | |
| enum class | clos_conv_prep : flags_t |
%clos.clos_conv | |
| enum class | clos_conv : flags_t |
%clos.branch_clos | |
| enum class | branch_clos : flags_t |
%clos.lower_typed_clos_prep | |
| enum class | lower_typed_clos_prep : flags_t |
%clos.clos2sjlj | |
| enum class | clos2sjlj : flags_t |
%clos.lower_typed_clos | |
| enum class | lower_typed_clos : flags_t |
Functions | |
| void | register_normalizers (Normalizers &normalizers) |
Closures | |
| ClosLit | isa_clos_lit (const Def *def, bool fn_isa_lam=true) |
| Tries to match a closure literal. | |
| const Def * | clos_pack (const Def *env, const Def *fn, const Def *ct=nullptr) |
| Pack a typed closure. | |
| std::tuple< const Def *, const Def *, const Def * > | clos_unpack (const Def *c) |
| Deconstruct a closure into (env_type, function, env). | |
| const Def * | clos_apply (const Def *closure, const Def *args) |
| Apply a closure to arguments. | |
| const Def * | apply_closure (const Def *closure, Defs args) |
| template<class N> | |
| std::tuple< const Extract *, N * > | isa_var_proj (const Def *def) |
If def is a projection var#i of the Var of some mutable of type N, returns (projection, binder). | |
Closure Types | |
| const Sigma * | isa_clos_type (const Def *def) |
| Sigma * | clos_type (const Pi *pi) |
Creates a typed closure type from pi. | |
| const Pi * | clos_type_to_pi (const Def *ct, const Def *new_env_type=nullptr) |
Convert a closure type to a Pi, where the environment type has been removed or replaced by new_env_type (if new_env_type != nullptr). | |
Closure Environment | |
| size_t | env_param (Defs doms) |
Describes where the environment is placed in the argument list: right after a leading mem.M, if doms starts with one, or in slot 0 otherwise. | |
| size_t | env_param (const Pi *pi) |
| size_t | shift_env (size_t ep, size_t i) |
| Adjust the index of an argument to account for the env param. | |
| size_t | skip_env (size_t ep, size_t i) |
| Same as shift_env, but skips the env param instead. | |
| const Def * | ctype (World &w, Defs doms, const Def *env_type=nullptr) |
Builds a closure type from the domains doms of a Cn. | |
| const Def * | clos_insert_env (size_t ep, size_t i, const Def *env, std::function< const Def *(size_t)> f) |
| const Def * | clos_insert_env (size_t ep, size_t i, const Def *env, const Def *a) |
| const Def * | clos_insert_env (size_t ep, const Def *env, const Def *tup_or_sig) |
| const Def * | clos_remove_env (size_t ep, size_t i, std::function< const Def *(size_t)> f) |
| const Def * | clos_remove_env (size_t ep, size_t i, const Def *def) |
| const Def * | clos_remove_env (size_t ep, const Def *tup_or_sig) |
| const Def * | clos_sub_env (size_t ep, const Def *tup_or_sig, const Def *new_env) |
Variables | |
| static constexpr plugin_t | Plugin_Id = 0x10d4140000000000 |
%clos.attr | |
| enum class | attr : flags_t { returning = 0x10d4140000000400 , free_bb = 0x10d4140000000401 , fstclass_bb = 0x10d4140000000402 , esc = 0x10d4140000000403 , bottom = 0x10d4140000000404 } |
| template<attr o> | |
| const Def * | normalize_clos (const Def *, const Def *, const Def *arg) |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
Definition at line 65 of file clos.h.
References clos_apply(), mim::World::tuple(), and mim::Def::world().
Apply a closure to arguments.
Definition at line 76 of file clos.cpp.
References clos_unpack(), env_param(), and mim::Def::world().
Referenced by apply_closure(), and mim::plug::clos::phase::ClosConv::rewrite_imm_App().
|
inline |
Definition at line 119 of file clos.h.
References mim::Def::num_projs(), and mim::Def::world().
|
inline |
Definition at line 115 of file clos.h.
References clos_insert_env().
| const Def * mim::plug::clos::clos_pack | ( | const Def * | env, |
| const Def * | fn, | ||
| const Def * | ct = nullptr ) |
Pack a typed closure.
This assumes that fn expects the environment at its env_param()th argument.
Definition at line 59 of file clos.cpp.
References clos_remove_env(), clos_type(), mim::Pi::dom(), env_param(), isa_clos_type(), mim::Def::type(), and mim::Def::world().
Referenced by mim::plug::clos::phase::LowerTypedClosPrep::rewrite_imm_Tuple(), and mim::plug::clos::phase::ClosConv::rewrite_mut_Lam().
Definition at line 129 of file clos.h.
References mim::Def::num_projs(), and mim::Def::world().
Definition at line 126 of file clos.h.
References clos_remove_env(), and mim::Def::proj().
| const Def * mim::plug::clos::clos_remove_env | ( | size_t | ep, |
| size_t | i, | ||
| std::function< const Def *(size_t)> | f ) |
Definition at line 122 of file clos.cpp.
References skip_env().
Referenced by clos_pack(), clos_remove_env(), clos_type_to_pi(), and mim::plug::clos::phase::BranchClosElim::rewrite_imm_App().
|
inline |
Definition at line 135 of file clos.h.
References mim::Def::refine().
Referenced by clos_type_to_pi().
Creates a typed closure type from pi.
Definition at line 99 of file clos.cpp.
References mim::Def::as_mut(), ctype(), and mim::Def::world().
Referenced by clos_pack().
Convert a closure type to a Pi, where the environment type has been removed or replaced by new_env_type (if new_env_type != nullptr).
Definition at line 105 of file clos.cpp.
References clos_remove_env(), clos_sub_env(), mim::Pi::dom(), env_param(), isa_clos_type(), mim::Def::op(), and mim::Def::world().
Deconstruct a closure into (env_type, function, env).
Important: use this or ClosLit to destruct closures, since typechecking dependent pairs is currently broken.
Definition at line 70 of file clos.cpp.
References isa_clos_type().
Referenced by clos_apply(), mim::plug::clos::ClosLit::env(), mim::plug::clos::ClosLit::fnc(), and mim::plug::clos::ClosLit::isa_clos_lit.
Builds a closure type from the domains doms of a Cn.
If env_type is nullptr, returns the recursive closure Sigma [T: *, Cn [doms with T at env_param], T]. Otherwise, returns the bare Cn [doms with env_type at env_param] (the code part of such a closure).
Definition at line 124 of file clos.cpp.
References ctype(), and env_param().
Referenced by clos_type(), and ctype().
|
inline |
Definition at line 101 of file clos.h.
References env_param().
|
inline |
Describes where the environment is placed in the argument list: right after a leading mem.M, if doms starts with one, or in slot 0 otherwise.
tup_or_sig should generally be a Tuple, Sigma or Var. This way, closures built from mem-free (pure) functions don't gain a bogus mem-shaped layout, and don't get misaligned with their real parameters (see issue #126).
Definition at line 100 of file clos.h.
References mim::Axm::isa().
Referenced by clos_apply(), clos_pack(), clos_type_to_pi(), ctype(), env_param(), mim::plug::clos::ClosLit::env_var(), isa_clos_type(), mim::plug::clos::phase::BranchClosElim::rewrite_imm_App(), and mim::plug::clos::phase::ClosConv::rewrite_imm_Extract().
Tries to match a closure literal.
If fn_isa_lam, additionally requires the code part to be a Lam.
Definition at line 50 of file clos.cpp.
Referenced by mim::plug::clos::phase::LowerTypedClosPrep::analyze(), mim::plug::clos::phase::LowerTypedClos::rewrite(), and mim::plug::clos::phase::LowerTypedClosPrep::rewrite_imm_Tuple().
Returns def if def is a closure and nullptr otherwise
Definition at line 88 of file clos.cpp.
References env_param(), mim::Pi::isa_cn(), mim::Def::isa_mut(), mim::Def::op(), mim::Def::var(), and mim::Def::world().
Referenced by clos_pack(), clos_type_to_pi(), clos_unpack(), mim::plug::clos::ClosLit::isa_clos_lit, and mim::plug::clos::phase::LowerTypedClos::rewrite().
| std::tuple< const Extract *, N * > mim::plug::clos::isa_var_proj | ( | const Def * | def | ) |
If def is a projection var#i of the Var of some mutable of type N, returns (projection, binder).
Otherwise, returns (nullptr, nullptr).
Definition at line 72 of file clos.h.
References mim::Var::binder().
Referenced by mim::plug::clos::phase::ClosConv::rewrite_imm_Extract().
| const Def * mim::plug::clos::normalize_clos | ( | const Def * | , |
| const Def * | , | ||
| const Def * | arg ) |
Definition at line 6 of file normalizers.cpp.
References bottom.
| void mim::plug::clos::register_normalizers | ( | Normalizers & | normalizers | ) |
Referenced by mim_get_plugin().
|
inline |
Adjust the index of an argument to account for the env param.
Definition at line 104 of file clos.h.
Referenced by clos_insert_env().
|
inline |
Same as shift_env, but skips the env param instead.
Definition at line 107 of file clos.h.
Referenced by clos_remove_env(), and mim::plug::clos::phase::ClosConv::rewrite_imm_Extract().