pub fn run_bytecode_model_builder<'a>(
    modules: impl IntoIterator<Item = &'a CompiledModule>,
) -> anyhow::Result<GlobalEnv> {
    let mut env = GlobalEnv::new();
    for (i, m) in modules.into_iter().enumerate() {
        let id = m.self_id();
        let addr = addr_to_big_uint(id.address());
        let module_name = ModuleName::new(addr, env.symbol_pool().make(id.name().as_str()));
        let module_id = ModuleId::new(i);
        let mut module_data = ModuleData::stub(module_name.clone(), module_id, m.clone());

        // add functions
        for (i, def) in m.function_defs().iter().enumerate() {
            let def_idx = FunctionDefinitionIndex(i as u16);
            let name = m.identifier_at(m.function_handle_at(def.function).name);
            let symbol = env.symbol_pool().make(name.as_str());
            let fun_id = FunId::new(symbol);
            let data = FunctionData::stub(symbol, def_idx, def.function);
            module_data.function_data.insert(fun_id, data);
            module_data.function_idx_to_id.insert(def_idx, fun_id);
        }

        // add structs
        for (i, def) in m.struct_defs().iter().enumerate() {
            let def_idx = StructDefinitionIndex(i as u16);
            let name = m.identifier_at(m.struct_handle_at(def.struct_handle).name);
            let symbol = env.symbol_pool().make(name.as_str());
            let struct_id = StructId::new(symbol);
            let data = env.create_move_struct_data(
                m,
                def_idx,
                symbol,
                Loc::default(),
                Vec::default(),
                Spec::default(),
            );
            module_data.struct_data.insert(struct_id, data);
            module_data.struct_idx_to_id.insert(def_idx, struct_id);
        }

        env.module_data.push(module_data);
    }
    Ok(env)
}
/// Build a `GlobalEnv` from a collection of `CompiledModule`'s. The `modules` list must be
/// topologically sorted by the dependency relation (i.e., a child node in the dependency graph
/// should appear earlier in the vector than its parents).
Build a `GlobalEnv` from a collection of `CompiledModule`'s. The `modules` list must be
topologically sorted by the dependency relation .
Build a ` GlobalEnv ` from a collection of ` CompiledModule ` ' s . The ` modules ` list must be topologically sorted by the dependency relation .
pub fn run_bytecode_model_builder<'a>(
    modules: impl IntoIterator<Item = &'a CompiledModule>,
) -> anyhow::Result<GlobalEnv> {
    let mut env = GlobalEnv::new();
    for (i, m) in modules.into_iter().enumerate() {
        let id = m.self_id();
        let addr = addr_to_big_uint(id.address());
        let module_name = ModuleName::new(addr, env.symbol_pool().make(id.name().as_str()));
        let module_id = ModuleId::new(i);
        let mut module_data = ModuleData::stub(module_name.clone(), module_id, m.clone());
        // add functions
        for (i, def) in m.function_defs().iter().enumerate() {
            let def_idx = FunctionDefinitionIndex(i as u16);
            let name = m.identifier_at(m.function_handle_at(def.function).name);
            let symbol = env.symbol_pool().make(name.as_str());
            let fun_id = FunId::new(symbol);
            let data = FunctionData::stub(symbol, def_idx, def.function);
            module_data.function_data.insert(fun_id, data);
            module_data.function_idx_to_id.insert(def_idx, fun_id);
        }
        // add structs
        for (i, def) in m.struct_defs().iter().enumerate() {
            let def_idx = StructDefinitionIndex(i as u16);
            let name = m.identifier_at(m.struct_handle_at(def.struct_handle).name);
            let symbol = env.symbol_pool().make(name.as_str());
            let struct_id = StructId::new(symbol);
            let data = env.create_move_struct_data(
                m,
                def_idx,
                symbol,
                Loc::default(),
                Vec::default(),
                Spec::default(),
            );
            module_data.struct_data.insert(struct_id, data);
            module_data.struct_idx_to_id.insert(def_idx, struct_id);
        }
        env.module_data.push(module_data);
    }
    Ok(env)
}
pub fn run_bytecode_model_builder < ' a > ( modules : impl IntoIterator < Item = & ' a CompiledModule > , ) -> anyhow :: Result < GlobalEnv > { let mut env = GlobalEnv :: new ( ) ; for ( i , m ) in modules . into_iter ( ) . enumerate ( ) { let id = m . self_id ( ) ; let addr = addr_to_big_uint ( id . address ( ) ) ; let module_name = ModuleName :: new ( addr , env . symbol_pool ( ) . make ( id . name ( ) . as_str ( ) ) ) ; let module_id = ModuleId :: new ( i ) ; let mut module_data = ModuleData :: stub ( module_name . clone ( ) , module_id , m . clone ( ) ) ; // add functions for ( i , def ) in m . function_defs ( ) . iter ( ) . enumerate ( ) { let def_idx = FunctionDefinitionIndex ( i as u16 ) ; let name = m . identifier_at ( m . function_handle_at ( def . function ) . name ) ; let symbol = env . symbol_pool ( ) . make ( name . as_str ( ) ) ; let fun_id = FunId :: new ( symbol ) ; let data = FunctionData :: stub ( symbol , def_idx , def . function ) ; module_data . function_data . insert ( fun_id , data ) ; module_data . function_idx_to_id . insert ( def_idx , fun_id ) ; } // add structs for ( i , def ) in m . struct_defs ( ) . iter ( ) . enumerate ( ) { let def_idx = StructDefinitionIndex ( i as u16 ) ; let name = m . identifier_at ( m . struct_handle_at ( def . struct_handle ) . name ) ; let symbol = env . symbol_pool ( ) . make ( name . as_str ( ) ) ; let struct_id = StructId :: new ( symbol ) ; let data = env . create_move_struct_data ( m , def_idx , symbol , Loc :: default ( ) , Vec :: default ( ) , Spec :: default ( ) , ) ; module_data . struct_data . insert ( struct_id , data ) ; module_data . struct_idx_to_id . insert ( def_idx , struct_id ) ; } env . module_data . push ( module_data ) ; } Ok ( env ) }
Build a `GlobalEnv` from a collection of `CompiledModule`'s.
Build a ` GlobalEnv ` from a collection of ` CompiledModule ` ' s .
modules
impl IntoIterator<Item = &'a CompiledModule>