fn compile_explicit_dependency_declarations(
    outer_context: &mut Context,
    imports: Vec<ImportDefinition>,
    dependencies: Vec<ModuleDependency>,
) -> Result<()> {
    let mut dependencies_acc = outer_context.take_dependencies();
    for dependency in dependencies {
        let ModuleDependency {
            name: mname,
            structs,
            functions,
        } = dependency;
        let current_module = outer_context.module_ident(&mname)?;
        let mut context = Context::new(
            outer_context.decl_location(),
            dependencies_acc,
            Some(*current_module),
        )?;
        compile_imports(&mut context, imports.clone())?;
        let self_module_handle_idx = context.module_handle_index(&mname)?;
        for struct_dep in structs {
            let StructDependency {
                abilities: abs,
                name,
                type_formals: tys,
            } = struct_dep;
            let sname = QualifiedStructIdent::new(mname, name);
            let ability_set = abilities(&abs);
            let kinds = struct_type_parameters(&tys);
            context.declare_struct_handle_index(sname, ability_set, kinds)?;
        }
        for function_dep in functions {
            let FunctionDependency { name, signature } = function_dep;
            let sig = function_signature(&mut context, &signature)?;
            context.declare_function(mname, name, sig)?;
        }

        let (
            MaterializedPools {
                module_handles,
                struct_handles,
                function_handles,
                field_handles,
                signatures,
                identifiers,
                address_identifiers,
                constant_pool,
                function_instantiations,
                struct_def_instantiations,
                field_instantiations,
            },
            compiled_deps,
            _source_map,
        ) = context.materialize_pools();
        let compiled_module = CompiledModule {
            version: VERSION_MAX,
            module_handles,
            self_module_handle_idx,
            struct_handles,
            function_handles,
            field_handles,
            friend_decls: vec![],
            struct_def_instantiations,
            function_instantiations,
            field_instantiations,
            signatures,
            identifiers,
            address_identifiers,
            constant_pool,
            struct_defs: vec![],
            function_defs: vec![],
        };
        dependencies_acc = compiled_deps;
        dependencies_acc.insert(
            *current_module,
            CompiledDependency::stored(compiled_module)?,
        );
    }
    outer_context.restore_dependencies(dependencies_acc);
    Ok(())
}
// Note: DO NOT try to recover from this function as it zeros out the `outer_contexts` dependencies
// and sets them after a successful result
// Any `Error` should stop compilation in the caller
DO NOT try to recover from this function as it zeros out the `outer_contexts` dependencies
and sets them after a successful result
Any `Error` should stop compilation in the caller
DO NOT try to recover from this function as it zeros out the ` outer_contexts ` dependencies and sets them after a successful result Any ` Error ` should stop compilation in the caller
fn compile_explicit_dependency_declarations(
    outer_context: &mut Context,
    imports: Vec<ImportDefinition>,
    dependencies: Vec<ModuleDependency>,
) -> Result<()> {
    let mut dependencies_acc = outer_context.take_dependencies();
    for dependency in dependencies {
        let ModuleDependency {
            name: mname,
            structs,
            functions,
        } = dependency;
        let current_module = outer_context.module_ident(&mname)?;
        let mut context = Context::new(
            outer_context.decl_location(),
            dependencies_acc,
            Some(*current_module),
        )?;
        compile_imports(&mut context, imports.clone())?;
        let self_module_handle_idx = context.module_handle_index(&mname)?;
        for struct_dep in structs {
            let StructDependency {
                abilities: abs,
                name,
                type_formals: tys,
            } = struct_dep;
            let sname = QualifiedStructIdent::new(mname, name);
            let ability_set = abilities(&abs);
            let kinds = struct_type_parameters(&tys);
            context.declare_struct_handle_index(sname, ability_set, kinds)?;
        }
        for function_dep in functions {
            let FunctionDependency { name, signature } = function_dep;
            let sig = function_signature(&mut context, &signature)?;
            context.declare_function(mname, name, sig)?;
        }
        let (
            MaterializedPools {
                module_handles,
                struct_handles,
                function_handles,
                field_handles,
                signatures,
                identifiers,
                address_identifiers,
                constant_pool,
                function_instantiations,
                struct_def_instantiations,
                field_instantiations,
            },
            compiled_deps,
            _source_map,
        ) = context.materialize_pools();
        let compiled_module = CompiledModule {
            version: VERSION_MAX,
            module_handles,
            self_module_handle_idx,
            struct_handles,
            function_handles,
            field_handles,
            friend_decls: vec![],
            struct_def_instantiations,
            function_instantiations,
            field_instantiations,
            signatures,
            identifiers,
            address_identifiers,
            constant_pool,
            struct_defs: vec![],
            function_defs: vec![],
        };
        dependencies_acc = compiled_deps;
        dependencies_acc.insert(
            *current_module,
            CompiledDependency::stored(compiled_module)?,
        );
    }
    outer_context.restore_dependencies(dependencies_acc);
    Ok(())
}
fn compile_explicit_dependency_declarations ( outer_context : & mut Context , imports : Vec < ImportDefinition > , dependencies : Vec < ModuleDependency > , ) -> Result < ( ) > { let mut dependencies_acc = outer_context . take_dependencies ( ) ; for dependency in dependencies { let ModuleDependency { name : mname , structs , functions , } = dependency ; let current_module = outer_context . module_ident ( & mname ) ? ; let mut context = Context :: new ( outer_context . decl_location ( ) , dependencies_acc , Some ( * current_module ) , ) ? ; compile_imports ( & mut context , imports . clone ( ) ) ? ; let self_module_handle_idx = context . module_handle_index ( & mname ) ? ; for struct_dep in structs { let StructDependency { abilities : abs , name , type_formals : tys , } = struct_dep ; let sname = QualifiedStructIdent :: new ( mname , name ) ; let ability_set = abilities ( & abs ) ; let kinds = struct_type_parameters ( & tys ) ; context . declare_struct_handle_index ( sname , ability_set , kinds ) ? ; } for function_dep in functions { let FunctionDependency { name , signature } = function_dep ; let sig = function_signature ( & mut context , & signature ) ? ; context . declare_function ( mname , name , sig ) ? ; } let ( MaterializedPools { module_handles , struct_handles , function_handles , field_handles , signatures , identifiers , address_identifiers , constant_pool , function_instantiations , struct_def_instantiations , field_instantiations , } , compiled_deps , _source_map , ) = context . materialize_pools ( ) ; let compiled_module = CompiledModule { version : VERSION_MAX , module_handles , self_module_handle_idx , struct_handles , function_handles , field_handles , friend_decls : vec ! [ ] , struct_def_instantiations , function_instantiations , field_instantiations , signatures , identifiers , address_identifiers , constant_pool , struct_defs : vec ! [ ] , function_defs : vec ! [ ] , } ; dependencies_acc = compiled_deps ; dependencies_acc . insert ( * current_module , CompiledDependency :: stored ( compiled_module ) ? , ) ; } outer_context . restore_dependencies ( dependencies_acc ) ; Ok ( ( ) ) }
Note: DO NOT try to recover from this function as it zeros out the `outer_contexts` dependencies
and sets them after a successful result
Any `Error` should stop compilation in the caller
Note : DO NOT try to recover from this function as it zeros out the ` outer_contexts ` dependencies and sets them after a successful result Any ` Error ` should stop compilation in the caller
outer_context
&mut Context
imports
Vec<ImportDefinition>
dependencies
Vec<ModuleDependency>
outer_context
&mut Context
imports
Vec<ImportDefinition>
dependencies
Vec<ModuleDependency>