Skip to content

Commit

Permalink
chore(api): De-duplicate module info polyfill
Browse files Browse the repository at this point in the history
The module was copy-pasted between js and jsc backends.

This commit lifts the module up to the root and shares it.
  • Loading branch information
theduke committed Jan 31, 2024
1 parent 26d600f commit bb9f246
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 618 deletions.
2 changes: 0 additions & 2 deletions lib/api/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ pub(crate) mod instance;
mod js_handle;
pub(crate) mod mem_access;
pub(crate) mod module;
#[cfg(feature = "wasm-types-polyfill")]
mod module_info_polyfill;
pub(crate) mod store;
pub(crate) mod trap;
pub(crate) mod typed_function;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/js/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Module {
// The module is now validated, so we can safely parse it's types
#[cfg(feature = "wasm-types-polyfill")]
let (type_hints, name) = {
let info = crate::js::module_info_polyfill::translate_module(&binary[..]).unwrap();
let info = crate::module_info_polyfill::translate_module(&binary[..]).unwrap();

(
Some(ModuleTypeHints {
Expand Down
1 change: 0 additions & 1 deletion lib/api/src/jsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub(crate) mod externals;
pub(crate) mod instance;
pub(crate) mod mem_access;
pub(crate) mod module;
mod module_info_polyfill;
pub(crate) mod store;
pub(crate) mod trap;
pub(crate) mod typed_function;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/jsc/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl Module {
pub(crate) unsafe fn from_js_module(module: JSObject, binary: impl IntoBytes) -> Self {
let binary = binary.into_bytes();
// The module is now validated, so we can safely parse it's types
let info = crate::jsc::module_info_polyfill::translate_module(&binary[..])
let info = crate::module_info_polyfill::translate_module(&binary[..])
.unwrap()
.info;

Expand Down
Loading

0 comments on commit bb9f246

Please sign in to comment.