fn do_relocation<T>(funcs: T, func_starts: &HashMap<String, McFuncId>, globals: &mut GlobalVarList) -> Vec<McFunction>
    where T: IntoIterator<Item=McFunction>
{
    let mut funcs = funcs.into_iter().collect::<Vec<_>>();

    for (func, func_id) in func_starts.iter() {
        let idx = funcs.iter().position(|f| &f.id == func_id).unwrap();

        let name = Name::Name(Box::new(func.clone()));

        #[allow(clippy::map_entry)]
        if globals.contains_key(&name) {
            globals.get_mut(&name).unwrap().0 = idx as u32;
        } else {
            assert!(func.contains("intrinsic"));
            let name = Box::leak(Box::new(name));
            globals.insert(name, (idx as u32, None));
        }
    }

    funcs.push(create_call_func(&funcs));
    funcs.push(create_return_func());

    apply_fixups(&mut funcs, &func_starts);

    funcs
}
/// Finalizes the locations of the generated functions
/// and applies any necessary fixups
Finalizes the locations of the generated functions
and applies any necessary fixups
Finalizes the locations of the generated functions and applies any necessary fixups
fn do_relocation<T>(funcs: T, func_starts: &HashMap<String, McFuncId>, globals: &mut GlobalVarList) -> Vec<McFunction>
    where T: IntoIterator<Item=McFunction>
{
    let mut funcs = funcs.into_iter().collect::<Vec<_>>();
    for (func, func_id) in func_starts.iter() {
        let idx = funcs.iter().position(|f| &f.id == func_id).unwrap();
        let name = Name::Name(Box::new(func.clone()));
        #[allow(clippy::map_entry)]
        if globals.contains_key(&name) {
            globals.get_mut(&name).unwrap().0 = idx as u32;
        } else {
            assert!(func.contains("intrinsic"));
            let name = Box::leak(Box::new(name));
            globals.insert(name, (idx as u32, None));
        }
    }
    funcs.push(create_call_func(&funcs));
    funcs.push(create_return_func());
    apply_fixups(&mut funcs, &func_starts);
    funcs
}
fn do_relocation < T > ( funcs : T , func_starts : & HashMap < String , McFuncId > , globals : & mut GlobalVarList ) -> Vec < McFunction > where T : IntoIterator < Item = McFunction > { let mut funcs = funcs . into_iter ( ) . collect :: < Vec < _ > > ( ) ; for ( func , func_id ) in func_starts . iter ( ) { let idx = funcs . iter ( ) . position ( | f | & f . id == func_id ) . unwrap ( ) ; let name = Name :: Name ( Box :: new ( func . clone ( ) ) ) ; # [ allow ( clippy map_entry ) ] if globals . contains_key ( & name ) { globals . get_mut ( & name ) . unwrap ( ) . 0 = idx as u32 ; } else { assert ! ( func contains ( " " ) ) ; let name = Box :: leak ( Box :: new ( name ) ) ; globals . insert ( name , ( idx as u32 , None ) ) ; } } funcs . push ( create_call_func ( & funcs ) ) ; funcs . push ( create_return_func ( ) ) ; apply_fixups ( & mut funcs , & func_starts ) ; funcs }
Finalizes the locations of the generated functions
and applies any necessary fixups
Finalizes the locations of the generated functions and applies any necessary fixups
funcs
T
func_starts
&HashMap<String, McFuncId>
globals
&mut GlobalVarList
funcs
T
func_starts
&HashMap<String, McFuncId>
globals
&mut GlobalVarList