From 0eefaef2a656769f3243768b81fb3b1f56eac2ce Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Thu, 14 Sep 2023 17:09:30 +0300 Subject: [PATCH] pretty printer for ByteArrayTo* IR nodes; --- ergotree-ir/src/pretty_printer/print.rs | 30 +++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ergotree-ir/src/pretty_printer/print.rs b/ergotree-ir/src/pretty_printer/print.rs index fd58cda8c..99994369d 100644 --- a/ergotree-ir/src/pretty_printer/print.rs +++ b/ergotree-ir/src/pretty_printer/print.rs @@ -4,6 +4,8 @@ use crate::mir::apply::Apply; use crate::mir::bin_op::BinOp; use crate::mir::block::BlockValue; use crate::mir::bool_to_sigma::BoolToSigmaProp; +use crate::mir::byte_array_to_bigint::ByteArrayToBigInt; +use crate::mir::byte_array_to_long::ByteArrayToLong; use crate::mir::calc_blake2b256::CalcBlake2b256; use crate::mir::coll_append::Append; use crate::mir::coll_by_index::ByIndex; @@ -74,8 +76,8 @@ impl Print for Expr { Expr::ByIndex(v) => v.expr().print(w), Expr::ConstPlaceholder(_) => Ok(self.clone()), Expr::SubstConstants(_) => todo!(), - Expr::ByteArrayToLong(_) => todo!(), - Expr::ByteArrayToBigInt(_) => todo!(), + Expr::ByteArrayToLong(v) => v.expr().print(w), + Expr::ByteArrayToBigInt(v) => v.expr().print(w), Expr::LongToByteArray(_) => todo!(), Expr::Collection(v) => v.print(w), Expr::Tuple(v) => v.print(w), @@ -719,4 +721,28 @@ impl Print for ExtractBytes { } .into()) } +} + +impl Print for ByteArrayToLong { + fn print(&self, w: &mut dyn Printer) -> Result { + write!(w, "byteArrayToLong(")?; + let input = self.input.print(w)?; + write!(w, ")")?; + Ok(ByteArrayToLong { + input: Box::new(input), + } + .into()) + } +} + +impl Print for ByteArrayToBigInt { + fn print(&self, w: &mut dyn Printer) -> Result { + write!(w, "byteArrayToBigInt(")?; + let input = self.input.print(w)?; + write!(w, ")")?; + Ok(ByteArrayToBigInt { + input: Box::new(input), + } + .into()) + } } \ No newline at end of file