Skip to content

Commit a6a683e

Browse files
committed
Expose more mutability
1 parent 3af60e0 commit a6a683e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/ir/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ pub type LocalId = Id<Local>;
2323
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2424
pub struct Local {
2525
id: LocalId,
26-
ty: ValType,
26+
/// The type of this local
27+
pub ty: ValType,
2728
/// A human-readable name for this local, often useful when debugging
2829
pub name: Option<String>,
2930
}

src/module/locals.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ impl ModuleLocals {
3434
pub fn iter(&self) -> impl Iterator<Item = &Local> {
3535
self.arena.iter().map(|(_, f)| f)
3636
}
37+
38+
/// Get a mutable reference to this module's globals.
39+
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Local> {
40+
self.arena.iter_mut().map(|(_, f)| f)
41+
}
3742
}

src/ty.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,18 @@ impl Type {
117117
&*self.results
118118
}
119119

120+
/// Get the parameters to this function type.
121+
#[inline]
122+
pub fn params_mut(&mut self) -> &mut [ValType] {
123+
&mut *self.params
124+
}
125+
126+
/// Get the results of this function type.
127+
#[inline]
128+
pub fn results_mut(&mut self) -> &mut [ValType] {
129+
&mut *self.results
130+
}
131+
120132
pub(crate) fn is_for_function_entry(&self) -> bool {
121133
self.is_for_function_entry
122134
}

0 commit comments

Comments
 (0)