Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
yjhmelody committed Nov 28, 2023
1 parent 534f25e commit 2e0a564
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
33 changes: 0 additions & 33 deletions crates/wasmi/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ pub enum GlobalError {
/// The type of the new value that mismatches the type of the global variable.
encountered: ValueType,
},
/// Occurs when a global type does not satisfy the constraints of another.
UnsatisfyingGlobalType {
/// The unsatisfying [`GlobalType`].
unsatisfying: GlobalType,
/// The required [`GlobalType`].
required: GlobalType,
},
}

impl Display for GlobalError {
Expand All @@ -57,16 +50,6 @@ impl Display for GlobalError {
expected {expected:?} but encountered {encountered:?}.",
)
}
Self::UnsatisfyingGlobalType {
unsatisfying,
required,
} => {
write!(
f,
"global type {unsatisfying:?} does not \
satisfy requirements of {required:?}",
)
}
}
}
}
Expand Down Expand Up @@ -119,22 +102,6 @@ impl GlobalType {
pub fn mutability(&self) -> Mutability {
self.mutability
}

/// Checks if `self` satisfies the given `GlobalType`.
///
/// # Errors
///
/// - If the initial limits of the `required` [`GlobalType`] are greater than `self`.
/// - If the maximum limits of the `required` [`GlobalType`] are greater than `self`.
pub(crate) fn satisfies(&self, required: &GlobalType) -> Result<(), GlobalError> {
if self != required {
return Err(GlobalError::UnsatisfyingGlobalType {
unsatisfying: *self,
required: *required,
});
}
Ok(())
}
}

/// A global variable entity.
Expand Down
9 changes: 3 additions & 6 deletions crates/wasmi/src/module/instantiate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,16 @@ impl Module {
/// mismatch with the expected module import type.
///
/// [`Func`]: [`crate::Func`]
fn extract_imports<I>(
builder: &mut InstanceEntityBuilder,
externals: I,
)
fn extract_imports<I>(builder: &mut InstanceEntityBuilder, externals: I)
where
I: IntoIterator<Item = Extern>,
{
for external in externals {
match external {
Extern::Func(func)=> {
Extern::Func(func) => {
builder.push_func(func);
}
Extern::Table(table)=> {
Extern::Table(table) => {
builder.push_table(table);
}
Extern::Memory(memory) => {
Expand Down

0 comments on commit 2e0a564

Please sign in to comment.