Skip to content

Commit 12a9c5a

Browse files
committed
add StackOperand::ty getter method
1 parent b834be0 commit 12a9c5a

File tree

1 file changed

+11
-0
lines changed
  • crates/wasmi/src/engine/translator/func2/stack

1 file changed

+11
-0
lines changed

crates/wasmi/src/engine/translator/func2/stack/operands.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ pub enum StackOperand {
5555
},
5656
}
5757

58+
impl StackOperand {
59+
/// Returns the [`ValType`] of the [`StackOperand`].
60+
pub fn ty(&self, locals: &LocalsRegistry) -> ValType {
61+
match self {
62+
StackOperand::Temp { ty, .. } => *ty,
63+
StackOperand::Immediate { val } => val.ty(),
64+
StackOperand::Local { local_index, .. } => locals.ty(*local_index),
65+
}
66+
}
67+
}
68+
5869
/// The Wasm operand (or value) stack.
5970
#[derive(Debug, Default)]
6071
pub struct OperandStack {

0 commit comments

Comments
 (0)