use crate::FunctionInliner;
use leo_ast::{ProgramReconstructor, ProgramScope};
impl ProgramReconstructor for FunctionInliner<'_> {
fn reconstruct_program_scope(&mut self, mut input: ProgramScope) -> ProgramScope {
let order = self.call_graph.post_order().unwrap();
for function_name in order.into_iter() {
if let Some(function) = input.functions.remove(&function_name) {
let reconstructed_function = self.reconstruct_function(function);
self.reconstructed_functions.insert(function_name, reconstructed_function);
}
}
assert!(input.functions.is_empty(), "All functions in the program scope should have been processed.");
let functions = core::mem::take(&mut self.reconstructed_functions);
ProgramScope {
program_id: input.program_id,
structs: input.structs,
mappings: input.mappings,
functions,
span: input.span,
}
}
}