Modifications
This commit is contained in:
+13
-14
@@ -9,23 +9,22 @@
|
||||
mod step_1;
|
||||
mod step_2;
|
||||
|
||||
use crate::{parse::Atom, regify::RegFn};
|
||||
use crate::{declass::step_1::ClassSequence, regify::RegFn};
|
||||
|
||||
/// A class's constructor and its hoisted field initialiser, as fn ids into the
|
||||
/// flat function list. Read by step 1, consumed by step 2.
|
||||
#[derive(Clone, Copy)]
|
||||
struct FieldInit {
|
||||
ctor: usize,
|
||||
fields: usize,
|
||||
}
|
||||
use step_1::{find_class_seqs, rewrite_class_to_proto};
|
||||
use step_2::splice_ctor;
|
||||
|
||||
pub fn declass(reg_fns: Vec<RegFn>, _atoms: &[Atom]) -> Vec<RegFn> {
|
||||
// Read the constructor <-> field-initialiser links before step 1 rewrites
|
||||
// the class builds that carry them.
|
||||
let field_inits = step_1::field_init_links(®_fns);
|
||||
pub fn declass(mut reg_fns: Vec<RegFn>) -> Vec<RegFn> {
|
||||
let class_seqs = reg_fns
|
||||
.iter()
|
||||
.map(find_class_seqs)
|
||||
.collect::<Vec<Vec<ClassSequence>>>();
|
||||
|
||||
let mut reg_fns: Vec<RegFn> = reg_fns.into_iter().map(step_1::rewrite).collect();
|
||||
reg_fns
|
||||
.iter_mut()
|
||||
.zip(&class_seqs)
|
||||
.for_each(|(f, s)| rewrite_class_to_proto(f, s));
|
||||
|
||||
step_2::splice(&mut reg_fns, &field_inits);
|
||||
splice_ctor(&mut reg_fns, &class_seqs);
|
||||
reg_fns
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user