Skip to content

Commit

Permalink
Update to new GC cast instruction encoding (bytecodealliance#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvisness authored and dhil committed Jul 21, 2023
1 parent 60617d5 commit 16742a0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crates/wast/src/core/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,26 +1212,22 @@ impl Encode for RefCast<'_> {
}
}

fn br_on_cast_flags(on_fail: bool, from_nullable: bool, to_nullable: bool) -> u8 {
fn br_on_cast_flags(from_nullable: bool, to_nullable: bool) -> u8 {
let mut flag = 0;
if from_nullable {
flag |= 1 << 0;
}
if to_nullable {
flag |= 1 << 1;
}
if on_fail {
flag |= 1 << 2;
}
flag
}

impl Encode for BrOnCast<'_> {
fn encode(&self, e: &mut Vec<u8>) {
e.push(0xfb);
e.push(0x4f);
e.push(0x4e);
e.push(br_on_cast_flags(
false,
self.from_type.nullable,
self.to_type.nullable,
));
Expand All @@ -1246,7 +1242,6 @@ impl Encode for BrOnCastFail<'_> {
e.push(0xfb);
e.push(0x4f);
e.push(br_on_cast_flags(
true,
self.from_type.nullable,
self.to_type.nullable,
));
Expand Down

0 comments on commit 16742a0

Please sign in to comment.