Skip to content

Commit

Permalink
Expose more mutability
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jun 9, 2023
1 parent 3af60e0 commit a6a683e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub type LocalId = Id<Local>;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Local {
id: LocalId,
ty: ValType,
/// The type of this local
pub ty: ValType,
/// A human-readable name for this local, often useful when debugging
pub name: Option<String>,
}
Expand Down
5 changes: 5 additions & 0 deletions src/module/locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ impl ModuleLocals {
pub fn iter(&self) -> impl Iterator<Item = &Local> {
self.arena.iter().map(|(_, f)| f)
}

/// Get a mutable reference to this module's globals.
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Local> {
self.arena.iter_mut().map(|(_, f)| f)
}
}
12 changes: 12 additions & 0 deletions src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ impl Type {
&*self.results
}

/// Get the parameters to this function type.
#[inline]
pub fn params_mut(&mut self) -> &mut [ValType] {
&mut *self.params
}

/// Get the results of this function type.
#[inline]
pub fn results_mut(&mut self) -> &mut [ValType] {
&mut *self.results
}

pub(crate) fn is_for_function_entry(&self) -> bool {
self.is_for_function_entry
}
Expand Down

0 comments on commit a6a683e

Please sign in to comment.