missed a Air Op Code and updated how we pass in otherwise for assignment
This commit is contained in:
parent
7da35d5d73
commit
df939e20ce
|
@ -9,7 +9,7 @@ use self::{
|
|||
modify_cyclic_calls, modify_self_calls, rearrange_list_clauses, AssignmentProperties,
|
||||
ClauseProperties, CodeGenSpecialFuncs, CycleFunctionNames, HoistableFunction, Variant,
|
||||
},
|
||||
tree::{AirMsg, AirTree, TreePath},
|
||||
tree::{AirTree, TreePath},
|
||||
};
|
||||
use crate::{
|
||||
ast::{
|
||||
|
@ -17,7 +17,7 @@ use crate::{
|
|||
Span, TraceLevel, Tracing, TypedArg, TypedClause, TypedDataType, TypedFunction,
|
||||
TypedPattern, TypedValidator, UnOp,
|
||||
},
|
||||
builtins::{bool, data, int, list, string, void},
|
||||
builtins::{bool, data, int, list, void},
|
||||
expr::TypedExpr,
|
||||
gen_uplc::{
|
||||
air::ExpectLevel,
|
||||
|
@ -285,14 +285,11 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
self.special_functions.insert_new_function(
|
||||
msg_func_name.clone(),
|
||||
Term::string(msg),
|
||||
string(),
|
||||
Term::Error.delayed_trace(Term::string(msg)),
|
||||
void(),
|
||||
);
|
||||
|
||||
let msg_string =
|
||||
AirTree::string(self.special_functions.use_function_string(msg_func_name));
|
||||
|
||||
AirTree::trace(msg_string, void(), AirTree::error(void(), false))
|
||||
self.special_functions.use_function_tree(msg_func_name)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1776,28 +1773,13 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
// mutate code_gen_funcs and defined_data_types in this if branch
|
||||
if function.is_none() && defined_data_types.get(&data_type_name).is_none() {
|
||||
let (msg_term, error_term) = match self.tracing {
|
||||
TraceLevel::Silent => (None, AirTree::error(tipo.clone(), false)),
|
||||
TraceLevel::Compact | TraceLevel::Verbose => {
|
||||
let msg = AirMsg::LocalVar("__param_msg".to_string());
|
||||
(
|
||||
Some(msg.clone()),
|
||||
AirTree::trace(
|
||||
msg.to_air_tree(),
|
||||
tipo.clone(),
|
||||
AirTree::error(tipo.clone(), false),
|
||||
),
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
defined_data_types.insert(data_type_name.clone(), 1);
|
||||
|
||||
let current_defined = defined_data_types.clone();
|
||||
let mut diff_defined_types = vec![];
|
||||
|
||||
let constr_clauses = data_type.constructors.iter().enumerate().rfold(
|
||||
error_term,
|
||||
otherwise.clone(),
|
||||
|acc, (index, constr)| {
|
||||
let mut constr_args = vec![];
|
||||
|
||||
|
@ -1836,8 +1818,8 @@ impl<'a> CodeGenerator<'a> {
|
|||
),
|
||||
tipo.clone(),
|
||||
),
|
||||
msg_term.clone(),
|
||||
constr_then,
|
||||
otherwise.clone(),
|
||||
)
|
||||
} else {
|
||||
AirTree::fields_expose(
|
||||
|
@ -3069,15 +3051,11 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
self.special_functions.insert_new_function(
|
||||
msg_func_name.to_string(),
|
||||
Term::string(msg),
|
||||
string(),
|
||||
Term::Error.delayed_trace(Term::string(msg)),
|
||||
void(),
|
||||
);
|
||||
|
||||
let msg_string = AirTree::string(
|
||||
self.special_functions.use_function_string(msg_func_name),
|
||||
);
|
||||
|
||||
AirTree::trace(msg_string, void(), AirTree::error(void(), false))
|
||||
self.special_functions.use_function_tree(msg_func_name)
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -233,14 +233,6 @@ impl CodeGenSpecialFuncs {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn use_function_string(&mut self, func_name: String) -> String {
|
||||
if !self.used_funcs.contains(&func_name) {
|
||||
self.used_funcs.push(func_name.to_string());
|
||||
}
|
||||
|
||||
func_name
|
||||
}
|
||||
|
||||
pub fn use_function_tree(&mut self, func_name: String) -> AirTree {
|
||||
if !self.used_funcs.contains(&func_name) {
|
||||
self.used_funcs.push(func_name.to_string());
|
||||
|
|
|
@ -215,8 +215,8 @@ pub enum AirTree {
|
|||
// Misc.
|
||||
FieldsEmpty {
|
||||
constr: Box<AirTree>,
|
||||
msg: Option<AirMsg>,
|
||||
then: Box<AirTree>,
|
||||
otherwise: Box<AirTree>,
|
||||
},
|
||||
ListEmpty {
|
||||
list: Box<AirTree>,
|
||||
|
@ -960,11 +960,11 @@ impl AirTree {
|
|||
AirTree::NoOp { then: then.into() }
|
||||
}
|
||||
|
||||
pub fn fields_empty(constr: AirTree, msg: Option<AirMsg>, then: AirTree) -> AirTree {
|
||||
pub fn fields_empty(constr: AirTree, then: AirTree, otherwise: AirTree) -> AirTree {
|
||||
AirTree::FieldsEmpty {
|
||||
constr: constr.into(),
|
||||
msg,
|
||||
then: then.into(),
|
||||
otherwise: otherwise.into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1284,15 +1284,16 @@ impl AirTree {
|
|||
otherwise.create_air_vec(air_vec);
|
||||
}
|
||||
}
|
||||
AirTree::FieldsEmpty { constr, msg, then } => {
|
||||
AirTree::FieldsEmpty {
|
||||
constr,
|
||||
then,
|
||||
otherwise,
|
||||
} => {
|
||||
air_vec.push(Air::FieldsEmpty);
|
||||
|
||||
if let Some(msg) = msg {
|
||||
msg.to_air_tree().create_air_vec(air_vec);
|
||||
}
|
||||
|
||||
constr.create_air_vec(air_vec);
|
||||
then.create_air_vec(air_vec);
|
||||
otherwise.create_air_vec(air_vec);
|
||||
}
|
||||
AirTree::ListEmpty {
|
||||
list,
|
||||
|
|
Loading…
Reference in New Issue