From 1dee4d1318be735587ef361548a788004c2ff028 Mon Sep 17 00:00:00 2001 From: nerodesu017 Date: Mon, 18 Nov 2024 12:49:05 +0200 Subject: [PATCH] fix: DROP opcode Signed-off-by: nerodesu017 --- src/validation/validation_stack.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/validation/validation_stack.rs b/src/validation/validation_stack.rs index a692ae40..7a327ddd 100644 --- a/src/validation/validation_stack.rs +++ b/src/validation/validation_stack.rs @@ -32,6 +32,15 @@ impl ValidationStack { self.stack.push(ValidationStackEntry::Label(label_info)); } + /// Similar to [`ValidationStack::pop`], because it pops a value from the stack, + /// but more public and doesn't actually return the popped value. + pub(super) fn drop_val(&mut self) -> Result<()> { + match self.stack.pop().ok_or(Error::EndInvalidValueStack)? { + ValidationStackEntry::Val(_) => Ok(()), + _ => Err(Error::ExpectedAnOperand), + } + } + /// This puts an unspecified element on top of the stack. /// While the top of the stack is unspecified, arbitrary value types can be popped. /// To undo this, a new label has to be pushed or an existing one has to be popped.