Skip to content

Commit

Permalink
Added the ability to add features when decoding Wasm with wit-compone…
Browse files Browse the repository at this point in the history
…nt (#1201)

* added the option so set features when decoding wit

* export decode with features

* Changed so all features are enabled in wit-component
  • Loading branch information
silesmo authored Sep 18, 2023
1 parent 0cd2755 commit 0a1e92b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
26 changes: 26 additions & 0 deletions crates/wasmparser/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,32 @@ pub struct WasmFeatures {
}

impl WasmFeatures {
/// Returns [`WasmFeatures`] with all features enabled.
pub fn all() -> Self {
WasmFeatures {
mutable_global: true,
saturating_float_to_int: true,
sign_extension: true,
reference_types: true,
multi_value: true,
bulk_memory: true,
simd: true,
relaxed_simd: true,
threads: true,
tail_call: true,
floats: true,
multi_memory: true,
exceptions: true,
memory64: true,
extended_const: true,
component_model: true,
function_references: true,
memory_control: true,
gc: true,
component_model_values: true,
}
}

/// NOTE: This only checks that the value type corresponds to the feature set!!
///
/// To check that reference types are valid, we need access to the module
Expand Down
5 changes: 1 addition & 4 deletions crates/wit-component/src/decoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ enum Extern<'a> {
impl<'a> ComponentInfo<'a> {
/// Creates a new component info by parsing the given WebAssembly component bytes.
fn new(bytes: &'a [u8]) -> Result<Self> {
let mut validator = Validator::new_with_features(WasmFeatures {
component_model: true,
..Default::default()
});
let mut validator = Validator::new_with_features(WasmFeatures::all());
let mut externs = Vec::new();
let mut depth = 1;
let mut types = None;
Expand Down

0 comments on commit 0a1e92b

Please sign in to comment.