fn compute_stack_costs(ctx: &mut Context, module: &elements::Module) -> Result<(), Error> {
	let func_imports = module.import_count(elements::ImportCountType::Function);
	let mut func_stack_costs = vec![0; module.functions_space()];
	// TODO: optimize!
	for (func_idx, func_stack_cost) in func_stack_costs.iter_mut().enumerate() {
		// We can't calculate stack_cost of the import functions.
		if func_idx >= func_imports {
			*func_stack_cost = compute_stack_cost(func_idx as u32, &module)?;
		}
	}

	ctx.func_stack_costs = Some(func_stack_costs);
	Ok(())
}
/// Calculate stack costs for all functions.
///
/// Returns a vector with a stack cost for each function, including imports.
Calculate stack costs for all functions.
Returns a vector with a stack cost for each function, including imports.
Calculate stack costs for all functions . Returns a vector with a stack cost for each function including imports .
fn compute_stack_costs(ctx: &mut Context, module: &elements::Module) -> Result<(), Error> {
	let func_imports = module.import_count(elements::ImportCountType::Function);
	let mut func_stack_costs = vec![0; module.functions_space()];
	// TODO: optimize!
	for (func_idx, func_stack_cost) in func_stack_costs.iter_mut().enumerate() {
		// We can't calculate stack_cost of the import functions.
		if func_idx >= func_imports {
			*func_stack_cost = compute_stack_cost(func_idx as u32, &module)?;
		}
	}
	ctx.func_stack_costs = Some(func_stack_costs);
	Ok(())
}
fn compute_stack_costs ( ctx : & mut Context , module : & elements :: Module ) -> Result < ( ) , Error > { let func_imports = module . import_count ( elements :: ImportCountType :: Function ) ; let mut func_stack_costs = vec ! [ 0 module functions_space ( ) ] ; // TODO: optimize! for ( func_idx , func_stack_cost ) in func_stack_costs . iter_mut ( ) . enumerate ( ) { // We can't calculate stack_cost of the import functions. if func_idx >= func_imports { * func_stack_cost = compute_stack_cost ( func_idx as u32 , & module ) ? ; } } ctx . func_stack_costs = Some ( func_stack_costs ) ; Ok ( ( ) ) }
Calculate stack costs for all functions.
Calculate stack costs for all functions .
ctx
&mut Context
module
&elements::Module
ctx
&mut Context
module
&elements::Module