pub struct ClosureConverter { /* private fields */ }Expand description
The closure conversion pass.
Transforms an LCNF module by making all closures explicit: lambda expressions become struct allocations with captured variables.
Implementations§
Source§impl ClosureConverter
impl ClosureConverter
Sourcepub fn new(config: ClosureConvertConfig) -> Self
pub fn new(config: ClosureConvertConfig) -> Self
Create a new closure converter.
Sourcepub fn default_converter() -> Self
pub fn default_converter() -> Self
Create with default configuration.
Sourcepub fn convert_module(&mut self, module: &mut LcnfModule)
pub fn convert_module(&mut self, module: &mut LcnfModule)
Convert all closures in a module.
Sourcepub fn convert_fun_decl(
&mut self,
decl: &LcnfFunDecl,
) -> (LcnfFunDecl, Vec<LcnfFunDecl>)
pub fn convert_fun_decl( &mut self, decl: &LcnfFunDecl, ) -> (LcnfFunDecl, Vec<LcnfFunDecl>)
Convert a single function declaration.
Returns the converted declaration and any helper functions that were lifted out.
Sourcepub fn defunctionalize(
&mut self,
call_site_var: LcnfVarId,
possible_callees: &[String],
) -> Option<LcnfExpr>
pub fn defunctionalize( &mut self, call_site_var: LcnfVarId, possible_callees: &[String], ) -> Option<LcnfExpr>
Attempt to defunctionalize a set of closures at a call site.
When the set of possible callees is statically known, replace the closure call with a switch on the closure’s tag.
Sourcepub fn stack_allocate_closure(&self, info: &ClosureInfo) -> bool
pub fn stack_allocate_closure(&self, info: &ClosureInfo) -> bool
Determine whether a closure should be stack-allocated.
Sourcepub fn stats(&self) -> &ClosureConvertStats
pub fn stats(&self) -> &ClosureConvertStats
Get the conversion statistics.
Sourcepub fn get_closure_info(&self, var: LcnfVarId) -> Option<&ClosureInfo>
pub fn get_closure_info(&self, var: LcnfVarId) -> Option<&ClosureInfo>
Get closure info for a variable, if available.
Auto Trait Implementations§
impl Freeze for ClosureConverter
impl RefUnwindSafe for ClosureConverter
impl Send for ClosureConverter
impl Sync for ClosureConverter
impl Unpin for ClosureConverter
impl UnsafeUnpin for ClosureConverter
impl UnwindSafe for ClosureConverter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more