aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-05 14:29:15 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-05 14:49:53 +0200
commita8083c0397a20233866b4f69a3e393d843fb417d (patch)
tree47d4f18aac1e0f43abe5ac8db3cd0715c89fe401 /src
parentc421f2bc81f1f1c711591a0ad0308d9eb5adb812 (diff)
downloadfengari-a8083c0397a20233866b4f69a3e393d843fb417d.tar.gz
fengari-a8083c0397a20233866b4f69a3e393d843fb417d.tar.bz2
fengari-a8083c0397a20233866b4f69a3e393d843fb417d.zip
L.openupval list was not linked correctly
Diffstat (limited to 'src')
-rw-r--r--src/lfunc.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lfunc.js b/src/lfunc.js
index cf2cfe0..7b2c557 100644
--- a/src/lfunc.js
+++ b/src/lfunc.js
@@ -8,7 +8,7 @@ const CT = defs.constant_types;
class Proto {
- constructor(L) {
+ constructor() {
this.k = []; // constants used by the function
this.p = []; // functions defined inside the function
this.code = []; // opcodes
@@ -54,10 +54,10 @@ const luaF_newLclosure = function(L, n) {
const findupval = function(L, level) {
let pp = L.openupval;
-
- while(pp !== null && pp.v >= level) {
- let p = pp;
-
+ let p = pp;
+ while (pp !== null && pp.v >= level) {
+ p = pp;
+ assert(p.isopen());
if (p.v === level)
return p;
@@ -66,11 +66,14 @@ const findupval = function(L, level) {
let uv = new UpVal();
- uv.open_next = pp;
+ if (p) { /* The openupval list is not empty */
+ uv.open_next = p; /* link it to list of open upvalues */
+ }
+
L.openupval = uv;
uv.L = L;
- uv.v = level;
+ uv.v = level; /* current value lives in the stack */
return uv;
};