//! declass: ES classes become prototype form, one algo step per file. //! //! The steps follow declass_algo.txt: //! //! step_1 rewrite how a class is built (per function). //! step_2 splice the field initialiser into the constructor. //! step_3 fix the constructor header: rename, drop the capture (to come). mod step_1; mod step_2; use crate::{declass::step_1::ClassSequence, regify::RegFn}; use step_1::{find_class_seqs, rewrite_class_to_proto}; use step_2::splice_ctors; pub fn declass(mut reg_fns: Vec) -> Vec { let class_seqs = reg_fns .iter() .map(find_class_seqs) .collect::>>(); reg_fns .iter_mut() .zip(&class_seqs) .for_each(|(f, s)| rewrite_class_to_proto(f, s)); splice_ctors(&mut reg_fns, &class_seqs); reg_fns }