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