Reuse "convert_tag_to_constr"

This commit is contained in:
Niels Mündler 2023-12-31 11:56:45 +01:00 committed by Kasey
parent cda1716d47
commit f934e87b1d
1 changed files with 4 additions and 8 deletions

View File

@ -1,7 +1,7 @@
use crate::{
ast::{Constant, Program, Term, Type},
flat::Binder,
machine::runtime::Compressable,
machine::runtime::{convert_tag_to_constr, Compressable},
machine::value::from_pallas_bigint,
};
use pallas_primitives::babbage::{Constr, PlutusData};
@ -317,15 +317,11 @@ impl Constant {
tag,
any_constructor,
fields,
..
}) => RcDoc::text("Constr")
.append(RcDoc::space())
.append(RcDoc::as_string(match tag {
121..=127 => tag - 121,
1280..=1400 => tag - 1280 + 7,
102 => any_constructor.unwrap(),
_ => panic!("unknown tag {}", tag),
}))
.append(RcDoc::as_string(
convert_tag_to_constr(*tag).unwrap_or_else(|| any_constructor.unwrap()),
))
.append(RcDoc::space())
.append(RcDoc::text("["))
.append(RcDoc::intersperse(