mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
dbb3211485
The file wasm_glue.js was copied from the Go wasm port and was modified, most importantly to match the TinyGo calling convention.
24 lines
441 B
JavaScript
24 lines
441 B
JavaScript
'use strict';
|
|
|
|
const WASM_URL = '../../../wasm.wasm';
|
|
|
|
var wasm;
|
|
|
|
function updateResult() {
|
|
wasm.exports.update();
|
|
}
|
|
|
|
function init() {
|
|
document.querySelector('#a').oninput = updateResult;
|
|
document.querySelector('#b').oninput = updateResult;
|
|
|
|
const go = new Go();
|
|
WebAssembly.instantiateStreaming(fetch(WASM_URL), go.importObject).then(function(obj) {
|
|
wasm = obj.instance;
|
|
go.run(wasm);
|
|
updateResult();
|
|
})
|
|
}
|
|
|
|
init();
|