Make sure clean up doesn't add case and constr to comp time eval. Also had fun with test_1 mint script context validator
This commit is contained in:
parent
33392f1532
commit
2c214186b6
|
@ -3712,7 +3712,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> =
|
||||||
program.clean_up().try_into().unwrap();
|
program.clean_up(false).try_into().unwrap();
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
eval_program
|
eval_program
|
||||||
|
@ -3822,7 +3822,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> =
|
||||||
program.clean_up().try_into().unwrap();
|
program.clean_up(false).try_into().unwrap();
|
||||||
|
|
||||||
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
||||||
.eval(ExBudget::default())
|
.eval(ExBudget::default())
|
||||||
|
@ -4364,7 +4364,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> =
|
||||||
program.clean_up().try_into().unwrap();
|
program.clean_up(false).try_into().unwrap();
|
||||||
|
|
||||||
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
||||||
.eval(ExBudget::default())
|
.eval(ExBudget::default())
|
||||||
|
@ -4389,7 +4389,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> =
|
||||||
program.clean_up().try_into().unwrap();
|
program.clean_up(false).try_into().unwrap();
|
||||||
|
|
||||||
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
||||||
.eval(ExBudget::default())
|
.eval(ExBudget::default())
|
||||||
|
@ -4802,7 +4802,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
interner.program(&mut program);
|
interner.program(&mut program);
|
||||||
|
|
||||||
let eval_program: Program<NamedDeBruijn> =
|
let eval_program: Program<NamedDeBruijn> =
|
||||||
program.clean_up().try_into().unwrap();
|
program.clean_up(false).try_into().unwrap();
|
||||||
|
|
||||||
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
let evaluated_term: Term<NamedDeBruijn> = eval_program
|
||||||
.eval(ExBudget::default())
|
.eval(ExBudget::default())
|
||||||
|
|
|
@ -38,5 +38,5 @@ pub fn aiken_optimize_and_intern(program: Program<Name>) -> Program<Name> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prog.clean_up()
|
prog.clean_up(true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -984,9 +984,6 @@ impl Term<Name> {
|
||||||
inline_lambda,
|
inline_lambda,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Term::Constr { .. } => todo!(),
|
|
||||||
Term::Case { .. } => todo!(),
|
|
||||||
other => other.traverse_uplc_with_helper(
|
other => other.traverse_uplc_with_helper(
|
||||||
scope,
|
scope,
|
||||||
arg_stack,
|
arg_stack,
|
||||||
|
@ -1012,8 +1009,40 @@ impl Term<Name> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Term::Case { .. } => todo!(),
|
Term::Case { constr, branches } => {
|
||||||
Term::Constr { .. } => todo!(),
|
let constr = Rc::make_mut(constr);
|
||||||
|
constr.traverse_uplc_with_helper(
|
||||||
|
scope,
|
||||||
|
vec![],
|
||||||
|
id_gen,
|
||||||
|
with,
|
||||||
|
context,
|
||||||
|
inline_lambda,
|
||||||
|
);
|
||||||
|
|
||||||
|
for branch in branches {
|
||||||
|
branch.traverse_uplc_with_helper(
|
||||||
|
scope,
|
||||||
|
arg_stack.clone(),
|
||||||
|
id_gen,
|
||||||
|
with,
|
||||||
|
context,
|
||||||
|
inline_lambda,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Term::Constr { fields, .. } => {
|
||||||
|
for field in fields {
|
||||||
|
field.traverse_uplc_with_helper(
|
||||||
|
scope,
|
||||||
|
vec![],
|
||||||
|
id_gen,
|
||||||
|
with,
|
||||||
|
context,
|
||||||
|
inline_lambda,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Term::Builtin(func) => {
|
Term::Builtin(func) => {
|
||||||
let mut args = vec![];
|
let mut args = vec![];
|
||||||
|
@ -2051,10 +2080,12 @@ impl Program<Name> {
|
||||||
.0
|
.0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clean_up(self) -> Self {
|
pub fn clean_up(self, case: bool) -> Self {
|
||||||
self.traverse_uplc_with(true, &mut |id, term, _arg_stack, scope, context| {
|
self.traverse_uplc_with(true, &mut |id, term, _arg_stack, scope, context| {
|
||||||
term.remove_no_inlines(id, vec![], scope, context);
|
term.remove_no_inlines(id, vec![], scope, context);
|
||||||
term.case_constr_apply_reducer(id, vec![], scope, context);
|
if case {
|
||||||
|
term.case_constr_apply_reducer(id, vec![], scope, context);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.0
|
.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ fn assert_outputs(
|
||||||
},
|
},
|
||||||
) == list.at(outputs, 0)
|
) == list.at(outputs, 0)
|
||||||
|
|
||||||
|
trace @"This test validator has a higher hash than the one below. Change and try again."
|
||||||
|
|
||||||
expect
|
expect
|
||||||
Some(
|
Some(
|
||||||
Output {
|
Output {
|
||||||
|
@ -134,7 +136,7 @@ fn assert_mint(mint: Value, our_policy_id: PolicyId, other_policy_id: PolicyId)
|
||||||
///
|
///
|
||||||
validator test_2 {
|
validator test_2 {
|
||||||
mint(_tmp2: Void, _policy_id: PolicyId, _transaction: Transaction) {
|
mint(_tmp2: Void, _policy_id: PolicyId, _transaction: Transaction) {
|
||||||
trace @"slfhioer7w8yru"
|
trace @"slhhioer7w8ypuga"
|
||||||
True
|
True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue