pub fn substitute_frame_references(&self, substitute: &mut dyn FnMut(FrameReference) -> Option<CellRef>) -> Closure<Action> {
        // Rebind the imported cells for this closure
        let mut new_import_cells    = vec![];
        let mut new_bound_cells     = self.bound_cells.clone();

        // Substitute the imported cells
        for (src_cell_id, tgt_cell_id) in self.import_cells.iter() {
            if let Some(substitution) = substitute(FrameReference(*src_cell_id, 0, ReferenceType::Value)) {
                // Bind to an absolute value or a different cell
                match &*substitution {
                    SafasCell::FrameReference(new_src_cell_id, 0, _)    => new_import_cells.push((*new_src_cell_id, *tgt_cell_id)),
                    _                                                   => new_bound_cells.push((*tgt_cell_id, substitution))
                }
            } else {
                // Import as before
                new_import_cells.push((*src_cell_id, *tgt_cell_id));
            }
        }

        // Generate the substituted closure
        Closure {
            action:         Arc::clone(&self.action),
            import_cells:   new_import_cells,
            bound_cells:    new_bound_cells,
            num_cells:      self.num_cells,
            arg_count:      self.arg_count,
            returns_monad:  self.returns_monad
        }
    }
///
/// Changes the source references according to the results of the substitution function
///
Changes the source references according to the results of the substitution function
Changes the source references according to the results of the substitution function
pub fn substitute_frame_references(&self, substitute: &mut dyn FnMut(FrameReference) -> Option<CellRef>) -> Closure<Action> {
        // Rebind the imported cells for this closure
        let mut new_import_cells    = vec![];
        let mut new_bound_cells     = self.bound_cells.clone();
        // Substitute the imported cells
        for (src_cell_id, tgt_cell_id) in self.import_cells.iter() {
            if let Some(substitution) = substitute(FrameReference(*src_cell_id, 0, ReferenceType::Value)) {
                // Bind to an absolute value or a different cell
                match &*substitution {
                    SafasCell::FrameReference(new_src_cell_id, 0, _)    => new_import_cells.push((*new_src_cell_id, *tgt_cell_id)),
                    _                                                   => new_bound_cells.push((*tgt_cell_id, substitution))
                }
            } else {
                // Import as before
                new_import_cells.push((*src_cell_id, *tgt_cell_id));
            }
        }
        // Generate the substituted closure
        Closure {
            action:         Arc::clone(&self.action),
            import_cells:   new_import_cells,
            bound_cells:    new_bound_cells,
            num_cells:      self.num_cells,
            arg_count:      self.arg_count,
            returns_monad:  self.returns_monad
        }
    }
pub fn substitute_frame_references ( & self , substitute : & mut dyn FnMut ( FrameReference ) -> Option < CellRef > ) -> Closure < Action > { // Rebind the imported cells for this closure let mut new_import_cells = vec ! [ ] ; let mut new_bound_cells = self . bound_cells . clone ( ) ; // Substitute the imported cells for ( src_cell_id , tgt_cell_id ) in self . import_cells . iter ( ) { if let Some ( substitution ) = substitute ( FrameReference ( * src_cell_id , 0 , ReferenceType :: Value ) ) { // Bind to an absolute value or a different cell match & * substitution { SafasCell :: FrameReference ( new_src_cell_id , 0 , _ ) => new_import_cells . push ( ( * new_src_cell_id , * tgt_cell_id ) ) , _ => new_bound_cells . push ( ( * tgt_cell_id , substitution ) ) } } else { // Import as before new_import_cells . push ( ( * src_cell_id , * tgt_cell_id ) ) ; } } // Generate the substituted closure Closure { action : Arc :: clone ( & self . action ) , import_cells : new_import_cells , bound_cells : new_bound_cells , num_cells : self . num_cells , arg_count : self . arg_count , returns_monad : self . returns_monad } }
Changes the source references according to the results of the substitution function
Changes the source references according to the results of the substitution function
&self
substitute
&mut dyn FnMut(FrameReference) -> Option<CellRef>
&self
substitute
&mut dyn FnMut(FrameReference) -> Option<CellRef>