Skip to content

Commit e5f996f

Browse files
committed
make encode_branch generic over T:Encode
1 parent 81c7975 commit e5f996f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/wasmi/src/engine/translator/func/encoder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,26 +373,26 @@ impl OpEncoder {
373373
Ok(Some(Pos::from(pos)))
374374
}
375375

376-
/// Encodes a branch [`Op`] to the [`OpEncoder`] and returns its [`Pos<Op>`] and [`Pos<BranchOffset>`].
376+
/// Encodes a type with [`BranchOffset`] to the [`OpEncoder`] and returns its [`Pos<Op>`] and [`Pos<BranchOffset>`].
377377
///
378378
/// # Note
379379
///
380380
/// Bumps the `fuel` of the [`Op::ConsumeFuel`] accordingly.
381-
pub fn encode_branch(
381+
pub fn encode_branch<T: ir::Encode>(
382382
&mut self,
383-
op: Op,
383+
item: T,
384384
fuel_pos: Option<Pos<BlockFuel>>,
385385
fuel_selector: impl FuelCostsSelector,
386-
) -> Result<(Pos<Op>, Pos<BranchOffset>), Error> {
386+
) -> Result<(Pos<T>, Pos<BranchOffset>), Error> {
387387
self.try_encode_staged()?;
388388
self.bump_fuel_consumption(fuel_pos, fuel_selector)?;
389-
let pos_op = self.encode_impl(op)?;
389+
let pos_item = self.encode_impl(item)?;
390390
let pos_offset = match self.ops.take_temp() {
391391
Some((pos, TempBuffer::BranchOffset(_))) => Pos::from(pos),
392392
_ => panic!("missing encoded position for `BranchOffset`"),
393393
};
394394
debug_assert!(self.staged.is_none());
395-
Ok((pos_op, pos_offset))
395+
Ok((pos_item, pos_offset))
396396
}
397397

398398
/// Encodes an [`Op`] to the [`OpEncoder`] and returns its [`Pos<Op>`].

0 commit comments

Comments
 (0)