diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-29 15:42:49 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-29 15:51:01 +1000 |
commit | a5e267bf7df32e3ff6add67b7985c587fe8e3fb1 (patch) | |
tree | 5b7bacee053260221081b9c342edebae4f255ff5 /src/lapi.js | |
parent | 6d1484d41f5b5d561d21d6e497bd1ec437973464 (diff) | |
download | fengari-a5e267bf7df32e3ff6add67b7985c587fe8e3fb1.tar.gz fengari-a5e267bf7df32e3ff6add67b7985c587fe8e3fb1.tar.bz2 fengari-a5e267bf7df32e3ff6add67b7985c587fe8e3fb1.zip |
src/lapi.js: Clean up upvaluejoin
- Remember to decrement in upvaluejoin
- Last arg to getupvalref was an out arg
Diffstat (limited to 'src/lapi.js')
-rw-r--r-- | src/lapi.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lapi.js b/src/lapi.js index b08f342..f326198 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -1070,7 +1070,7 @@ const lua_len = function(L, idx) { assert(L.top <= L.ci.top, "stack overflow"); }; -const getupvalref = function(L, fidx, n, pf) { +const getupvalref = function(L, fidx, n) { let fi = index2addr(L, fidx); assert(fi.ttisLclosure(), "Lua function expected"); let f = fi.value; @@ -1086,7 +1086,7 @@ const lua_upvalueid = function(L, fidx, n) { let fi = index2addr(L, fidx); switch (fi.ttype()) { case CT.LUA_TLCL: { /* lua closure */ - return getupvalref(L, fidx, n, null).upval; + return getupvalref(L, fidx, n).upval; } case CT.LUA_TCCL: { /* C closure */ let f = fi.value; @@ -1103,10 +1103,12 @@ const lua_upvalueid = function(L, fidx, n) { const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) { let ref1 = getupvalref(L, fidx1, n1); let ref2 = getupvalref(L, fidx2, n2); - let up1 = ref1.upvalOff; + let up1 = ref1.upval; let up2 = ref2.upval; let f1 = ref1.closure; - f1.upvals[up1] = up2; + assert(up1.refcount > 0); + up1.refcount--; + f1.upvals[ref1.upvalOff] = up2; up2.refcount++; }; |