pub fn new(parsed_module: parity_wasm::elements::Module) -> Result<Self, Error> {
        // Inject metering calls, which are used for checking timeouts.
        let parsed_module = pwasm_utils::inject_gas_counter(parsed_module, &Default::default())
            .map_err(|_| err_msg("failed to inject gas counter"))?;

        // `inject_gas_counter` injects an import so the section must exist.
        let import_section = parsed_module.import_section().unwrap().clone();

        // Collect the names of all host modules used in the WASM module
        let mut host_module_names: Vec<_> = import_section
            .entries()
            .into_iter()
            .map(|import| import.module().to_owned())
            .collect();
        host_module_names.dedup();

        let module = wasmi::Module::from_parity_wasm_module(parsed_module)
            .map_err(|e| format_err!("Invalid WASM module: {}", e))?;

        Ok(ValidModule {
            module,
            host_module_names,
        })
    }
/// Pre-process and validate the module.
Pre-process and validate the module.
Pre - process and validate the module .
pub fn new(parsed_module: parity_wasm::elements::Module) -> Result<Self, Error> {
        // Inject metering calls, which are used for checking timeouts.
        let parsed_module = pwasm_utils::inject_gas_counter(parsed_module, &Default::default())
            .map_err(|_| err_msg("failed to inject gas counter"))?;
        // `inject_gas_counter` injects an import so the section must exist.
        let import_section = parsed_module.import_section().unwrap().clone();
        // Collect the names of all host modules used in the WASM module
        let mut host_module_names: Vec<_> = import_section
            .entries()
            .into_iter()
            .map(|import| import.module().to_owned())
            .collect();
        host_module_names.dedup();
        let module = wasmi::Module::from_parity_wasm_module(parsed_module)
            .map_err(|e| format_err!("Invalid WASM module: {}", e))?;
        Ok(ValidModule {
            module,
            host_module_names,
        })
    }
pub fn new ( parsed_module : parity_wasm :: elements :: Module ) -> Result < Self , Error > { // Inject metering calls, which are used for checking timeouts. let parsed_module = pwasm_utils :: inject_gas_counter ( parsed_module , & Default :: default ( ) ) . map_err ( | _ | err_msg ( " " ) ) ? ; // `inject_gas_counter` injects an import so the section must exist. let import_section = parsed_module . import_section ( ) . unwrap ( ) . clone ( ) ; // Collect the names of all host modules used in the WASM module let mut host_module_names : Vec < _ > = import_section . entries ( ) . into_iter ( ) . map ( | import | import . module ( ) . to_owned ( ) ) . collect ( ) ; host_module_names . dedup ( ) ; let module = wasmi :: Module :: from_parity_wasm_module ( parsed_module ) . map_err ( | e | format_err ! ( " " e ) ) ? ; Ok ( ValidModule { module , host_module_names , } ) }
Pre-process and validate the module.
Pre - process and validate the module .
parsed_module
parity_wasm::elements::Module
parsed_module
parity_wasm::elements::Module