diff --git a/package-lock.json b/package-lock.json index dccd891..dc262cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wasmoon-lua5.1", - "version": "1.18.5", + "version": "1.18.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wasmoon-lua5.1", - "version": "1.18.5", + "version": "1.18.6", "license": "MIT", "dependencies": { "@types/emscripten": "^1.39.10", diff --git a/package.json b/package.json index 44d9393..847a4b5 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wasmoon-lua5.1", - "version": "1.18.5", + "version": "1.18.6", "description": "A real lua 5.1 VM with JS bindings made with webassembly", "main": "dist/index.js", "scripts": { diff --git a/src/table.ts b/src/table.ts index 70446e8..16b6fe6 100644 --- a/src/table.ts +++ b/src/table.ts @@ -68,7 +68,7 @@ export class LuaTable { this.thread.pushValue(key); this.thread.luaApi.lua_gettable(this.thread.address, -2); const result = this.thread.getValue(-1); - this.thread.pop(); + this.thread.pop(2); return result; } diff --git a/test/debug.mjs b/test/debug.mjs index 38ff238..8398675 100644 --- a/test/debug.mjs +++ b/test/debug.mjs @@ -3,16 +3,10 @@ import { Lua } from '../dist/index.js'; const lua = await Lua.create(); -function test() { - return 1234; -} +lua.ctx.a = { name: 'a' }; +lua.ctx.a.b = { name: 'b' }; +lua.ctx.a.b.c = { name: 'c' }; +lua.ctx.a.b.c.d = { name: 'd' }; -for (const index of Array.from({ length: 1 }, (_, i) => i + 1)) { - console.log(index); - lua.ctx.test = test; - for (const i of Array.from({ length: 50 }, (_, i) => i + 1)) { - await lua.doString('test()'); - await lua.doString(`print(test.x)`); - await lua.doString(`test.x = ${i}`); - } -} +lua.global.dumpStack(); +console.log(lua.global.getValue(-1).$detach());