Loader: support .wasm imports (#3328)

* loader: support .wasm imports

* http_server: true

* Support named exports

* Clippy
This commit is contained in:
Kevin (Kun) "Kassimo" Qian 2019-11-14 05:31:39 -08:00 committed by Ry Dahl
parent fdf0ede2ac
commit 4189cc1ab5
20 changed files with 388 additions and 9 deletions

View file

@ -0,0 +1,19 @@
const importObject = Object.create(null);
//IMPORTS
function base64ToUint8Array(data) {
const binString = window.atob(data);
const size = binString.length;
const bytes = new Uint8Array(size);
for (let i = 0; i < size; i++) {
bytes[i] = binString.charCodeAt(i);
}
return bytes;
}
const buffer = base64ToUint8Array("BASE64_DATA");
const compiled = await WebAssembly.compile(buffer);
const instance = new WebAssembly.Instance(compiled, importObject);
//EXPORTS