pub (super) fn rebind_cell(binding: &CellRef, bindings: SymbolBindings, frame_depth: u32) -> (SymbolBindings, Option<CellRef>) {
    match &**binding {
        // Frame references need to be imported into the current frame
        SafasCell::FrameReference(outer_cell_id, bound_level, cell_type) => {
            // Import this frame reference
            let mut bindings    = bindings;
            let local_cell_id   = bindings.alloc_cell();
            let outer_cell      = SafasCell::FrameReference(*outer_cell_id, *bound_level + frame_depth, *cell_type).into();
            bindings.import(outer_cell, local_cell_id);

            // Update the binding
            (bindings, Some(SafasCell::FrameReference(local_cell_id, 0, *cell_type).into()))
        }

        // Syntax might need to be rebound to the current frame
        SafasCell::Syntax(old_syntax, val) => {
            // Try to rebind the syntax
            let (new_bindings, new_syntax) = old_syntax.rebind_from_outer_frame(bindings, val.clone(), frame_depth);

            // Update the binding if the syntax update
            if let Some((new_syntax, new_val)) = new_syntax {
                (new_bindings, Some(SafasCell::Syntax(new_syntax, new_val).into()))
            } else {
                (new_bindings, None)
            }
        }

        // Other types are not affected by rebinding
        _ => { (bindings, None) }
    }
}
///
/// Rebinds a single cell to a new frame depth
///
Rebinds a single cell to a new frame depth
Rebinds a single cell to a new frame depth
pub (super) fn rebind_cell(binding: &CellRef, bindings: SymbolBindings, frame_depth: u32) -> (SymbolBindings, Option<CellRef>) {
    match &**binding {
        // Frame references need to be imported into the current frame
        SafasCell::FrameReference(outer_cell_id, bound_level, cell_type) => {
            // Import this frame reference
            let mut bindings    = bindings;
            let local_cell_id   = bindings.alloc_cell();
            let outer_cell      = SafasCell::FrameReference(*outer_cell_id, *bound_level + frame_depth, *cell_type).into();
            bindings.import(outer_cell, local_cell_id);
            // Update the binding
            (bindings, Some(SafasCell::FrameReference(local_cell_id, 0, *cell_type).into()))
        }
        // Syntax might need to be rebound to the current frame
        SafasCell::Syntax(old_syntax, val) => {
            // Try to rebind the syntax
            let (new_bindings, new_syntax) = old_syntax.rebind_from_outer_frame(bindings, val.clone(), frame_depth);
            // Update the binding if the syntax update
            if let Some((new_syntax, new_val)) = new_syntax {
                (new_bindings, Some(SafasCell::Syntax(new_syntax, new_val).into()))
            } else {
                (new_bindings, None)
            }
        }
        // Other types are not affected by rebinding
        _ => { (bindings, None) }
    }
}
pub ( super ) fn rebind_cell ( binding : & CellRef , bindings : SymbolBindings , frame_depth : u32 ) -> ( SymbolBindings , Option < CellRef > ) { match & * * binding { // Frame references need to be imported into the current frame SafasCell :: FrameReference ( outer_cell_id , bound_level , cell_type ) => { // Import this frame reference let mut bindings = bindings ; let local_cell_id = bindings . alloc_cell ( ) ; let outer_cell = SafasCell :: FrameReference ( * outer_cell_id , * bound_level + frame_depth , * cell_type ) . into ( ) ; bindings . import ( outer_cell , local_cell_id ) ; // Update the binding ( bindings , Some ( SafasCell :: FrameReference ( local_cell_id , 0 , * cell_type ) . into ( ) ) ) } // Syntax might need to be rebound to the current frame SafasCell :: Syntax ( old_syntax , val ) => { // Try to rebind the syntax let ( new_bindings , new_syntax ) = old_syntax . rebind_from_outer_frame ( bindings , val . clone ( ) , frame_depth ) ; // Update the binding if the syntax update if let Some ( ( new_syntax , new_val ) ) = new_syntax { ( new_bindings , Some ( SafasCell :: Syntax ( new_syntax , new_val ) . into ( ) ) ) } else { ( new_bindings , None ) } } // Other types are not affected by rebinding _ => { ( bindings , None ) } } }
Rebinds a single cell to a new frame depth
Rebinds a single cell to a new frame depth
binding
&CellRef
bindings
SymbolBindings
frame_depth
u32
binding
&CellRef
bindings
SymbolBindings
frame_depth
u32