add new enum for hoistablefunctions

This commit is contained in:
microproofs 2023-09-06 22:13:36 -04:00 committed by Kasey
parent ced818c455
commit 0b38855ce4
2 changed files with 38 additions and 1 deletions

View File

@ -2622,7 +2622,7 @@ impl<'a> CodeGenerator<'a> {
};
}
HoistableFunction::Link(_) => todo!("Deal with Link later"),
HoistableFunction::CyclicLink(_) => unreachable!(),
_ => unreachable!(),
}
}
validator_hoistable.dedup();
@ -2688,8 +2688,40 @@ impl<'a> CodeGenerator<'a> {
function_name: format!("__cyclic_function_{}", index),
module_name: "".to_string(),
};
let (functions, mut deps) = function_names
.into_iter()
.map(|(func_key, variant)| {
let (_, func) = functions_to_hoist
.get(func_key)
.expect("Missing Function Definition")
.get(variant)
.expect("Missing Function Variant Definition");
match func {
HoistableFunction::Function { body, deps, params } => {
(params.clone(), body.clone(), deps.clone())
}
_ => unreachable!(),
}
})
.fold((vec![], vec![]), |mut acc, f| {
acc.0.push((f.0, f.1));
acc.1.push(f.2);
acc
});
let cyclic_function = HoistableFunction::CyclicFunction {
functions,
deps: deps.into_iter().flatten().dedup().collect_vec(),
};
}
todo!();
// Rest of code is for hoisting functions
let mut sorted_function_vec = vec![];
@ -2739,6 +2771,7 @@ impl<'a> CodeGenerator<'a> {
}
HoistableFunction::Link(_) => todo!("Deal with Link later"),
HoistableFunction::CyclicLink(_) => {}
HoistableFunction::CyclicFunction { functions, deps } => todo!(),
}
sorted_function_vec.push((generic_func, variant));

View File

@ -46,6 +46,10 @@ pub enum HoistableFunction {
deps: Vec<(FunctionAccessKey, String)>,
params: Vec<String>,
},
CyclicFunction {
functions: Vec<(Vec<String>, AirTree)>,
deps: Vec<(FunctionAccessKey, String)>,
},
Link((FunctionAccessKey, String)),
CyclicLink((FunctionAccessKey, String)),
}