Start working on separating pairs from 2 tuples in Aiken
co-authored-by: KtorZ <matthias.benkort@gmail.com>
This commit is contained in:
@@ -762,7 +762,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
TypedExpr::TupleIndex {
|
||||
index, tuple, tipo, ..
|
||||
} => {
|
||||
if tuple.tipo().is_2_tuple() {
|
||||
if tuple.tipo().is_pair() {
|
||||
AirTree::pair_index(
|
||||
*index,
|
||||
tipo.clone(),
|
||||
@@ -1486,7 +1486,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
|
||||
AirTree::let_assignment(&list_name, value, func_call)
|
||||
}
|
||||
} else if tipo.is_2_tuple() {
|
||||
} else if tipo.is_pair() {
|
||||
let tuple_inner_types = tipo.get_inner_types();
|
||||
|
||||
assert!(tuple_inner_types.len() == 2);
|
||||
@@ -3833,7 +3833,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
}
|
||||
|
||||
DefaultFunction::HeadList
|
||||
if !constructor.tipo.return_type().unwrap().is_2_tuple() =>
|
||||
if !constructor.tipo.return_type().unwrap().is_pair() =>
|
||||
{
|
||||
builder::undata_builtin(
|
||||
builtin,
|
||||
@@ -4249,7 +4249,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
builder::undata_builtin(&func, count, tipo, arg_vec)
|
||||
}
|
||||
|
||||
DefaultFunction::HeadList if !tipo.is_2_tuple() => {
|
||||
DefaultFunction::HeadList if !tipo.is_pair() => {
|
||||
builder::undata_builtin(&func, count, tipo, arg_vec)
|
||||
}
|
||||
|
||||
@@ -4310,15 +4310,14 @@ impl<'a> CodeGenerator<'a> {
|
||||
);
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_map() {
|
||||
}
|
||||
if tipo.is_map() {
|
||||
let term = builtin
|
||||
.apply(Term::map_data().apply(left))
|
||||
.apply(Term::map_data().apply(right));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_tuple()
|
||||
&& matches!(tipo.get_uplc_type(), UplcType::Pair(_, _))
|
||||
{
|
||||
}
|
||||
if tipo.is_pair() {
|
||||
let term = builtin
|
||||
.apply(Term::map_data().apply(
|
||||
Term::mk_cons().apply(left).apply(Term::empty_map()),
|
||||
@@ -4326,15 +4325,16 @@ impl<'a> CodeGenerator<'a> {
|
||||
.apply(Term::map_data().apply(
|
||||
Term::mk_cons().apply(right).apply(Term::empty_map()),
|
||||
));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_list() || tipo.is_tuple() {
|
||||
}
|
||||
if tipo.is_list() || tipo.is_tuple() {
|
||||
let term = builtin
|
||||
.apply(Term::list_data().apply(left))
|
||||
.apply(Term::list_data().apply(right));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_void() {
|
||||
}
|
||||
if tipo.is_void() {
|
||||
let term = left.choose_unit(right.choose_unit(Term::bool(true)));
|
||||
|
||||
return Some(term);
|
||||
@@ -4352,16 +4352,16 @@ impl<'a> CodeGenerator<'a> {
|
||||
);
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_map() {
|
||||
}
|
||||
if tipo.is_map() {
|
||||
let term = builtin
|
||||
.apply(Term::map_data().apply(left))
|
||||
.apply(Term::map_data().apply(right))
|
||||
.if_then_else(Term::bool(false), Term::bool(true));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_tuple()
|
||||
&& matches!(tipo.get_uplc_type(), UplcType::Pair(_, _))
|
||||
{
|
||||
}
|
||||
if tipo.is_pair() {
|
||||
let term = builtin
|
||||
.apply(Term::map_data().apply(
|
||||
Term::mk_cons().apply(left).apply(Term::empty_map()),
|
||||
@@ -4370,16 +4370,16 @@ impl<'a> CodeGenerator<'a> {
|
||||
Term::mk_cons().apply(right).apply(Term::empty_map()),
|
||||
))
|
||||
.if_then_else(Term::bool(false), Term::bool(true));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_list() || tipo.is_tuple() {
|
||||
}
|
||||
if tipo.is_list() || tipo.is_tuple() {
|
||||
let term = builtin
|
||||
.apply(Term::list_data().apply(left))
|
||||
.apply(Term::list_data().apply(right))
|
||||
.if_then_else(Term::bool(false), Term::bool(true));
|
||||
|
||||
return Some(term);
|
||||
} else if tipo.is_void() {
|
||||
}
|
||||
if tipo.is_void() {
|
||||
return Some(Term::bool(false));
|
||||
}
|
||||
|
||||
@@ -4642,9 +4642,14 @@ impl<'a> CodeGenerator<'a> {
|
||||
|| tipo.is_string()
|
||||
|| tipo.is_list()
|
||||
|| tipo.is_tuple()
|
||||
|| tipo.is_pair()
|
||||
|| tipo.is_bool()
|
||||
|| tipo.is_bls381_12_g1()
|
||||
|| tipo.is_bls381_12_g2()
|
||||
{
|
||||
subject
|
||||
} else if tipo.is_ml_result() {
|
||||
unreachable!()
|
||||
} else {
|
||||
Term::var(
|
||||
self.special_functions
|
||||
@@ -4709,7 +4714,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
Term::equals_string()
|
||||
.apply(clause)
|
||||
.apply(Term::var(subject_name))
|
||||
} else if tipo.is_list() || tipo.is_tuple() {
|
||||
} else if tipo.is_list() || tipo.is_tuple() || tipo.is_pair() {
|
||||
unreachable!("{:#?}", tipo)
|
||||
} else {
|
||||
Term::equals_integer()
|
||||
@@ -4787,7 +4792,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
.apply(next_clause.delay());
|
||||
}
|
||||
|
||||
if tipo.is_2_tuple() {
|
||||
if tipo.is_pair() {
|
||||
for (index, name) in indices.iter() {
|
||||
if name == "_" {
|
||||
continue;
|
||||
@@ -5256,7 +5261,7 @@ impl<'a> CodeGenerator<'a> {
|
||||
let mut term = arg_stack.pop().unwrap();
|
||||
let list_id = self.id_gen.next();
|
||||
|
||||
if tipo.is_2_tuple() {
|
||||
if tipo.is_pair() {
|
||||
assert!(names.len() == 2);
|
||||
|
||||
if names[1] != "_" {
|
||||
|
||||
Reference in New Issue
Block a user