New direction

This commit is contained in:
2026-09-03 20:20:58 +00:00
parent 92451e9cdc
commit af85244587
12 changed files with 1095 additions and 998 deletions
+31
View File
@@ -0,0 +1,31 @@
//! 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::{parse::Atom, 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,
}
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(&reg_fns);
let mut reg_fns: Vec<RegFn> = reg_fns.into_iter().map(step_1::rewrite).collect();
step_2::splice(&mut reg_fns, &field_inits);
reg_fns
}