Merge pull request #208 from aiken-lang/tuple-when2

fix todo and list and tuple not equal operator
This commit is contained in:
Matthias Benkort 2022-12-22 10:28:06 +01:00 committed by GitHub
commit a129a8a0d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 70 additions and 74 deletions

View File

@ -2678,63 +2678,63 @@ impl<'a> CodeGenerator<'a> {
} else if tipo.is_tuple() } else if tipo.is_tuple()
&& matches!(tipo.clone().get_uplc_type(), UplcType::Pair(_, _)) && matches!(tipo.clone().get_uplc_type(), UplcType::Pair(_, _))
{ {
// let term = Term::Apply { let mut term = Term::Apply {
// function: Term::Apply {
// function: default_builtin.into(),
// argument: Term::Apply {
// function: DefaultFunction::MapData.into(),
// argument: Term::Apply {
// function: Term::Apply {
// function: Term::Builtin(DefaultFunction::MkCons)
// .force_wrap()
// .into(),
// argument: left.into(),
// }
// .into(),
// argument: Term::Constant(UplcConstant::ProtoList(
// UplcType::Pair(
// UplcType::Data.into(),
// UplcType::Data.into(),
// ),
// vec![],
// ))
// .into(),
// }
// .into(),
// }
// .into(),
// }
// .into(),
// argument: Term::Apply {
// function: Term::Apply {
// function: Term::Builtin(DefaultFunction::MkCons)
// .force_wrap()
// .into(),
// argument: right.into(),
// }
// .into(),
// argument: Term::Constant(UplcConstant::ProtoList(
// UplcType::Pair(
// UplcType::Data.into(),
// UplcType::Data.into(),
// ),
// vec![],
// ))
// .into(),
// }
// .into(),
// };
// arg_stack.push(term);
// return;
todo!()
} else if tipo.is_list() {
let term = Term::Apply {
function: Term::Apply { function: Term::Apply {
function: default_builtin.into(),
argument: Term::Apply {
function: DefaultFunction::MapData.into(),
argument: Term::Apply {
function: Term::Apply { function: Term::Apply {
function: Term::Builtin(DefaultFunction::IfThenElse) function: Term::Builtin(DefaultFunction::MkCons)
.force_wrap() .force_wrap()
.into(), .into(),
argument: left.into(),
}
.into(),
argument: Term::Constant(UplcConstant::ProtoList(
UplcType::Pair(
UplcType::Data.into(),
UplcType::Data.into(),
),
vec![],
))
.into(),
}
.into(),
}
.into(),
}
.into(),
argument: Term::Apply { argument: Term::Apply {
function: Term::Apply {
function: Term::Builtin(DefaultFunction::MkCons)
.force_wrap()
.into(),
argument: right.into(),
}
.into(),
argument: Term::Constant(UplcConstant::ProtoList(
UplcType::Pair(
UplcType::Data.into(),
UplcType::Data.into(),
),
vec![],
))
.into(),
}
.into(),
};
term = if_else(
term,
Term::Constant(UplcConstant::Bool(false)),
Term::Constant(UplcConstant::Bool(true)),
);
arg_stack.push(term);
return;
} else if tipo.is_list() {
let term = if_else(
Term::Apply {
function: Term::Apply { function: Term::Apply {
function: default_builtin.into(), function: default_builtin.into(),
argument: Term::Apply { argument: Term::Apply {
@ -2753,15 +2753,10 @@ impl<'a> CodeGenerator<'a> {
.into(), .into(),
} }
.into(), .into(),
} },
.into(), Term::Constant(UplcConstant::Bool(false)),
} Term::Constant(UplcConstant::Bool(true)),
.into(), );
argument: Term::Constant(UplcConstant::Bool(false)).into(),
}
.into(),
argument: Term::Constant(UplcConstant::Bool(true)).into(),
};
arg_stack.push(term); arg_stack.push(term);
return; return;
@ -3545,8 +3540,9 @@ impl<'a> CodeGenerator<'a> {
.into(), .into(),
} }
.into(), .into(),
argument: Term::Error.into(), argument: Term::Delay(Term::Error.into()).into(),
}; }
.force_wrap();
arg_stack.push(term); arg_stack.push(term);
} }
@ -3716,7 +3712,7 @@ impl<'a> CodeGenerator<'a> {
function: Term::Apply { function: Term::Apply {
function: Term::Builtin(DefaultFunction::Trace).force_wrap().into(), function: Term::Builtin(DefaultFunction::Trace).force_wrap().into(),
argument: Term::Constant(UplcConstant::String( argument: Term::Constant(UplcConstant::String(
text.unwrap_or_else(|| "aike::trace".to_string()), text.unwrap_or_else(|| "aiken::trace".to_string()),
)) ))
.into(), .into(),
} }