Closed kateinoigakukun closed 1 month ago
Using dir.virt.wasm attached in https://github.com/bytecodealliance/jco/issues/431, the following command generates syntactically and semantically invalid JavaScript code.
dir.virt.wasm
$ jco transpile test/fixtures/commands/dir.virt.wasm -o tmp --instantiation async
definedResourceTables
resourceTransferBorrow
instantiate
// (snip) function resourceTransferBorrow(handle, fromTid, toTid) { const fromTable = handleTables[fromTid]; const isOwn = (fromTable[(handle << 1) + 1] & T_FLAG) !== 0; const rep = isOwn ? fromTable[(handle << 1) + 1] & ~T_FLAG : rscTableRemove(fromTable, handle).rep; if (definedResourceTables[toTid]) return rep; const toTable = handleTables[toTid] || (handleTables[toTid] = [T_FLAG, 0]); const newHandle = rscTableCreateBorrow(toTable, rep); resourceCallBorrows.push({ rid: toTid, handle: newHandle }); return newHandle; } // (snip) export async function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.instantiate) { // ... (snip) const definedResourceTables = [,,,,,,,,,,,,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,]const run020 = { run: run, }; return { run: run020, 'wasi:cli/run@0.2.0': run020, }; }
Thanks for your quick fix!
Using
dir.virt.wasm
attached in https://github.com/bytecodealliance/jco/issues/431, the following command generates syntactically and semantically invalid JavaScript code.definedResourceTables
definition needs to be new-lined.resourceTransferBorrow
cannot see thedefinedResourceTables
definition because it's defined underinstantiate
scope.