Add codegen for recursive statics case
We also flip the recursive_statics fields to recursive_nonstatics; This makes the codegen a little easier. It also has a hacky way to hard code in some recursive statics for testing
This commit is contained in:
@@ -47,7 +47,7 @@ pub enum Air {
|
||||
module_name: String,
|
||||
params: Vec<String>,
|
||||
recursive: bool,
|
||||
recursive_static_params: Vec<String>,
|
||||
recursive_nonstatic_params: Vec<String>,
|
||||
variant_name: String,
|
||||
},
|
||||
Fn {
|
||||
|
||||
@@ -583,7 +583,7 @@ pub fn erase_opaque_type_operations(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modify_self_calls(air_tree: &mut AirTree, func_key: &FunctionAccessKey, variant: &String) {
|
||||
pub fn modify_self_calls(air_tree: &mut AirTree, func_key: &FunctionAccessKey, variant: &String, static_recursive_params: &Vec<usize>) {
|
||||
if let AirTree::Expression(AirExpression::Call { func, args, .. }) = air_tree {
|
||||
if let AirTree::Expression(AirExpression::Var {
|
||||
constructor:
|
||||
@@ -599,6 +599,11 @@ pub fn modify_self_calls(air_tree: &mut AirTree, func_key: &FunctionAccessKey, v
|
||||
&& module == &func_key.module_name
|
||||
&& variant == variant_name
|
||||
{
|
||||
// Remove any static-recursive-parameters, because they'll be bound statically
|
||||
// above the recursive part of the function
|
||||
for arg in static_recursive_params.iter().rev() {
|
||||
args.remove(*arg);
|
||||
}
|
||||
let mut new_args = vec![func.as_ref().clone()];
|
||||
new_args.append(args);
|
||||
*args = new_args;
|
||||
|
||||
@@ -129,7 +129,7 @@ pub enum AirStatement {
|
||||
module_name: String,
|
||||
params: Vec<String>,
|
||||
recursive: bool,
|
||||
recursive_static_params: Vec<String>,
|
||||
recursive_nonstatic_params: Vec<String>,
|
||||
variant_name: String,
|
||||
func_body: Box<AirTree>,
|
||||
},
|
||||
@@ -424,7 +424,7 @@ impl AirTree {
|
||||
variant_name: impl ToString,
|
||||
params: Vec<String>,
|
||||
recursive: bool,
|
||||
recursive_static_params: Vec<String>,
|
||||
recursive_nonstatic_params: Vec<String>,
|
||||
func_body: AirTree,
|
||||
) -> AirTree {
|
||||
AirTree::Statement {
|
||||
@@ -433,7 +433,7 @@ impl AirTree {
|
||||
module_name: module_name.to_string(),
|
||||
params,
|
||||
recursive,
|
||||
recursive_static_params,
|
||||
recursive_nonstatic_params,
|
||||
variant_name: variant_name.to_string(),
|
||||
func_body: func_body.into(),
|
||||
},
|
||||
@@ -878,7 +878,7 @@ impl AirTree {
|
||||
module_name,
|
||||
params,
|
||||
recursive,
|
||||
recursive_static_params,
|
||||
recursive_nonstatic_params,
|
||||
variant_name,
|
||||
func_body,
|
||||
} => {
|
||||
@@ -887,7 +887,7 @@ impl AirTree {
|
||||
module_name: module_name.clone(),
|
||||
params: params.clone(),
|
||||
recursive: *recursive,
|
||||
recursive_static_params: recursive_static_params.clone(),
|
||||
recursive_nonstatic_params: recursive_nonstatic_params.clone(),
|
||||
variant_name: variant_name.clone(),
|
||||
});
|
||||
func_body.create_air_vec(air_vec);
|
||||
|
||||
Reference in New Issue
Block a user