Quellcode durchsuchen

No longer use the default namespace if the imported name length is zero, so a query using empty string instead.

Michael Ferris vor 9 Jahren
Ursprung
Commit
432fd7208b
2 geänderte Dateien mit 7 neuen und 18 gelöschten Zeilen
  1. 5 16
      lib/Runtime/Library/WebAssemblyInstance.cpp
  2. 2 2
      test/wasm/api.js

+ 5 - 16
lib/Runtime/Library/WebAssemblyInstance.cpp

@@ -22,25 +22,14 @@ Var GetImportVariable(Wasm::WasmImport* wi, ScriptContext* ctx, Var ffi)
 
     const char16* name = wi->importName;
     uint32 nameLen = wi->importNameLen;
-    Var prop = nullptr;
-    if (nameLen > 0)
-    {
-        PropertyRecord const * propertyRecord = nullptr;
-        ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
+    PropertyRecord const * propertyRecord = nullptr;
+    ctx->GetOrAddPropertyRecord(name, nameLen, &propertyRecord);
 
-        if (!RecyclableObject::Is(modProp))
-        {
-            JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
-        }
-        prop = JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
-    }
-    else
+    if (!RecyclableObject::Is(modProp))
     {
-        // Use only first level if name is missing
-        prop = modProp;
+        JavascriptError::ThrowTypeError(ctx, WASMERR_InvalidImport);
     }
-
-    return prop;
+    return JavascriptOperators::OP_GetProperty(modProp, propertyRecord->GetPropertyId(), ctx);
 }
 
 WebAssemblyInstance::WebAssemblyInstance(WebAssemblyModule * wasmModule, DynamicType * type) :

+ 2 - 2
test/wasm/api.js

@@ -15,13 +15,13 @@ const imports = {
     g1: 45,
     g2: -8,
   },
-  table: new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})
+  table: {"": new WebAssembly.Table({element: "anyfunc", initial: 30, maximum: 100})}
 };
 
 function overrideImports(overrides) {
   return {
     test: Object.assign({}, imports.test, overrides),
-    table: overrides.table || imports.table
+    table: overrides.table ? {"":overrides.table} : imports.table
   };
 }