wasm-encoder
Advanced tools
| { | ||
| "git": { | ||
| "sha1": "d05406062d031ae96146486f58a965d87eefea5e" | ||
| "sha1": "d4e317f22c3bace76cb3205003bcc34b4929037d" | ||
| }, | ||
| "path_in_vcs": "crates/wasm-encoder" | ||
| } |
+5
-5
@@ -155,3 +155,3 @@ # This file is automatically @generated by Cargo. | ||
| name = "wasm-encoder" | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| dependencies = [ | ||
@@ -167,5 +167,5 @@ "anyhow", | ||
| name = "wasmparser" | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d" | ||
| checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" | ||
| dependencies = [ | ||
@@ -179,5 +179,5 @@ "bitflags", | ||
| name = "wasmprinter" | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "eb2b6035559e146114c29a909a3232928ee488d6507a1504d8934e8607b36d7b" | ||
| checksum = "09390d7b2bd7b938e563e4bff10aa345ef2e27a3bc99135697514ef54495e68f" | ||
| dependencies = [ | ||
@@ -184,0 +184,0 @@ "anyhow", |
+5
-6
@@ -14,7 +14,7 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| edition = "2021" | ||
| rust-version = "1.76.0" | ||
| rust-version = "1.81.0" | ||
| name = "wasm-encoder" | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| authors = ["Nick Fitzgerald <fitzgen@gmail.com>"] | ||
| build = "build.rs" | ||
| build = false | ||
| autolib = false | ||
@@ -54,3 +54,3 @@ autobins = false | ||
| [dependencies.wasmparser] | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| features = [ | ||
@@ -70,7 +70,6 @@ "simd", | ||
| [dev-dependencies.wasmprinter] | ||
| version = "0.243.0" | ||
| version = "0.244.0" | ||
| default-features = false | ||
| [lints.clippy] | ||
| allow_attributes_without_reason = "warn" | ||
| clone_on_copy = "warn" | ||
@@ -77,0 +76,0 @@ manual_strip = "warn" |
@@ -481,8 +481,2 @@ use crate::component::*; | ||
| /// Declares a new `backpressure.set` intrinsic. | ||
| pub fn backpressure_set(&mut self) -> u32 { | ||
| self.canonical_functions().backpressure_set(); | ||
| self.core_funcs.add(Some("backpressure.set")) | ||
| } | ||
| /// Declares a new `backpressure.inc` intrinsic. | ||
@@ -489,0 +483,0 @@ pub fn backpressure_inc(&mut self) -> u32 { |
@@ -199,12 +199,2 @@ use crate::{ComponentSection, ComponentSectionId, ComponentValType, Encode, encode_section}; | ||
| /// Defines a function which tells the host to enable or disable | ||
| /// backpressure for the caller's instance. When backpressure is enabled, | ||
| /// the host must not start any new calls to that instance until | ||
| /// backpressure is disabled. | ||
| pub fn backpressure_set(&mut self) -> &mut Self { | ||
| self.bytes.push(0x08); | ||
| self.num_added += 1; | ||
| self | ||
| } | ||
| /// Defines a function which tells the host to increment the backpressure | ||
@@ -211,0 +201,0 @@ /// counter. |
@@ -623,2 +623,9 @@ use super::CORE_TYPE_SORT; | ||
| /// Define a map type. | ||
| pub fn map(self, key: impl Into<ComponentValType>, value: impl Into<ComponentValType>) { | ||
| self.0.push(0x63); | ||
| key.into().encode(self.0); | ||
| value.into().encode(self.0); | ||
| } | ||
| /// Define a fixed size list type. | ||
@@ -625,0 +632,0 @@ pub fn fixed_size_list(self, ty: impl Into<ComponentValType>, elements: u32) { |
+82
-5
@@ -6,2 +6,3 @@ use crate::{ | ||
| }; | ||
| use alloc::borrow::Cow; | ||
| use alloc::vec::Vec; | ||
@@ -87,2 +88,45 @@ | ||
| /// An import item to be used with [`Imports::Single`]. | ||
| #[derive(Clone, Debug)] | ||
| pub struct Import<'a> { | ||
| /// The import's module name. | ||
| pub module: &'a str, | ||
| /// The import's item name. | ||
| pub name: &'a str, | ||
| /// The import's time. | ||
| pub ty: EntityType, | ||
| } | ||
| /// An import item to be used with [`Imports::Compact1`]. | ||
| #[derive(Clone, Debug)] | ||
| pub struct ImportCompact<'a> { | ||
| /// The import's item name. | ||
| pub name: &'a str, | ||
| /// The import's type. | ||
| pub ty: EntityType, | ||
| } | ||
| /// A single entry in the import section of a WebAssembly module, possibly containing multiple imports. | ||
| #[derive(Clone, Debug)] | ||
| pub enum Imports<'a> { | ||
| /// A single import item. | ||
| Single(Import<'a>), | ||
| /// A group of imports with a common module name. | ||
| Compact1 { | ||
| /// The common module name. | ||
| module: &'a str, | ||
| /// The individual import items (name/type). | ||
| items: Cow<'a, [ImportCompact<'a>]>, | ||
| }, | ||
| /// A group of imports with a common module name and type. | ||
| Compact2 { | ||
| /// The common module name. | ||
| module: &'a str, | ||
| /// The common import type. | ||
| ty: EntityType, | ||
| /// The individual import item names. | ||
| names: Cow<'a, [&'a str]>, | ||
| }, | ||
| } | ||
| /// An encoder for the import section of WebAssembly modules. | ||
@@ -135,10 +179,43 @@ /// | ||
| /// Define an import in the import section. | ||
| pub fn import(&mut self, module: &str, field: &str, ty: impl Into<EntityType>) -> &mut Self { | ||
| module.encode(&mut self.bytes); | ||
| field.encode(&mut self.bytes); | ||
| ty.into().encode(&mut self.bytes); | ||
| /// Define imports in the import section. | ||
| pub fn imports<'a>(&mut self, imports: Imports<'a>) -> &mut Self { | ||
| match imports { | ||
| Imports::Single(import) => { | ||
| import.module.encode(&mut self.bytes); | ||
| import.name.encode(&mut self.bytes); | ||
| import.ty.encode(&mut self.bytes); | ||
| } | ||
| Imports::Compact1 { module, items } => { | ||
| module.encode(&mut self.bytes); | ||
| self.bytes.push(0x00); // empty name | ||
| self.bytes.push(0x7F); | ||
| items.len().encode(&mut self.bytes); | ||
| for item in items.iter() { | ||
| item.name.encode(&mut self.bytes); | ||
| item.ty.encode(&mut self.bytes); | ||
| } | ||
| } | ||
| Imports::Compact2 { module, ty, names } => { | ||
| module.encode(&mut self.bytes); | ||
| self.bytes.push(0x00); // empty name | ||
| self.bytes.push(0x7E); | ||
| ty.encode(&mut self.bytes); | ||
| names.len().encode(&mut self.bytes); | ||
| for item in names.iter() { | ||
| item.encode(&mut self.bytes); | ||
| } | ||
| } | ||
| } | ||
| self.num_added += 1; | ||
| self | ||
| } | ||
| /// Define an import in the import section. | ||
| pub fn import(&mut self, module: &str, name: &str, ty: impl Into<EntityType>) -> &mut Self { | ||
| self.imports(Imports::Single(Import { | ||
| module, | ||
| name, | ||
| ty: ty.into(), | ||
| })) | ||
| } | ||
| } | ||
@@ -145,0 +222,0 @@ |
@@ -772,2 +772,8 @@ use crate::reencode::{Error, Reencode, RoundtripReencoder}; | ||
| } | ||
| wasmparser::ComponentDefinedType::Map(k, v) => { | ||
| defined.map( | ||
| reencoder.component_val_type(k), | ||
| reencoder.component_val_type(v), | ||
| ); | ||
| } | ||
| wasmparser::ComponentDefinedType::FixedSizeList(t, elements) => { | ||
@@ -981,5 +987,2 @@ defined.fixed_size_list(reencoder.component_val_type(t), elements); | ||
| } | ||
| wasmparser::CanonicalFunction::BackpressureSet => { | ||
| section.backpressure_set(); | ||
| } | ||
| wasmparser::CanonicalFunction::BackpressureInc => { | ||
@@ -986,0 +989,0 @@ section.backpressure_inc(); |
-27
| use std::process::Command; | ||
| use std::str; | ||
| fn main() { | ||
| // Temporary check to see if the rustc version >= 1.81 in which case the | ||
| // `Error` trait is always available. This is temporary because in the | ||
| // future the MSRV of this crate will be beyond 1.81 in which case this | ||
| // build script can be deleted. | ||
| let minor = rustc_minor_version().unwrap_or(0); | ||
| if minor >= 81 { | ||
| println!("cargo:rustc-cfg=core_error"); | ||
| } | ||
| if minor >= 80 { | ||
| println!("cargo:rustc-check-cfg=cfg(core_error)"); | ||
| } | ||
| } | ||
| fn rustc_minor_version() -> Option<u32> { | ||
| let rustc = std::env::var("RUSTC").unwrap(); | ||
| let output = Command::new(rustc).arg("--version").output().ok()?; | ||
| let version = str::from_utf8(&output.stdout).ok()?; | ||
| let mut pieces = version.split('.'); | ||
| if pieces.next() != Some("rustc 1") { | ||
| return None; | ||
| } | ||
| pieces.next()?.parse().ok() | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display