Skip to content

Commit 81c7975

Browse files
committed
refactor LabelUser type and make it private
1 parent 7c3843b commit 81c7975

File tree

1 file changed

+12
-16
lines changed
  • crates/wasmi/src/engine/translator/func

1 file changed

+12
-16
lines changed

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,19 @@ impl RegisteredLabels {
9090

9191
/// A user of a label.
9292
#[derive(Debug, Copy, Clone)]
93-
pub struct LabelUser {
94-
/// The branch `target` label in use by the `user`.
95-
target: LabelRef,
96-
/// The reference to the using instruction.
97-
user: Pos<Op>,
98-
/// The [`BranchOffset`] of `user` that needs to be updated once `target` has been resolved.
99-
offset: Pos<BranchOffset>,
93+
struct LabelUser {
94+
/// The branch destination [`Label`].
95+
dst: LabelRef,
96+
/// The branch source [`Op`].
97+
src: Pos<Op>,
98+
/// The [`BranchOffset`] of `src` that needs to be updated once `dst` has been pinned.
99+
pos: Pos<BranchOffset>,
100100
}
101101

102102
impl LabelUser {
103103
/// Creates a new [`LabelUser`].
104-
pub fn new(target: LabelRef, user: Pos<Op>, offset: Pos<BranchOffset>) -> Self {
105-
Self {
106-
target,
107-
user,
108-
offset,
109-
}
104+
pub fn new(dst: LabelRef, src: Pos<Op>, pos: Pos<BranchOffset>) -> Self {
105+
Self { dst, src, pos }
110106
}
111107
}
112108

@@ -257,9 +253,9 @@ impl Iterator for ResolvedUserIter<'_> {
257253

258254
fn next(&mut self) -> Option<Self::Item> {
259255
let next = self.users.next()?;
260-
let src = next.user;
261-
let Label::Pinned(dst) = self.labels.get(next.target) else {
262-
panic!("encountered unexpected unpinned label: {:?}", next.target)
256+
let src = next.src;
257+
let Label::Pinned(dst) = self.labels.get(next.dst) else {
258+
panic!("encountered unexpected unpinned label: {:?}", next.dst)
263259
};
264260
let offset = trace_branch_offset(src, dst);
265261
Some((src, offset))

0 commit comments

Comments
 (0)