Now code gen is finished and we just have testing
This commit is contained in:
parent
518bea5be4
commit
6eeb282dee
|
@ -625,7 +625,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
if props.value_type.is_data() && props.kind.is_expect() && !tipo.is_data() {
|
if props.value_type.is_data() && props.kind.is_expect() && !tipo.is_data() {
|
||||||
value = AirTree::cast_from_data(value, tipo.clone());
|
value = AirTree::cast_from_data(value, tipo.clone());
|
||||||
} else if !props.value_type.is_data() && tipo.is_data() {
|
} else if !props.value_type.is_data() && tipo.is_data() {
|
||||||
value = AirTree::cast_to_data(value, tipo.clone());
|
value = AirTree::cast_to_data(value, props.value_type.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
match pattern {
|
match pattern {
|
||||||
|
@ -2877,24 +2877,24 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_uplc(&mut self, ir: Air, arg_stack: &mut Vec<Term<Name>>) {
|
fn gen_uplc(&mut self, ir: Air, arg_stack: &mut Vec<Term<Name>>) {
|
||||||
|
// Going to mark the changes made to code gen after air tree implementation
|
||||||
match ir {
|
match ir {
|
||||||
Air::Int { value, .. } => {
|
Air::Int { value } => {
|
||||||
arg_stack.push(Term::integer(value.parse().unwrap()));
|
arg_stack.push(Term::integer(value.parse().unwrap()));
|
||||||
}
|
}
|
||||||
Air::String { value, .. } => {
|
Air::String { value } => {
|
||||||
arg_stack.push(Term::string(value));
|
arg_stack.push(Term::string(value));
|
||||||
}
|
}
|
||||||
Air::ByteArray { bytes, .. } => {
|
Air::ByteArray { bytes } => {
|
||||||
arg_stack.push(Term::byte_string(bytes));
|
arg_stack.push(Term::byte_string(bytes));
|
||||||
}
|
}
|
||||||
Air::Bool { value, .. } => {
|
Air::Bool { value } => {
|
||||||
arg_stack.push(Term::bool(value));
|
arg_stack.push(Term::bool(value));
|
||||||
}
|
}
|
||||||
Air::Var {
|
Air::Var {
|
||||||
name,
|
name,
|
||||||
constructor,
|
constructor,
|
||||||
variant_name,
|
variant_name,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
match &constructor.variant {
|
match &constructor.variant {
|
||||||
ValueConstructorVariant::LocalVariable { .. } => arg_stack.push(Term::Var(
|
ValueConstructorVariant::LocalVariable { .. } => arg_stack.push(Term::Var(
|
||||||
|
@ -2907,6 +2907,40 @@ impl<'a> CodeGenerator<'a> {
|
||||||
ValueConstructorVariant::ModuleConstant { .. } => {
|
ValueConstructorVariant::ModuleConstant { .. } => {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ValueConstructorVariant::ModuleFn {
|
||||||
|
builtin: Some(builtin),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
let term = match builtin {
|
||||||
|
DefaultFunction::IfThenElse
|
||||||
|
| DefaultFunction::ChooseUnit
|
||||||
|
| DefaultFunction::Trace
|
||||||
|
| DefaultFunction::ChooseList
|
||||||
|
| DefaultFunction::ChooseData
|
||||||
|
| DefaultFunction::UnConstrData => {
|
||||||
|
builder::special_case_builtin(builtin, 0, vec![])
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultFunction::FstPair
|
||||||
|
| DefaultFunction::SndPair
|
||||||
|
| DefaultFunction::HeadList => {
|
||||||
|
builder::undata_builtin(builtin, 0, &constructor.tipo, vec![])
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultFunction::MkCons | DefaultFunction::MkPairData => {
|
||||||
|
unimplemented!("MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z).\n")
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let mut term: Term<Name> = (*builtin).into();
|
||||||
|
|
||||||
|
term = builder::apply_builtin_forces(term, builtin.force_count());
|
||||||
|
|
||||||
|
term
|
||||||
|
}
|
||||||
|
};
|
||||||
|
arg_stack.push(term);
|
||||||
|
}
|
||||||
ValueConstructorVariant::ModuleFn {
|
ValueConstructorVariant::ModuleFn {
|
||||||
name: func_name,
|
name: func_name,
|
||||||
module,
|
module,
|
||||||
|
@ -3001,10 +3035,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Air::Void { .. } => arg_stack.push(Term::Constant(UplcConstant::Unit.into())),
|
Air::Void => arg_stack.push(Term::Constant(UplcConstant::Unit.into())),
|
||||||
Air::List {
|
Air::List { count, tipo, tail } => {
|
||||||
count, tipo, tail, ..
|
|
||||||
} => {
|
|
||||||
let mut args = vec![];
|
let mut args = vec![];
|
||||||
|
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
|
@ -3018,8 +3050,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let list_type = tipo.get_inner_types()[0].clone();
|
|
||||||
|
|
||||||
if constants.len() == args.len() && !tail {
|
if constants.len() == args.len() && !tail {
|
||||||
let list = if tipo.is_map() {
|
let list = if tipo.is_map() {
|
||||||
let mut convert_keys = vec![];
|
let mut convert_keys = vec![];
|
||||||
|
@ -3075,11 +3105,14 @@ impl<'a> CodeGenerator<'a> {
|
||||||
Term::empty_list()
|
Term::empty_list()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// move this down here since the constant list path doesn't need to do this
|
||||||
|
let list_element_type = tipo.get_inner_types()[0].clone();
|
||||||
|
|
||||||
for arg in args.into_iter().rev() {
|
for arg in args.into_iter().rev() {
|
||||||
let list_item = if tipo.is_map() {
|
let list_item = if tipo.is_map() {
|
||||||
arg
|
arg
|
||||||
} else {
|
} else {
|
||||||
builder::convert_type_to_data(arg, &list_type)
|
builder::convert_type_to_data(arg, &list_element_type)
|
||||||
};
|
};
|
||||||
term = Term::mk_cons().apply(list_item).apply(term);
|
term = Term::mk_cons().apply(list_item).apply(term);
|
||||||
}
|
}
|
||||||
|
@ -3089,9 +3122,11 @@ impl<'a> CodeGenerator<'a> {
|
||||||
Air::ListAccessor {
|
Air::ListAccessor {
|
||||||
names,
|
names,
|
||||||
tail,
|
tail,
|
||||||
|
// TODO: rename tipo -
|
||||||
|
// tipo here refers to the list type while the actual return
|
||||||
|
// type is nothing since this is an assignment over some expression
|
||||||
tipo,
|
tipo,
|
||||||
check_last_item,
|
check_last_item,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
@ -3129,8 +3164,9 @@ impl<'a> CodeGenerator<'a> {
|
||||||
Air::ListExpose {
|
Air::ListExpose {
|
||||||
tail_head_names,
|
tail_head_names,
|
||||||
tail,
|
tail,
|
||||||
|
// TODO: another case where tipo is not the actual return type,
|
||||||
|
// but the list type
|
||||||
tipo,
|
tipo,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3154,15 +3190,19 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::Fn { params, .. } => {
|
Air::Fn { params } => {
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
for param in params.iter().rev() {
|
for param in params.iter().rev() {
|
||||||
term = term.lambda(param);
|
term = term.lambda(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.is_empty() {
|
||||||
|
arg_stack.push(term.delay())
|
||||||
|
} else {
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Air::Call { count, .. } => {
|
Air::Call { count, .. } => {
|
||||||
if count >= 1 {
|
if count >= 1 {
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
@ -3177,23 +3217,27 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let term = arg_stack.pop().unwrap();
|
let term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
let zero_arg_functions = self.zero_arg_functions.clone();
|
let zero_arg_functions = self.zero_arg_functions.clone();
|
||||||
let mut anon_func = true;
|
|
||||||
|
|
||||||
if let Term::Var(name) = term.clone() {
|
// How we handle empty anon functions has changed
|
||||||
|
// We now delay zero arg anon functions and force them on a call operation
|
||||||
|
if let Term::Var(name) = &term {
|
||||||
let text = &name.text;
|
let text = &name.text;
|
||||||
|
|
||||||
for (
|
if let Some((_, air_vec)) = zero_arg_functions.iter().find(
|
||||||
|
|(
|
||||||
FunctionAccessKey {
|
FunctionAccessKey {
|
||||||
module_name,
|
module_name,
|
||||||
function_name,
|
function_name,
|
||||||
},
|
},
|
||||||
ir,
|
_,
|
||||||
) in zero_arg_functions.into_iter()
|
)| {
|
||||||
{
|
|
||||||
let name_module = format!("{module_name}_{function_name}");
|
let name_module = format!("{module_name}_{function_name}");
|
||||||
let name = function_name.to_string();
|
let name = function_name.to_string();
|
||||||
if text == &name || text == &name_module {
|
text == &name || text == &name_module
|
||||||
let mut term = self.uplc_code_gen(ir.clone());
|
},
|
||||||
|
) {
|
||||||
|
let mut term = self.uplc_code_gen(air_vec.clone());
|
||||||
|
|
||||||
term = term
|
term = term
|
||||||
.constr_get_field()
|
.constr_get_field()
|
||||||
.constr_fields_exposer()
|
.constr_fields_exposer()
|
||||||
|
@ -3208,25 +3252,21 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> = program.try_into().unwrap();
|
||||||
program.try_into().unwrap();
|
|
||||||
|
|
||||||
let evaluated_term: Term<NamedDeBruijn> =
|
let evaluated_term: Term<NamedDeBruijn> =
|
||||||
eval_program.eval(ExBudget::default()).result().unwrap();
|
eval_program.eval(ExBudget::max()).result().unwrap();
|
||||||
|
|
||||||
arg_stack.push(evaluated_term.try_into().unwrap());
|
arg_stack.push(evaluated_term.try_into().unwrap());
|
||||||
anon_func = false;
|
} else {
|
||||||
|
arg_stack.push(term.force())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unreachable!("Shouldn't call anything other than var")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if anon_func {
|
Air::Builtin { func, tipo, count } => {
|
||||||
arg_stack.push(term);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Air::Builtin {
|
|
||||||
func, tipo, count, ..
|
|
||||||
} => {
|
|
||||||
let mut arg_vec = vec![];
|
let mut arg_vec = vec![];
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
arg_vec.push(arg_stack.pop().unwrap());
|
arg_vec.push(arg_stack.pop().unwrap());
|
||||||
|
@ -3254,7 +3294,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultFunction::MkCons | DefaultFunction::MkPairData => {
|
DefaultFunction::MkCons | DefaultFunction::MkPairData => {
|
||||||
builder::to_data_builtin(&func, count, tipo, arg_vec)
|
unimplemented!("MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z).\n")
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let mut term: Term<Name> = func.into();
|
let mut term: Term<Name> = func.into();
|
||||||
|
@ -3271,7 +3311,12 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::BinOp { name, tipo, .. } => {
|
Air::BinOp {
|
||||||
|
name,
|
||||||
|
// changed this to argument tipo
|
||||||
|
argument_tipo: tipo,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
let left = arg_stack.pop().unwrap();
|
let left = arg_stack.pop().unwrap();
|
||||||
let right = arg_stack.pop().unwrap();
|
let right = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3416,7 +3461,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
recursive,
|
recursive,
|
||||||
module_name,
|
module_name,
|
||||||
variant_name,
|
variant_name,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let func_name = if module_name.is_empty() {
|
let func_name = if module_name.is_empty() {
|
||||||
format!("{func_name}{variant_name}")
|
format!("{func_name}{variant_name}")
|
||||||
|
@ -3447,7 +3491,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Air::Let { name, .. } => {
|
Air::Let { name } => {
|
||||||
let arg = arg_stack.pop().unwrap();
|
let arg = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
@ -3456,21 +3500,21 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::CastFromData { tipo, .. } => {
|
Air::CastFromData { tipo } => {
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
term = builder::convert_data_to_type(term, &tipo);
|
term = builder::convert_data_to_type(term, &tipo);
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::CastToData { tipo, .. } => {
|
Air::CastToData { tipo } => {
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
term = builder::convert_type_to_data(term, &tipo);
|
term = builder::convert_type_to_data(term, &tipo);
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::AssertConstr { constr_index, .. } => {
|
Air::AssertConstr { constr_index } => {
|
||||||
self.needs_field_access = true;
|
self.needs_field_access = true;
|
||||||
let constr = arg_stack.pop().unwrap();
|
let constr = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3489,7 +3533,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::AssertBool { is_true, .. } => {
|
Air::AssertBool { is_true } => {
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3507,7 +3551,10 @@ impl<'a> CodeGenerator<'a> {
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::When {
|
Air::When {
|
||||||
subject_name, tipo, ..
|
subject_name,
|
||||||
|
// using subject type here
|
||||||
|
subject_tipo: tipo,
|
||||||
|
..
|
||||||
} => {
|
} => {
|
||||||
let subject = arg_stack.pop().unwrap();
|
let subject = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3534,7 +3581,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
subject_tipo: tipo,
|
subject_tipo: tipo,
|
||||||
subject_name,
|
subject_name,
|
||||||
complex_clause,
|
complex_clause,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
// clause to compare
|
// clause to compare
|
||||||
let clause = arg_stack.pop().unwrap();
|
let clause = arg_stack.pop().unwrap();
|
||||||
|
@ -3608,9 +3654,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
complex_clause,
|
complex_clause,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
// discard to pop off
|
// no longer need to pop off discard
|
||||||
let _ = arg_stack.pop().unwrap();
|
|
||||||
|
|
||||||
let body = arg_stack.pop().unwrap();
|
let body = arg_stack.pop().unwrap();
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3633,9 +3677,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::WrapClause { .. } => {
|
Air::WrapClause => {
|
||||||
let _ = arg_stack.pop().unwrap();
|
// no longer need to pop off discard
|
||||||
|
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
let arg = arg_stack.pop().unwrap();
|
let arg = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3643,10 +3686,55 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
|
Air::TupleClause {
|
||||||
|
subject_tipo: tipo,
|
||||||
|
indices,
|
||||||
|
subject_name,
|
||||||
|
complex_clause,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
let tuple_types = tipo.get_inner_types();
|
||||||
|
|
||||||
|
if complex_clause {
|
||||||
|
let next_clause = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
term = term
|
||||||
|
.lambda("__other_clauses_delayed")
|
||||||
|
.apply(next_clause.delay());
|
||||||
|
}
|
||||||
|
|
||||||
|
if tuple_types.len() == 2 {
|
||||||
|
for (index, name) in indices.iter() {
|
||||||
|
let builtin = if *index == 0 {
|
||||||
|
Term::fst_pair()
|
||||||
|
} else {
|
||||||
|
Term::snd_pair()
|
||||||
|
};
|
||||||
|
|
||||||
|
term = term.lambda(name).apply(builder::convert_data_to_type(
|
||||||
|
builtin.apply(Term::var(subject_name.clone())),
|
||||||
|
&tuple_types[*index].clone(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (index, name) in indices.iter() {
|
||||||
|
term = term
|
||||||
|
.lambda(name.clone())
|
||||||
|
.apply(builder::convert_data_to_type(
|
||||||
|
Term::head_list().apply(
|
||||||
|
Term::var(subject_name.clone()).repeat_tail_list(*index),
|
||||||
|
),
|
||||||
|
&tuple_types[*index].clone(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arg_stack.push(term);
|
||||||
|
}
|
||||||
Air::ClauseGuard {
|
Air::ClauseGuard {
|
||||||
subject_name,
|
subject_name,
|
||||||
subject_tipo: tipo,
|
subject_tipo: tipo,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let checker = arg_stack.pop().unwrap();
|
let checker = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3695,8 +3783,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
inverse,
|
inverse,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
// discard to pop off
|
// no longer need to pop off discard
|
||||||
let _ = arg_stack.pop().unwrap();
|
|
||||||
|
|
||||||
// the body to be run if the clause matches
|
// the body to be run if the clause matches
|
||||||
// the next branch in the when expression
|
// the next branch in the when expression
|
||||||
|
@ -3721,7 +3808,43 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::Finally { .. } => {
|
Air::TupleGuard {
|
||||||
|
subject_tipo: tipo,
|
||||||
|
indices,
|
||||||
|
subject_name,
|
||||||
|
} => {
|
||||||
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
let tuple_types = tipo.get_inner_types();
|
||||||
|
|
||||||
|
if tuple_types.len() == 2 {
|
||||||
|
for (index, name) in indices.iter() {
|
||||||
|
let builtin = if *index == 0 {
|
||||||
|
Term::fst_pair()
|
||||||
|
} else {
|
||||||
|
Term::snd_pair()
|
||||||
|
};
|
||||||
|
|
||||||
|
term = term.lambda(name).apply(builder::convert_data_to_type(
|
||||||
|
builtin.apply(Term::var(subject_name.clone())),
|
||||||
|
&tuple_types[*index].clone(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (index, name) in indices.iter() {
|
||||||
|
term = term
|
||||||
|
.lambda(name.clone())
|
||||||
|
.apply(builder::convert_data_to_type(
|
||||||
|
Term::head_list().apply(
|
||||||
|
Term::var(subject_name.clone()).repeat_tail_list(*index),
|
||||||
|
),
|
||||||
|
&tuple_types[*index].clone(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
arg_stack.push(term);
|
||||||
|
}
|
||||||
|
Air::Finally => {
|
||||||
let _clause = arg_stack.pop().unwrap();
|
let _clause = arg_stack.pop().unwrap();
|
||||||
}
|
}
|
||||||
Air::If { .. } => {
|
Air::If { .. } => {
|
||||||
|
@ -3737,7 +3860,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
tag: constr_index,
|
tag: constr_index,
|
||||||
tipo,
|
tipo,
|
||||||
count,
|
count,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let mut arg_vec = vec![];
|
let mut arg_vec = vec![];
|
||||||
|
|
||||||
|
@ -3779,9 +3901,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::RecordAccess {
|
Air::RecordAccess { record_index, tipo } => {
|
||||||
record_index, tipo, ..
|
|
||||||
} => {
|
|
||||||
self.needs_field_access = true;
|
self.needs_field_access = true;
|
||||||
let constr = arg_stack.pop().unwrap();
|
let constr = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3796,7 +3916,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
Air::FieldsExpose {
|
Air::FieldsExpose {
|
||||||
indices,
|
indices,
|
||||||
check_last_item,
|
check_last_item,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
self.needs_field_access = true;
|
self.needs_field_access = true;
|
||||||
let mut id_list = vec![];
|
let mut id_list = vec![];
|
||||||
|
@ -3835,7 +3954,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::FieldsEmpty { .. } => {
|
Air::FieldsEmpty => {
|
||||||
self.needs_field_access = true;
|
self.needs_field_access = true;
|
||||||
|
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
|
@ -3853,7 +3972,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::ListEmpty { .. } => {
|
Air::ListEmpty => {
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
|
@ -3867,7 +3986,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::Tuple { tipo, count, .. } => {
|
Air::Tuple { tipo, count } => {
|
||||||
let mut args = vec![];
|
let mut args = vec![];
|
||||||
|
|
||||||
for _ in 0..count {
|
for _ in 0..count {
|
||||||
|
@ -3929,7 +4048,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
highest_index,
|
highest_index,
|
||||||
indices,
|
indices,
|
||||||
tipo,
|
tipo,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
self.needs_field_access = true;
|
self.needs_field_access = true;
|
||||||
let tail_name_prefix = "__tail_index";
|
let tail_name_prefix = "__tail_index";
|
||||||
|
@ -4016,7 +4134,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::UnOp { op, .. } => {
|
Air::UnOp { op } => {
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
let term = match op {
|
let term = match op {
|
||||||
|
@ -4040,9 +4158,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
|
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::TupleIndex {
|
Air::TupleIndex { tipo, tuple_index } => {
|
||||||
tipo, tuple_index, ..
|
|
||||||
} => {
|
|
||||||
let mut term = arg_stack.pop().unwrap();
|
let mut term = arg_stack.pop().unwrap();
|
||||||
|
|
||||||
if matches!(tipo.get_uplc_type(), UplcType::Pair(_, _)) {
|
if matches!(tipo.get_uplc_type(), UplcType::Pair(_, _)) {
|
||||||
|
@ -4073,7 +4189,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
tipo,
|
tipo,
|
||||||
names,
|
names,
|
||||||
check_last_item,
|
check_last_item,
|
||||||
..
|
|
||||||
} => {
|
} => {
|
||||||
let inner_types = tipo.get_inner_types();
|
let inner_types = tipo.get_inner_types();
|
||||||
let value = arg_stack.pop().unwrap();
|
let value = arg_stack.pop().unwrap();
|
||||||
|
@ -4128,59 +4243,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
arg_stack.push(term);
|
arg_stack.push(term);
|
||||||
}
|
}
|
||||||
Air::ErrorTerm { .. } => arg_stack.push(Term::Error),
|
Air::ErrorTerm { .. } => arg_stack.push(Term::Error),
|
||||||
Air::TupleClause {
|
Air::NoOp => {}
|
||||||
subject_tipo: tipo,
|
|
||||||
indices,
|
|
||||||
subject_name,
|
|
||||||
complex_clause,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
let mut term = arg_stack.pop().unwrap();
|
|
||||||
|
|
||||||
let tuple_types = tipo.get_inner_types();
|
|
||||||
|
|
||||||
if complex_clause {
|
|
||||||
let next_clause = arg_stack.pop().unwrap();
|
|
||||||
|
|
||||||
term = term
|
|
||||||
.lambda("__other_clauses_delayed")
|
|
||||||
.apply(next_clause.delay());
|
|
||||||
}
|
|
||||||
|
|
||||||
if tuple_types.len() == 2 {
|
|
||||||
for (index, name) in indices.iter() {
|
|
||||||
let builtin = if *index == 0 {
|
|
||||||
Term::fst_pair()
|
|
||||||
} else {
|
|
||||||
Term::snd_pair()
|
|
||||||
};
|
|
||||||
|
|
||||||
term = term.lambda(name).apply(builder::convert_data_to_type(
|
|
||||||
builtin.apply(Term::var(subject_name.clone())),
|
|
||||||
&tuple_types[*index].clone(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (index, name) in indices.iter() {
|
|
||||||
term = term
|
|
||||||
.lambda(name.clone())
|
|
||||||
.apply(builder::convert_data_to_type(
|
|
||||||
Term::head_list().apply(
|
|
||||||
Term::var(subject_name.clone()).repeat_tail_list(*index),
|
|
||||||
),
|
|
||||||
&tuple_types[*index].clone(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
arg_stack.push(term);
|
|
||||||
}
|
|
||||||
Air::NoOp { .. } => {}
|
|
||||||
Air::TupleGuard {
|
|
||||||
subject_tipo,
|
|
||||||
indices,
|
|
||||||
subject_name,
|
|
||||||
type_count,
|
|
||||||
} => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,6 @@ pub enum Air {
|
||||||
indices: IndexSet<(usize, String)>,
|
indices: IndexSet<(usize, String)>,
|
||||||
predefined_indices: IndexSet<(usize, String)>,
|
predefined_indices: IndexSet<(usize, String)>,
|
||||||
subject_name: String,
|
subject_name: String,
|
||||||
count: usize,
|
|
||||||
complex_clause: bool,
|
complex_clause: bool,
|
||||||
},
|
},
|
||||||
ClauseGuard {
|
ClauseGuard {
|
||||||
|
@ -122,7 +121,6 @@ pub enum Air {
|
||||||
subject_tipo: Arc<Type>,
|
subject_tipo: Arc<Type>,
|
||||||
indices: IndexSet<(usize, String)>,
|
indices: IndexSet<(usize, String)>,
|
||||||
subject_name: String,
|
subject_name: String,
|
||||||
type_count: usize,
|
|
||||||
},
|
},
|
||||||
Finally,
|
Finally,
|
||||||
// If
|
// If
|
||||||
|
|
|
@ -157,7 +157,6 @@ pub enum AirStatement {
|
||||||
subject_tipo: Arc<Type>,
|
subject_tipo: Arc<Type>,
|
||||||
indices: IndexSet<(usize, String)>,
|
indices: IndexSet<(usize, String)>,
|
||||||
subject_name: String,
|
subject_name: String,
|
||||||
type_count: usize,
|
|
||||||
},
|
},
|
||||||
// Field Access
|
// Field Access
|
||||||
FieldsExpose {
|
FieldsExpose {
|
||||||
|
@ -290,7 +289,6 @@ pub enum AirExpression {
|
||||||
indices: IndexSet<(usize, String)>,
|
indices: IndexSet<(usize, String)>,
|
||||||
predefined_indices: IndexSet<(usize, String)>,
|
predefined_indices: IndexSet<(usize, String)>,
|
||||||
subject_name: String,
|
subject_name: String,
|
||||||
type_count: usize,
|
|
||||||
complex_clause: bool,
|
complex_clause: bool,
|
||||||
then: Box<AirTree>,
|
then: Box<AirTree>,
|
||||||
otherwise: Box<AirTree>,
|
otherwise: Box<AirTree>,
|
||||||
|
@ -566,14 +564,11 @@ impl AirTree {
|
||||||
otherwise: AirTree,
|
otherwise: AirTree,
|
||||||
complex_clause: bool,
|
complex_clause: bool,
|
||||||
) -> AirTree {
|
) -> AirTree {
|
||||||
let type_count = subject_tipo.get_inner_types().len();
|
|
||||||
|
|
||||||
AirTree::Expression(AirExpression::TupleClause {
|
AirTree::Expression(AirExpression::TupleClause {
|
||||||
subject_tipo,
|
subject_tipo,
|
||||||
indices,
|
indices,
|
||||||
predefined_indices,
|
predefined_indices,
|
||||||
subject_name: subject_name.to_string(),
|
subject_name: subject_name.to_string(),
|
||||||
type_count,
|
|
||||||
complex_clause,
|
complex_clause,
|
||||||
then: then.into(),
|
then: then.into(),
|
||||||
otherwise: otherwise.into(),
|
otherwise: otherwise.into(),
|
||||||
|
@ -624,7 +619,6 @@ impl AirTree {
|
||||||
statement: AirStatement::TupleGuard {
|
statement: AirStatement::TupleGuard {
|
||||||
indices,
|
indices,
|
||||||
subject_name: subject_name.to_string(),
|
subject_name: subject_name.to_string(),
|
||||||
type_count: subject_tipo.get_inner_types().len(),
|
|
||||||
subject_tipo,
|
subject_tipo,
|
||||||
},
|
},
|
||||||
hoisted_over: None,
|
hoisted_over: None,
|
||||||
|
@ -915,13 +909,11 @@ impl AirTree {
|
||||||
subject_tipo,
|
subject_tipo,
|
||||||
indices,
|
indices,
|
||||||
subject_name,
|
subject_name,
|
||||||
type_count,
|
|
||||||
} => {
|
} => {
|
||||||
air_vec.push(Air::TupleGuard {
|
air_vec.push(Air::TupleGuard {
|
||||||
subject_tipo: subject_tipo.clone(),
|
subject_tipo: subject_tipo.clone(),
|
||||||
indices: indices.clone(),
|
indices: indices.clone(),
|
||||||
subject_name: subject_name.clone(),
|
subject_name: subject_name.clone(),
|
||||||
type_count: *type_count,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
AirStatement::FieldsExpose {
|
AirStatement::FieldsExpose {
|
||||||
|
@ -1133,7 +1125,6 @@ impl AirTree {
|
||||||
indices,
|
indices,
|
||||||
predefined_indices,
|
predefined_indices,
|
||||||
subject_name,
|
subject_name,
|
||||||
type_count,
|
|
||||||
complex_clause,
|
complex_clause,
|
||||||
then,
|
then,
|
||||||
otherwise,
|
otherwise,
|
||||||
|
@ -1143,7 +1134,6 @@ impl AirTree {
|
||||||
indices: indices.clone(),
|
indices: indices.clone(),
|
||||||
predefined_indices: predefined_indices.clone(),
|
predefined_indices: predefined_indices.clone(),
|
||||||
subject_name: subject_name.clone(),
|
subject_name: subject_name.clone(),
|
||||||
count: *type_count,
|
|
||||||
complex_clause: *complex_clause,
|
complex_clause: *complex_clause,
|
||||||
});
|
});
|
||||||
then.create_air_vec(air_vec);
|
then.create_air_vec(air_vec);
|
||||||
|
|
|
@ -36,6 +36,13 @@ impl ExBudget {
|
||||||
cpu: 10000000000,
|
cpu: 10000000000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn max() -> Self {
|
||||||
|
ExBudget {
|
||||||
|
mem: 14000000000,
|
||||||
|
cpu: 10000000000000,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ExBudget {
|
impl Default for ExBudget {
|
||||||
|
|
Loading…
Reference in New Issue