Skip to content

Commit ac031d6

Browse files
committed
support streaming compilation
1 parent e49c24e commit ac031d6

File tree

2 files changed

+22
-94
lines changed

2 files changed

+22
-94
lines changed

src/adapters/webassembly/wasm-import-old.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/adapters/webassembly/wasm-import.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ exports.importWebAssembly = function (remoteEntry) {
3131

3232
const adaptedExports = Object.setPrototypeOf(
3333
{
34-
liftString: __lowerString,
35-
36-
lowerString: __lowerString,
37-
38-
liftArray: __liftArray,
39-
40-
lowerArray: __lowerArray,
41-
42-
__exports: exports,
43-
4434
getModelName () {
4535
// assembly/index/getModelName() => ~lib/string/String
4636
return __liftString(exports.getModelName() >>> 0)
@@ -176,6 +166,27 @@ exports.importWebAssembly = function (remoteEntry) {
176166
.reduce((a, b) => ({ ...a, ...b }))
177167
},
178168

169+
/**
170+
* Parse the input object into a multidimensional array of key-value pairs
171+
* and pass it as an argument to the exported wasm function. Do the reverse for
172+
* the response. Consequently, any wasm port or command function must accept a
173+
* multidemensional array of strings (numbers are converted to strings) and return
174+
* a multidimensional array of strings.
175+
*
176+
* Before they can be called, they must be registered in the wasm modelspec,
177+
* that is getPorts() and getCommands() must return appropria metadata.
178+
*
179+
* Notes:
180+
*
181+
* - for the moment, we only support strings and numbers in the input
182+
* and output objects.
183+
*
184+
* - {@link args} can also be a number, in which case, so is the return value.
185+
*
186+
* @param {string} fn exported wasm function name
187+
* @param {object|number} [args] object or number, see above
188+
* @returns {object|number} object or number, see above
189+
*/
179190
__callWasmFunction (fn, obj) {
180191
const entries = Object.entries(obj)
181192
const kv =
@@ -210,7 +221,7 @@ exports.importWebAssembly = function (remoteEntry) {
210221
new Uint32Array(memory.buffer)[pointer >>> 2]
211222
),
212223
2,
213-
fn(kv) >>> 0
224+
exports[fn](kv) >>> 0
214225
)
215226
.map(([k, v]) => ({ [k]: v }))
216227
.reduce((a, b) => ({ ...a, ...b }))

0 commit comments

Comments
 (0)