Skip to content

Commit 44cb9fa

Browse files
committed
use ControlFrameBase to generalize end_if translation
1 parent 0212977 commit 44cb9fa

File tree

1 file changed

+12
-7
lines changed
  • crates/wasmi/src/engine/translator/func2

1 file changed

+12
-7
lines changed

crates/wasmi/src/engine/translator/func2/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ impl FuncTranslator {
457457
fn translate_end_if(&mut self, frame: IfControlFrame) -> Result<(), Error> {
458458
debug_assert!(!self.stack.is_control_empty());
459459
let IfReachability::Both { else_label } = frame.reachability() else {
460-
return self.translate_end_if_then_or_else_only(frame);
460+
let reachability = frame.reachability().into();
461+
return self.translate_end_if_or_else_only(frame, reachability);
461462
};
462463
let end_of_then_reachable = self.reachable;
463464
let len_results = frame.ty().len_results(self.engine());
@@ -481,12 +482,16 @@ impl FuncTranslator {
481482
Ok(())
482483
}
483484

484-
/// Translates the end of a Wasm `if` control frame where only one branch is known to be reachable.
485-
fn translate_end_if_then_or_else_only(&mut self, frame: IfControlFrame) -> Result<(), Error> {
486-
let end_is_reachable = match frame.reachability() {
487-
IfReachability::OnlyThen => self.reachable,
488-
IfReachability::OnlyElse => true,
489-
IfReachability::Both { .. } => unreachable!(),
485+
/// Translates the end of a Wasm `else` control frame where only one branch is known to be reachable.
486+
fn translate_end_if_or_else_only(
487+
&mut self,
488+
frame: impl ControlFrameBase,
489+
reachability: ElseReachability,
490+
) -> Result<(), Error> {
491+
let end_is_reachable = match reachability {
492+
ElseReachability::OnlyThen => self.reachable,
493+
ElseReachability::OnlyElse => true,
494+
ElseReachability::Both => unreachable!(),
490495
};
491496
if end_is_reachable && frame.is_branched_to() {
492497
let len_values = frame.len_branch_params(&self.engine);

0 commit comments

Comments
 (0)