Skip to content

Commit 4353cd1

Browse files
committed
add bail_unreachable utility macro
1 parent fd8cfd4 commit 4353cd1

File tree

1 file changed

+17
-0
lines changed
  • crates/wasmi/src/engine/translator/translator2

1 file changed

+17
-0
lines changed

crates/wasmi/src/engine/translator/translator2/utils.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/// Bail out early in case the current code is unreachable.
2+
///
3+
/// # Note
4+
///
5+
/// - This should be prepended to most Wasm operator translation procedures.
6+
/// - If we are in unreachable code most Wasm translation is skipped. Only
7+
/// certain control flow operators such as `End` are going through the
8+
/// translation process. In particular the `End` operator may end unreachable
9+
/// code blocks.
10+
macro_rules! bail_unreachable {
11+
($this:ident) => {{
12+
if !$this.reachable {
13+
return Ok(());
14+
}
15+
}};
16+
}
17+
118
/// Implemented by types that can be reset for reuse.
219
pub trait Reset {
320
/// Resets `self` for reuse.

0 commit comments

Comments
 (0)