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