From c43721a1ae80539aea5ea9d8d295b7e377aa03f5 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 5 Oct 2022 15:18:22 -0700 Subject: wasm2js: Support for flexible module import naming (#5114) The previous code was making emscripten-specific assumptions about imports basically all coming from the `env` module. I can't find a way to make this backwards compatible so may do a combined roll with the emscripten-side change: https://github.com/emscripten-core/emscripten/pull/17806 --- test/wasm2js/dynamicLibrary.2asm.js.opt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test/wasm2js/dynamicLibrary.2asm.js.opt') diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt index 44b3411a0..61bdab183 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js.opt +++ b/test/wasm2js/dynamicLibrary.2asm.js.opt @@ -1,5 +1,4 @@ -import { memoryBase } from 'env'; -import { tableBase } from 'env'; +import * as env from 'env'; function Table(ret) { // grow method not included; table is not growable @@ -34,10 +33,10 @@ function Table(ret) { return uint8Array; } function initActiveSegments(imports) { - base64DecodeToExistingUint8Array(bufferView, imports[memoryBase], "ZHluYW1pYyBkYXRh"); + base64DecodeToExistingUint8Array(bufferView, imports['env']['memoryBase'], "ZHluYW1pYyBkYXRh"); } -function asmFunc(importObject) { - var env = importObject.env || importObject; +function asmFunc(imports) { + var env = imports.env; var memory = env.memory; var buffer = memory.buffer; var HEAP8 = new Int8Array(buffer); @@ -67,7 +66,7 @@ function asmFunc(importObject) { } bufferView = HEAPU8; - initActiveSegments(env); + initActiveSegments(imports); var FUNCTION_TABLE = Table(new Array(10)); FUNCTION_TABLE[import$tableBase + 0] = foo; FUNCTION_TABLE[import$tableBase + 1] = foo; @@ -83,6 +82,8 @@ function asmFunc(importObject) { var memasmFunc = new ArrayBuffer(16777216); var retasmFunc = asmFunc({ + "env": { memory: { buffer : memasmFunc } + }, }); export var baz = retasmFunc.baz; -- cgit v1.2.3