use crate::{function::Function, module::Module, statement::Statement};
pub fn find_function<'a>(module: &'a Module, name: &str) -> Option<&'a Function> {
module
.body
.statements
.iter()
.chain(module.symbols.iter().map(|symbol| &symbol.statement))
.find_map(|statement| match statement {
Statement::FunctionDecl(function) if function.name == name => Some(function),
_ => None,
})
}
pub fn function_exists(module: &Module, name: &str) -> bool {
find_function(module, name).is_some()
}