aboutsummaryrefslogtreecommitdiff
path: root/src/lfunc.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-23 15:02:16 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-23 15:06:01 +0100
commit6482d1ddc52f26d0a8e2e2a398276db73fbaa2bf (patch)
treeb1bddc73de8865e020add398cee358a250986385 /src/lfunc.js
parent2ffe44e84bfb72f44e4a2a598591cf0ec1c1c704 (diff)
downloadfengari-6482d1ddc52f26d0a8e2e2a398276db73fbaa2bf.tar.gz
fengari-6482d1ddc52f26d0a8e2e2a398276db73fbaa2bf.tar.bz2
fengari-6482d1ddc52f26d0a8e2e2a398276db73fbaa2bf.zip
coroutine.running, upvalue need to be attached to their thread
Diffstat (limited to 'src/lfunc.js')
-rw-r--r--src/lfunc.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lfunc.js b/src/lfunc.js
index 7057f2d..3b3c8ce 100644
--- a/src/lfunc.js
+++ b/src/lfunc.js
@@ -24,7 +24,8 @@ class Proto {
class UpVal {
- constructor() {
+ constructor(L) {
+ this.L = L; // Keep track of the thread it comes from
this.v = null; /* if null, upval is closed, value is in u.value */
this.u = {
open: { /* (when open) */
@@ -41,7 +42,7 @@ class UpVal {
setval(L, ra) {
if (this.v !== null) {
- L.stack[this.v] = L.stack[ra];
+ this.L.stack[this.v] = L.stack[ra];
this.v = ra;
} else this.u.value = L.stack[ra];
}
@@ -64,7 +65,7 @@ const findupval = function(L, level) {
pp = p.u.open.next;
}
- let uv = new UpVal();
+ let uv = new UpVal(L);
uv.refcount = 0;
uv.u.open.next = pp;
uv.u.open.touched = true;
@@ -92,7 +93,7 @@ const luaF_close = function(L, level) {
const luaF_initupvals = function(L, cl) {
for (let i = 0; i < cl.nupvalues; i++) {
- let uv = new UpVal();
+ let uv = new UpVal(L);
uv.refcount = 1;
uv.u.value = null;
uv.v = uv.u.value;