implement missing finalizeRef implementation from go wasm_exec.js

This commit is contained in:
Arthur Lu 2024-11-01 17:23:04 +00:00
parent 65516fbd50
commit 2c7adbef06

12
wfa.js
View File

@ -300,10 +300,14 @@
// func finalizeRef(v ref)
"syscall/js.finalizeRef": (v_ref) => {
// Note: TinyGo does not support finalizers so this should never be
// called.
//console.error('syscall/js.finalizeRef not implemented');
// for whatever reason this is called by wfajs but doesnt impact the results at all??
const id = mem().getUint32(unboxValue(v_ref), true);
this._goRefCounts[id]--;
if (this._goRefCounts[id] === 0) {
const v = this._values[id];
this._values[id] = null;
this._ids.delete(v);
this._idPool.push(id);
}
},
// func stringVal(value string) ref