Skip to content

Commit

Permalink
Merge with upstream (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhil authored Aug 9, 2024
2 parents d387cba + b2e8e13 commit 4d522a3
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ publish
*.wat
test.config

.DS_Store
.idea
.vscode
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/wasmparser/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ macro_rules! define_wasm_features {

define_wasm_features! {
/// Flags for features that are enabled for validation.
#[derive(Hash, Debug, Copy, Clone)]
#[derive(Hash, Debug, Copy, Clone, Eq, PartialEq)]
pub struct WasmFeatures: u32 {
/// The WebAssembly `mutable-global` proposal.
pub mutable_global: MUTABLE_GLOBAL(1) = true;
Expand Down
10 changes: 5 additions & 5 deletions crates/wasmparser/src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ pub const MAX_WASM_MODULE_SIZE: usize = 1024 * 1024 * 1024; //= 1 GiB
pub const MAX_WASM_MODULE_TYPE_DECLS: usize = 100_000;
pub const MAX_WASM_COMPONENT_TYPE_DECLS: usize = 100_000;
pub const MAX_WASM_INSTANCE_TYPE_DECLS: usize = 100_000;
pub const MAX_WASM_RECORD_FIELDS: usize = 1000;
pub const MAX_WASM_VARIANT_CASES: usize = 1000;
pub const MAX_WASM_TUPLE_TYPES: usize = 1000;
pub const MAX_WASM_FLAG_NAMES: usize = 1000;
pub const MAX_WASM_ENUM_CASES: usize = 1000;
pub const MAX_WASM_RECORD_FIELDS: usize = 10_000;
pub const MAX_WASM_VARIANT_CASES: usize = 10_000;
pub const MAX_WASM_TUPLE_TYPES: usize = 10_000;
pub const MAX_WASM_FLAG_NAMES: usize = 1_000;
pub const MAX_WASM_ENUM_CASES: usize = 10_000;
pub const MAX_WASM_INSTANTIATION_EXPORTS: usize = 100_000;
pub const MAX_WASM_CANONICAL_OPTIONS: usize = 10;
pub const MAX_WASM_INSTANTIATION_ARGS: usize = 100_000;
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmparser/src/readers/component/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum ComponentOuterAliasKind {
}

/// Represents an alias in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ComponentAlias<'a> {
/// The alias is to an export of a component instance.
InstanceExport {
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmparser/src/readers/component/canonicals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum CanonicalOption {
}

/// Represents a canonical function in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum CanonicalFunction {
/// The function lifts a core WebAssembly function to the canonical ABI.
Lift {
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmparser/src/readers/component/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ComponentExternalKind {
}

/// Represents an export in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ComponentExport<'a> {
/// The name of the exported item.
pub name: ComponentExportName<'a>,
Expand Down Expand Up @@ -115,7 +115,7 @@ impl<'a> FromReader<'a> for ComponentExternalKind {
}

/// Represents the name of a component export.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[allow(missing_docs)]
pub struct ComponentExportName<'a>(pub &'a str);

Expand Down
4 changes: 2 additions & 2 deletions crates/wasmparser/src/readers/component/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'a> FromReader<'a> for ComponentTypeRef {
}

/// Represents an import in a WebAssembly component
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct ComponentImport<'a> {
/// The name of the imported item.
pub name: ComponentImportName<'a>,
Expand Down Expand Up @@ -110,7 +110,7 @@ impl<'a> FromReader<'a> for ComponentImport<'a> {
pub type ComponentImportSectionReader<'a> = SectionLimited<'a, ComponentImport<'a>>;

/// Represents the name of a component import.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[allow(missing_docs)]
pub struct ComponentImportName<'a>(pub &'a str);

Expand Down
8 changes: 4 additions & 4 deletions crates/wasmparser/src/readers/component/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum InstantiationArgKind {
}

/// Represents an argument to instantiating a WebAssembly module.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct InstantiationArg<'a> {
/// The name of the module argument.
pub name: &'a str,
Expand All @@ -24,7 +24,7 @@ pub struct InstantiationArg<'a> {
}

/// Represents an instance of a WebAssembly module.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Instance<'a> {
/// The instance is from instantiating a WebAssembly module.
Instantiate {
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'a> FromReader<'a> for InstantiationArgKind {
}

/// Represents an argument to instantiating a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ComponentInstantiationArg<'a> {
/// The name of the component argument.
pub name: &'a str,
Expand All @@ -102,7 +102,7 @@ pub struct ComponentInstantiationArg<'a> {
}

/// Represents an instance in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ComponentInstance<'a> {
/// The instance is from instantiating a WebAssembly component.
Instantiate {
Expand Down
14 changes: 7 additions & 7 deletions crates/wasmparser/src/readers/component/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub enum OuterAliasKind {
}

/// Represents a core type in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum CoreType<'a> {
/// The type is for a core subtype.
Sub(SubType),
Expand Down Expand Up @@ -44,7 +44,7 @@ impl<'a> FromReader<'a> for CoreType<'a> {
}

/// Represents a module type declaration in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ModuleTypeDeclaration<'a> {
/// The module type definition is for a type.
Type(SubType),
Expand Down Expand Up @@ -235,7 +235,7 @@ impl fmt::Display for PrimitiveValType {
}

/// Represents a type in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ComponentType<'a> {
/// The type is a component defined type.
Defined(ComponentDefinedType<'a>),
Expand Down Expand Up @@ -295,7 +295,7 @@ impl<'a> FromReader<'a> for ComponentType<'a> {
}

/// Represents part of a component type declaration in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ComponentTypeDeclaration<'a> {
/// The component type declaration is for a core type.
CoreType(CoreType<'a>),
Expand Down Expand Up @@ -336,7 +336,7 @@ impl<'a> FromReader<'a> for ComponentTypeDeclaration<'a> {
}

/// Represents an instance type declaration in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum InstanceTypeDeclaration<'a> {
/// The component type declaration is for a core type.
CoreType(CoreType<'a>),
Expand Down Expand Up @@ -369,7 +369,7 @@ impl<'a> FromReader<'a> for InstanceTypeDeclaration<'a> {
}

/// Represents the result type of a component function.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ComponentFuncResult<'a> {
/// The function returns a singular, unnamed type.
Unnamed(ComponentValType),
Expand Down Expand Up @@ -430,7 +430,7 @@ impl ComponentFuncResult<'_> {
}

/// Represents a type of a function in a WebAssembly component.
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct ComponentFuncType<'a> {
/// The function parameters.
pub params: Box<[(&'a str, ComponentValType)]>,
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmparser/src/readers/core/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum ExternalKind {
}

/// Represents an export in a WebAssembly module.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Export<'a> {
/// The name of the exported item.
pub name: &'a str,
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmparser/src/readers/core/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
};

/// Represents a reference to a type definition in a WebAssembly module.
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum TypeRef {
/// The type is a function.
///
Expand All @@ -40,7 +40,7 @@ pub enum TypeRef {
}

/// Represents an import in a WebAssembly module.
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Import<'a> {
/// The module being imported from.
pub module: &'a str,
Expand Down
8 changes: 8 additions & 0 deletions crates/wasmparser/src/readers/core/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ pub struct ConstExpr<'a> {
reader: BinaryReader<'a>,
}

impl PartialEq for ConstExpr<'_> {
fn eq(&self, other: &Self) -> bool {
self.reader.remaining_buffer() == other.reader.remaining_buffer()
}
}

impl Eq for ConstExpr<'_> {}

impl<'a> ConstExpr<'a> {
/// Constructs a new `ConstExpr` from the given data and offset.
pub fn new(reader: BinaryReader<'a>) -> ConstExpr {
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmparser/src/readers/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,14 +1874,14 @@ pub struct GlobalType {
}

/// Represents a tag kind.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TagKind {
/// The tag is an exception type.
Exception,
}

/// A tag's type.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TagType {
/// The kind of tag
pub kind: TagKind,
Expand Down
3 changes: 3 additions & 0 deletions crates/wit-component/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ rust-version.workspace = true
[lints]
workspace = true

[package.metadata.docs.rs]
all-features = true

[dependencies]
wasmparser = { workspace = true }
wasm-encoder = { workspace = true, features = ["wasmparser"] }
Expand Down
1 change: 1 addition & 0 deletions crates/wit-component/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The WebAssembly component tooling.
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

use std::str::FromStr;
use std::{borrow::Cow, fmt::Display};
Expand Down

0 comments on commit 4d522a3

Please sign in to comment.