diff options
author | daurnimator <quae@daurnimator.com> | 2017-05-22 23:34:25 +1000 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-05-23 00:52:09 +1000 |
commit | f83115f90039666b9dc19c3ee9972a3aa98d28e7 (patch) | |
tree | 2ea8b8115110a57061a00d5b706afeafd9bba4be /src | |
parent | 252284298bce111a7b2e1bea07eef54a7835c422 (diff) | |
download | fengari-f83115f90039666b9dc19c3ee9972a3aa98d28e7.tar.gz fengari-f83115f90039666b9dc19c3ee9972a3aa98d28e7.tar.bz2 fengari-f83115f90039666b9dc19c3ee9972a3aa98d28e7.zip |
src/lapi.js: Throw errors when attempting to use pseudo-index with index2addr_
Diffstat (limited to 'src')
-rw-r--r-- | src/lapi.js | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/lapi.js b/src/lapi.js index efc59aa..8e0c491 100644 --- a/src/lapi.js +++ b/src/lapi.js @@ -66,7 +66,7 @@ const index2addr = function(L, idx) { } }; -// Like index2addr but returns the index on stack +// Like index2addr but returns the index on stack; doesn't allow pseudo indices const index2addr_ = function(L, idx) { let ci = L.ci; if (idx > 0) { @@ -77,16 +77,8 @@ const index2addr_ = function(L, idx) { } else if (idx > defs.LUA_REGISTRYINDEX) { assert(idx !== 0 && -idx <= L.top, "invalid index"); return L.top + idx; - } else if (idx === defs.LUA_REGISTRYINDEX) { - return null; - } else { /* upvalues */ - idx = defs.LUA_REGISTRYINDEX - idx; - assert(idx <= MAXUPVAL + 1, "upvalue index too large"); - if (ci.func.ttislcf()) /* light C function? */ - return null; /* it has no upvalues */ - else { - return idx <= ci.func.nupvalues ? idx - 1 : null; - } + } else { /* registry or upvalue */ + throw Error("attempt to use pseudo-index"); } }; |