@@ -16,30 +16,6 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssembly
1616
1717/** @typedef {import("../Module") } Module */
1818
19- /**
20- * @param {t.ModuleImport } n the import
21- * @returns {boolean } true, if a memory was imported
22- */
23- const isMemoryImport = n => n . descr . type === "Memory" ;
24-
25- /**
26- * @param {t.ModuleImport } n the import
27- * @returns {boolean } true, if a table was imported
28- */
29- const isTableImport = n => n . descr . type === "Table" ;
30-
31- /**
32- * @param {t.ModuleImport } n the import
33- * @returns {boolean } true, if a func was imported
34- */
35- const isFuncImport = n => n . descr . type === "FuncImportDescr" ;
36-
37- /**
38- * @param {t.ModuleImport } n the import
39- * @returns {boolean } true, if a global was imported
40- */
41- const isGlobalImport = n => n . descr . type === "GlobalType" ;
42-
4319const JS_COMPAT_TYPES = new Set ( [ "i32" , "f32" , "f64" ] ) ;
4420
4521/**
@@ -160,16 +136,16 @@ class WebAssemblyParser extends Tapable {
160136 /** @type {false | string } */
161137 let onlyDirectImport = false ;
162138
163- if ( isMemoryImport ( node ) === true ) {
139+ if ( t . isMemory ( node . descr ) === true ) {
164140 onlyDirectImport = "Memory" ;
165- } else if ( isTableImport ( node ) === true ) {
141+ } else if ( t . isTable ( node . descr ) === true ) {
166142 onlyDirectImport = "Table" ;
167- } else if ( isFuncImport ( node ) === true ) {
143+ } else if ( t . isFuncImportDescr ( node . descr ) === true ) {
168144 const incompatibleType = getJsIncompatibleType ( node . descr . signature ) ;
169145 if ( incompatibleType ) {
170146 onlyDirectImport = `Non-JS-compatible Func Sigurature (${ incompatibleType } )` ;
171147 }
172- } else if ( isGlobalImport ( node ) === true ) {
148+ } else if ( t . isGlobalType ( node . descr ) === true ) {
173149 const type = node . descr . valtype ;
174150 if ( ! JS_COMPAT_TYPES . has ( type ) ) {
175151 onlyDirectImport = `Non-JS-compatible Global Type (${ type } )` ;
@@ -185,7 +161,7 @@ class WebAssemblyParser extends Tapable {
185161
186162 state . module . addDependency ( dep ) ;
187163
188- if ( isGlobalImport ( node ) ) {
164+ if ( t . isGlobalType ( node . descr ) ) {
189165 importedGlobals . push ( node ) ;
190166 }
191167 }
0 commit comments