summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:28:36 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-17 07:28:36 +0100
commit0e7ae6679bc7950b93799500a7749fbe61690ffa (patch)
tree6ba3cae358f381468ea4d07ea85f40ce861aa582 /src/lapi.js
parentbe0757bcfc96dc6146d72e9536fa8e32d9a3dec7 (diff)
downloadfengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.tar.gz
fengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.tar.bz2
fengari-0e7ae6679bc7950b93799500a7749fbe61690ffa.zip
LUA_REGISTRYINDEX
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 41c0fbb..dd74552 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -35,12 +35,13 @@ const index2addr = function(L, idx) {
assert(idx <= ci.top - (ci.funcOff + 1), "unacceptable index");
if (o >= L.top) return ldo.nil;
else return L.stack[o];
- } else if (idx < 0) { // TODO: pseudo-indices relative to LUA_REGISTRYINDEX
+ } else if (idx > lua.LUA_REGISTRYINDEX) {
assert(idx !== 0 && -idx <= L.top, "invalid index");
return L.stack[L.top + idx];
- // TODO: if (idx == LUA_REGISTRYINDEX) return &G(L)->l_registry;
+ } else if (idx === lua.LUA_REGISTRYINDEX) {
+ return L.l_G.l_registry;
} else { /* upvalues */
- idx = -idx;
+ idx = lua.LUA_REGISTRYINDEX - idx;
assert(idx <= MAXUPVAL + 1, "upvalue index too large");
if (ci.func.ttislcf()) /* light C function? */
return ldo.nil; /* it has no upvalues */