Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/wasm-compose/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ impl<'a> TypeEncoder<'a> {
ComponentDefinedType::Variant(v) => self.variant(state, v),
ComponentDefinedType::List(ty) => self.list(state, *ty),
ComponentDefinedType::Map(key, value) => self.map(state, *key, *value),
ComponentDefinedType::FixedSizeList(ty, elements) => {
self.fixed_size_list(state, *ty, *elements)
ComponentDefinedType::FixedLengthList(ty, elements) => {
self.fixed_length_list(state, *ty, *elements)
}
ComponentDefinedType::Tuple(t) => self.tuple(state, t),
ComponentDefinedType::Flags(names) => Self::flags(&mut state.cur.encodable, names),
Expand Down Expand Up @@ -733,7 +733,7 @@ impl<'a> TypeEncoder<'a> {
index
}

fn fixed_size_list(
fn fixed_length_list(
&self,
state: &mut TypeState<'a>,
ty: ct::ComponentValType,
Expand All @@ -746,7 +746,7 @@ impl<'a> TypeEncoder<'a> {
.encodable
.ty()
.defined_type()
.fixed_size_list(ty, elements);
.fixed_length_list(ty, elements);
index
}

Expand Down Expand Up @@ -1271,7 +1271,7 @@ impl DependencyRegistrar<'_, '_> {
| ComponentDefinedType::Enum(_)
| ComponentDefinedType::Flags(_) => {}
ComponentDefinedType::List(t)
| ComponentDefinedType::FixedSizeList(t, _)
| ComponentDefinedType::FixedLengthList(t, _)
| ComponentDefinedType::Option(t) => self.val_type(*t),
ComponentDefinedType::Map(k, v) => {
self.val_type(*k);
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm-encoder/src/component/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ impl ComponentDefinedTypeEncoder<'_> {
value.into().encode(self.0);
}

/// Define a fixed size list type.
pub fn fixed_size_list(self, ty: impl Into<ComponentValType>, elements: u32) {
/// Define a fixed-length list type.
pub fn fixed_length_list(self, ty: impl Into<ComponentValType>, elements: u32) {
self.0.push(0x67);
ty.into().encode(self.0);
elements.encode(self.0);
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm-encoder/src/reencode/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,8 @@ pub mod component_utils {
reencoder.component_val_type(v),
);
}
wasmparser::ComponentDefinedType::FixedSizeList(t, elements) => {
defined.fixed_size_list(reencoder.component_val_type(t), elements);
wasmparser::ComponentDefinedType::FixedLengthList(t, elements) => {
defined.fixed_length_list(reencoder.component_val_type(t), elements);
}
wasmparser::ComponentDefinedType::Tuple(t) => {
defined.tuple(t.iter().map(|t| reencoder.component_val_type(*t)));
Expand Down
8 changes: 4 additions & 4 deletions crates/wasm-wave/src/value/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Type(pub(super) TypeEnum);
pub(super) enum TypeEnum {
Simple(SimpleType),
List(Arc<ListType>),
FixedSizeList(Arc<ListType>, u32),
FixedLengthList(Arc<ListType>, u32),
Record(Arc<RecordType>),
Tuple(Arc<TupleType>),
Variant(Arc<VariantType>),
Expand Down Expand Up @@ -57,9 +57,9 @@ impl Type {
}

/// Returns a list type with the given element type.
pub fn fixed_size_list(element_type: impl Into<Self>, elements: u32) -> Self {
pub fn fixed_length_list(element_type: impl Into<Self>, elements: u32) -> Self {
let element = element_type.into();
Self(TypeEnum::FixedSizeList(
Self(TypeEnum::FixedLengthList(
Arc::new(ListType { element }),
elements,
))
Expand Down Expand Up @@ -199,7 +199,7 @@ impl WasmType for Type {
match self.0 {
TypeEnum::Simple(simple) => simple.0,
TypeEnum::List(_) => WasmTypeKind::List,
TypeEnum::FixedSizeList(_, _) => WasmTypeKind::FixedSizeList,
TypeEnum::FixedLengthList(_, _) => WasmTypeKind::FixedLengthList,
TypeEnum::Record(_) => WasmTypeKind::Record,
TypeEnum::Tuple(_) => WasmTypeKind::Tuple,
TypeEnum::Variant(_) => WasmTypeKind::Variant,
Expand Down
8 changes: 4 additions & 4 deletions crates/wasm-wave/src/value/wit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl<'a> TypeResolver<'a> {
TypeDefKind::Option(some_type) => self.resolve_option(some_type),
TypeDefKind::Result(result) => self.resolve_result(result),
TypeDefKind::List(element_type) => self.resolve_list(element_type),
TypeDefKind::FixedSizeList(element_type, elements) => {
self.resolve_fixed_size_list(element_type, *elements)
TypeDefKind::FixedLengthList(element_type, elements) => {
self.resolve_fixed_length_list(element_type, *elements)
}
TypeDefKind::Type(Type::Bool) => Ok(value::Type::BOOL),
TypeDefKind::Type(Type::U8) => Ok(value::Type::U8),
Expand Down Expand Up @@ -150,9 +150,9 @@ impl<'a> TypeResolver<'a> {
Ok(value::Type::list(element_type))
}

fn resolve_fixed_size_list(&self, element_type: &Type, elements: u32) -> ValueResult {
fn resolve_fixed_length_list(&self, element_type: &Type, elements: u32) -> ValueResult {
let element_type = self.resolve_type(*element_type)?;
Ok(value::Type::fixed_size_list(element_type, elements))
Ok(value::Type::fixed_length_list(element_type, elements))
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/wasm-wave/src/wasm/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum WasmTypeKind {
Char,
String,
List,
FixedSizeList,
FixedLengthList,
Record,
Tuple,
Variant,
Expand Down Expand Up @@ -49,7 +49,7 @@ impl core::fmt::Display for WasmTypeKind {
WasmTypeKind::Char => "char",
WasmTypeKind::String => "string",
WasmTypeKind::List => "list",
WasmTypeKind::FixedSizeList => "list<_,N>",
WasmTypeKind::FixedLengthList => "list<_,N>",
WasmTypeKind::Record => "record",
WasmTypeKind::Tuple => "tuple",
WasmTypeKind::Variant => "variant",
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-wave/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<W: Write> Writer<W> {
}
self.write_str("]")
}
WasmTypeKind::FixedSizeList => {
WasmTypeKind::FixedLengthList => {
self.write_str("[")?;
for (idx, val) in val.unwrap_list().enumerate() {
if idx != 0 {
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmparser/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,11 @@ define_wasm_features! {
/// Corresponds to the 📝 character in
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
pub cm_error_context: CM_ERROR_CONTEXT(1 << 31) = false;
/// Support for fixed size lists
/// Support for fixed-length lists
///
/// Corresponds to the 🔧 character in
/// <https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md>.
pub cm_fixed_size_list: CM_FIXED_SIZE_LIST(1 << 32) = false;
pub cm_fixed_length_lists: CM_FIXED_LENGTH_LISTS(1 << 32) = false;
/// Support for Wasm GC in the component model proposal.
///
/// Corresponds to the 🛸 character in
Expand Down
6 changes: 3 additions & 3 deletions crates/wasmparser/src/readers/component/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ pub enum ComponentDefinedType<'a> {
List(ComponentValType),
/// The type is a map of the given key and value types.
Map(ComponentValType, ComponentValType),
/// The type is a fixed size list of the given value type.
FixedSizeList(ComponentValType, u32),
/// The type is a fixed-length list of the given value type.
FixedLengthList(ComponentValType, u32),
/// The type is a tuple of the given value types.
Tuple(Box<[ComponentValType]>),
/// The type is flags with the given names.
Expand Down Expand Up @@ -513,7 +513,7 @@ impl<'a> ComponentDefinedType<'a> {
},
0x69 => ComponentDefinedType::Own(reader.read()?),
0x68 => ComponentDefinedType::Borrow(reader.read()?),
0x67 => ComponentDefinedType::FixedSizeList(reader.read()?, reader.read_var_u32()?),
0x67 => ComponentDefinedType::FixedLengthList(reader.read()?, reader.read_var_u32()?),
0x66 => ComponentDefinedType::Stream(reader.read()?),
0x65 => ComponentDefinedType::Future(reader.read()?),
x => return reader.invalid_leading_byte(x, "component defined type"),
Expand Down
15 changes: 9 additions & 6 deletions crates/wasmparser/src/validator/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ impl ComponentState {
.unwrap_or(true)
}
ComponentDefinedType::List(ty)
| ComponentDefinedType::FixedSizeList(ty, _)
| ComponentDefinedType::FixedLengthList(ty, _)
| ComponentDefinedType::Option(ty) => types.type_named_valtype(ty, set),
ComponentDefinedType::Map(k, v) => {
types.type_named_valtype(k, set) && types.type_named_valtype(v, set)
Expand Down Expand Up @@ -3929,17 +3929,20 @@ impl ComponentState {
self.create_component_val_type(value, offset)?,
))
}
crate::ComponentDefinedType::FixedSizeList(ty, elements) => {
if !self.features.cm_fixed_size_list() {
crate::ComponentDefinedType::FixedLengthList(ty, elements) => {
if !self.features.cm_fixed_length_lists() {
bail!(
offset,
"Fixed size lists require the component model fixed size list feature"
"Fixed-length lists require the component model fixed-length lists feature"
)
}
if elements < 1 {
bail!(offset, "Fixed size lists must have more than zero elements")
bail!(
offset,
"Fixed-length lists must have more than zero elements"
)
}
Ok(ComponentDefinedType::FixedSizeList(
Ok(ComponentDefinedType::FixedLengthList(
self.create_component_val_type(ty, offset)?,
elements,
))
Expand Down
26 changes: 13 additions & 13 deletions crates/wasmparser/src/validator/component_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,8 +1470,8 @@ pub enum ComponentDefinedType {
List(ComponentValType),
/// The type is a map.
Map(ComponentValType, ComponentValType),
/// The type is a fixed size list.
FixedSizeList(ComponentValType, u32),
/// The type is a fixed-length list.
FixedLengthList(ComponentValType, u32),
/// The type is a tuple.
Tuple(TupleType),
/// The type is a set of flags.
Expand Down Expand Up @@ -1512,7 +1512,7 @@ impl TypeData for ComponentDefinedType {
Self::Record(r) => r.info,
Self::Variant(v) => v.info,
Self::Tuple(t) => t.info,
Self::List(ty) | Self::FixedSizeList(ty, _) | Self::Option(ty) => ty.info(types),
Self::List(ty) | Self::FixedLengthList(ty, _) | Self::Option(ty) => ty.info(types),
Self::Map(k, v) => {
let mut info = k.info(types);
info.combine(v.info(types), 0).unwrap();
Expand Down Expand Up @@ -1546,7 +1546,7 @@ impl ComponentDefinedType {
| Self::Borrow(_)
| Self::Future(_)
| Self::Stream(_) => false,
Self::Option(ty) | Self::FixedSizeList(ty, _) => ty.contains_ptr(types),
Self::Option(ty) | Self::FixedLengthList(ty, _) => ty.contains_ptr(types),
Self::Result { ok, err } => {
ok.map(|ty| ty.contains_ptr(types)).unwrap_or(false)
|| err.map(|ty| ty.contains_ptr(types)).unwrap_or(false)
Expand All @@ -1569,7 +1569,7 @@ impl ComponentDefinedType {
Self::List(_) | Self::Map(_, _) => {
lowered_types.try_push(ValType::I32) && lowered_types.try_push(ValType::I32)
}
Self::FixedSizeList(ty, length) => {
Self::FixedLengthList(ty, length) => {
(0..*length).all(|_n| ty.push_wasm_types(types, lowered_types))
}
Self::Tuple(t) => t
Expand Down Expand Up @@ -1647,7 +1647,7 @@ impl ComponentDefinedType {
ComponentDefinedType::Option(_) => "option",
ComponentDefinedType::List(_) => "list",
ComponentDefinedType::Map(_, _) => "map",
ComponentDefinedType::FixedSizeList(_, _) => "fixed size list",
ComponentDefinedType::FixedLengthList(_, _) => "fixed-length list",
ComponentDefinedType::Result { .. } => "result",
ComponentDefinedType::Own(_) => "own",
ComponentDefinedType::Borrow(_) => "borrow",
Expand All @@ -1671,7 +1671,7 @@ impl ComponentDefinedType {

ComponentDefinedType::Variant(ty) => ty.lower_gc(types, abi, options, offset, core),

ComponentDefinedType::List(ty) | ComponentDefinedType::FixedSizeList(ty, _) => {
ComponentDefinedType::List(ty) | ComponentDefinedType::FixedLengthList(ty, _) => {
let id = match core.as_concrete_ref() {
Some(id) => id,
None => bail!(
Expand Down Expand Up @@ -2524,7 +2524,7 @@ impl TypeAlloc {
}
}
ComponentDefinedType::List(ty)
| ComponentDefinedType::FixedSizeList(ty, _)
| ComponentDefinedType::FixedLengthList(ty, _)
| ComponentDefinedType::Option(ty) => {
self.free_variables_valtype(ty, set);
}
Expand Down Expand Up @@ -2672,7 +2672,7 @@ impl TypeAlloc {
.unwrap_or(true)
}
ComponentDefinedType::List(ty)
| ComponentDefinedType::FixedSizeList(ty, _)
| ComponentDefinedType::FixedLengthList(ty, _)
| ComponentDefinedType::Option(ty) => self.type_named_valtype(ty, set),
ComponentDefinedType::Map(k, v) => {
self.type_named_valtype(k, set) && self.type_named_valtype(v, set)
Expand Down Expand Up @@ -2865,7 +2865,7 @@ where
}
}
ComponentDefinedType::List(ty)
| ComponentDefinedType::FixedSizeList(ty, _)
| ComponentDefinedType::FixedLengthList(ty, _)
| ComponentDefinedType::Option(ty) => {
any_changed |= self.remap_valtype(ty, map);
}
Expand Down Expand Up @@ -3791,14 +3791,14 @@ impl<'a> SubtypeCx<'a> {
.with_context(|| "type mismatch in map value")
}
(Map(_, _), b) => bail!(offset, "expected {}, found map", b.desc()),
(FixedSizeList(a, asize), FixedSizeList(b, bsize)) => {
(FixedLengthList(a, asize), FixedLengthList(b, bsize)) => {
if asize != bsize {
bail!(offset, "expected fixed size {bsize}, found size {asize}")
bail!(offset, "expected fixed-length {bsize}, found size {asize}")
} else {
self.component_val_type(a, b, offset)
}
}
(FixedSizeList(_, _), b) => bail!(offset, "expected {}, found list", b.desc()),
(FixedLengthList(_, _), b) => bail!(offset, "expected {}, found list", b.desc()),
(Option(_), b) => bail!(offset, "expected {}, found option", b.desc()),
(Tuple(a), Tuple(b)) => {
if a.types.len() != b.types.len() {
Expand Down
6 changes: 3 additions & 3 deletions crates/wasmprinter/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Printer<'_, '_> {
Ok(())
}

pub(crate) fn print_fixed_size_list_type(
pub(crate) fn print_fixed_length_list_type(
&mut self,
state: &State,
element_ty: &ComponentValType,
Expand Down Expand Up @@ -293,8 +293,8 @@ impl Printer<'_, '_> {
ComponentDefinedType::Variant(cases) => self.print_variant_type(state, cases)?,
ComponentDefinedType::List(ty) => self.print_list_type(state, ty)?,
ComponentDefinedType::Map(key, value) => self.print_map_type(state, key, value)?,
ComponentDefinedType::FixedSizeList(ty, elements) => {
self.print_fixed_size_list_type(state, ty, *elements)?
ComponentDefinedType::FixedLengthList(ty, elements) => {
self.print_fixed_length_list_type(state, ty, *elements)?
}
ComponentDefinedType::Tuple(tys) => self.print_tuple_type(state, tys)?,
ComponentDefinedType::Flags(names) => self.print_flag_or_enum_type("flags", names)?,
Expand Down
4 changes: 2 additions & 2 deletions crates/wast/src/component/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ fn encode_defined_type(encoder: ComponentDefinedTypeEncoder, ty: &ComponentDefin
ComponentDefinedType::Map(m) => {
encoder.map(m.key.as_ref(), m.value.as_ref());
}
ComponentDefinedType::FixedSizeList(l) => {
encoder.fixed_size_list(l.element.as_ref(), l.elements);
ComponentDefinedType::FixedLengthList(l) => {
encoder.fixed_length_list(l.element.as_ref(), l.elements);
}
ComponentDefinedType::Tuple(t) => {
encoder.tuple(t.fields.iter());
Expand Down
2 changes: 1 addition & 1 deletion crates/wast/src/component/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl<'a> Expander<'a> {
}
}
ComponentDefinedType::List(List { element: t })
| ComponentDefinedType::FixedSizeList(FixedSizeList {
| ComponentDefinedType::FixedLengthList(FixedLengthList {
element: t,
elements: _,
}) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/wast/src/component/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl<'a> Resolver<'a> {
}
}
ComponentDefinedType::List(List { element: t })
| ComponentDefinedType::FixedSizeList(FixedSizeList {
| ComponentDefinedType::FixedLengthList(FixedLengthList {
element: t,
elements: _,
}) => {
Expand Down
8 changes: 4 additions & 4 deletions crates/wast/src/component/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ pub enum ComponentDefinedType<'a> {
Variant(Variant<'a>),
List(List<'a>),
Map(Map<'a>),
FixedSizeList(FixedSizeList<'a>),
FixedLengthList(FixedLengthList<'a>),
Tuple(Tuple<'a>),
Flags(Flags<'a>),
Enum(Enum<'a>),
Expand Down Expand Up @@ -600,9 +600,9 @@ pub struct Map<'a> {
pub value: Box<ComponentValType<'a>>,
}

/// A fixed size list type.
/// A fixed-length list type.
#[derive(Debug)]
pub struct FixedSizeList<'a> {
pub struct FixedLengthList<'a> {
/// The element type of the array.
pub element: Box<ComponentValType<'a>>,
/// Number of Elements
Expand All @@ -614,7 +614,7 @@ fn parse_list<'a>(parser: Parser<'a>) -> Result<ComponentDefinedType<'a>> {
let tp = parser.parse()?;
let elements = parser.parse::<Option<u32>>()?;
if let Some(elements) = elements {
Ok(ComponentDefinedType::FixedSizeList(FixedSizeList {
Ok(ComponentDefinedType::FixedLengthList(FixedLengthList {
element: Box::new(tp),
elements,
}))
Expand Down
2 changes: 1 addition & 1 deletion crates/wit-component/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl TypeContents {
TypeDefKind::Map(k, v) => {
Self::for_type(resolve, k) | Self::for_type(resolve, v) | Self::NEEDS_MEMORY
}
TypeDefKind::FixedSizeList(t, _elements) => Self::for_type(resolve, t),
TypeDefKind::FixedLengthList(t, _elements) => Self::for_type(resolve, t),
TypeDefKind::Type(t) => Self::for_type(resolve, t),
TypeDefKind::Future(_) => Self::empty(),
TypeDefKind::Stream(_) => Self::empty(),
Expand Down
Loading
Loading