Skip to content

Commit ffc3be3

Browse files
committed
feat(wasmparser): add feature flag support for component model map feature
1 parent 7f954f2 commit ffc3be3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

crates/wasmparser/src/features.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ define_wasm_features! {
286286
/// Corresponds to the 🛸 character in
287287
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
288288
pub cm_gc: CM_GC(1 << 33) = false;
289+
/// Support for maps in the component model proposal.
290+
///
291+
/// Corresponds to the 🗺️ character in
292+
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
293+
pub cm_map: CM_MAP(1 << 37) = false;
289294

290295
/// Subset of the reference-types WebAssembly proposal which only
291296
/// encompasses the leb-encoding of the table immediate to the

crates/wasmparser/src/validator/component.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3920,10 +3920,18 @@ impl ComponentState {
39203920
crate::ComponentDefinedType::List(ty) => Ok(ComponentDefinedType::List(
39213921
self.create_component_val_type(ty, offset)?,
39223922
)),
3923-
crate::ComponentDefinedType::Map(key, value) => Ok(ComponentDefinedType::Map(
3924-
self.create_component_val_type(key, offset)?,
3925-
self.create_component_val_type(value, offset)?,
3926-
)),
3923+
crate::ComponentDefinedType::Map(key, value) => {
3924+
if !self.features.cm_map() {
3925+
bail!(
3926+
offset,
3927+
"Maps require the component model map feature"
3928+
)
3929+
}
3930+
Ok(ComponentDefinedType::Map(
3931+
self.create_component_val_type(key, offset)?,
3932+
self.create_component_val_type(value, offset)?,
3933+
))
3934+
},
39273935
crate::ComponentDefinedType::FixedSizeList(ty, elements) => {
39283936
if !self.features.cm_fixed_size_list() {
39293937
bail!(

0 commit comments

Comments
 (0)