validator params are now converted to type from data
This commit is contained in:
parent
d5d878e83c
commit
306fa891a0
|
@ -7,7 +7,7 @@ use std::{
|
|||
use indexmap::IndexMap;
|
||||
use itertools::Itertools;
|
||||
use uplc::{
|
||||
ast::{Constant as UplcConstant, Name, Term, Type as UplcType},
|
||||
ast::{builder::apply_wrap, Constant as UplcConstant, Name, Term, Type as UplcType},
|
||||
builtins::DefaultFunction,
|
||||
machine::runtime::convert_constr_to_tag,
|
||||
BigInt, Constr, KeyValuePairs, PlutusData,
|
||||
|
@ -15,7 +15,7 @@ use uplc::{
|
|||
|
||||
use crate::{
|
||||
air::Air,
|
||||
ast::{Clause, Constant, Pattern, Span},
|
||||
ast::{Clause, Constant, Pattern, Span, TypedArg},
|
||||
expr::TypedExpr,
|
||||
tipo::{PatternConstructor, Type, TypeVar, ValueConstructorVariant},
|
||||
};
|
||||
|
@ -1051,6 +1051,39 @@ pub fn convert_constants_to_data(constants: Vec<UplcConstant>) -> Vec<UplcConsta
|
|||
new_constants
|
||||
}
|
||||
|
||||
pub fn wrap_validator_args(term: Term<Name>, arguments: Vec<TypedArg>) -> Term<Name> {
|
||||
let mut term = term;
|
||||
for arg in arguments.iter().rev() {
|
||||
if !matches!(arg.tipo.get_uplc_type(), UplcType::Data) {
|
||||
term = apply_wrap(
|
||||
Term::Lambda {
|
||||
parameter_name: Name {
|
||||
text: arg.arg_name.get_variable_name().unwrap_or("_").to_string(),
|
||||
unique: 0.into(),
|
||||
},
|
||||
body: term.into(),
|
||||
},
|
||||
convert_data_to_type(
|
||||
Term::Var(Name {
|
||||
text: arg.arg_name.get_variable_name().unwrap_or("_").to_string(),
|
||||
unique: 0.into(),
|
||||
}),
|
||||
&arg.tipo,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
term = Term::Lambda {
|
||||
parameter_name: Name {
|
||||
text: arg.arg_name.get_variable_name().unwrap_or("_").to_string(),
|
||||
unique: 0.into(),
|
||||
},
|
||||
body: term.into(),
|
||||
}
|
||||
}
|
||||
term
|
||||
}
|
||||
|
||||
pub fn monomorphize(
|
||||
ir: Vec<Air>,
|
||||
generic_types: HashMap<u64, Arc<Type>>,
|
||||
|
|
|
@ -30,7 +30,8 @@ use crate::{
|
|||
check_when_pattern_needs, constants_ir, convert_constants_to_data, convert_data_to_type,
|
||||
convert_type_to_data, get_common_ancestor, get_generics_and_type, get_variant_name,
|
||||
handle_func_deps_ir, list_access_to_uplc, match_ir_for_recursion, monomorphize,
|
||||
rearrange_clauses, ClauseProperties, DataTypeKey, FuncComponents, FunctionAccessKey,
|
||||
rearrange_clauses, wrap_validator_args, ClauseProperties, DataTypeKey, FuncComponents,
|
||||
FunctionAccessKey,
|
||||
},
|
||||
expr::TypedExpr,
|
||||
tipo::{
|
||||
|
@ -104,15 +105,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
term
|
||||
};
|
||||
|
||||
for arg in arguments.iter().rev() {
|
||||
term = Term::Lambda {
|
||||
parameter_name: uplc::ast::Name {
|
||||
text: arg.arg_name.get_variable_name().unwrap_or("_").to_string(),
|
||||
unique: 0.into(),
|
||||
},
|
||||
body: term.into(),
|
||||
}
|
||||
}
|
||||
term = wrap_validator_args(term, arguments);
|
||||
|
||||
let mut program = Program {
|
||||
version: (1, 0, 0),
|
||||
|
@ -3921,7 +3914,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
let term = Term::Apply {
|
||||
function: Term::Apply {
|
||||
function: Term::Builtin(DefaultFunction::Trace).force_wrap().into(),
|
||||
argument: Term::Constant(uplc::ast::Constant::String(
|
||||
argument: Term::Constant(UplcConstant::String(
|
||||
label.unwrap_or_else(|| "aiken::todo".to_string()),
|
||||
))
|
||||
.into(),
|
||||
|
|
Loading…
Reference in New Issue