diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-02-22 17:32:28 +0100 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-02-22 21:15:40 +0100 |
commit | fc911817a8401d0696407e91501f0ef65f05b711 (patch) | |
tree | 828ee9d2d6d02cfc7d0365ca1495f99b3158c5cd /src/lobject.js | |
parent | 4b764aa6a84289f04acde43108425c392d2e4806 (diff) | |
download | fengari-fc911817a8401d0696407e91501f0ef65f05b711.tar.gz fengari-fc911817a8401d0696407e91501f0ef65f05b711.tar.bz2 fengari-fc911817a8401d0696407e91501f0ef65f05b711.zip |
use luaL_argerror/error instead of throwing
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lobject.js b/src/lobject.js index 2ba45ad..4e4b701 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -121,7 +121,8 @@ class Table extends TValue { static keyValue(key) { // Those lua values are used by value, others by reference if (key instanceof TValue - && [CT.LUA_TSTRING, + && [CT.LUA_TNIL, + CT.LUA_TSTRING, CT.LUA_TSHRSTR, CT.LUA_TLNGSTR, CT.LUA_TNUMINT].indexOf(key.type) > -1) { @@ -135,9 +136,9 @@ class Table extends TValue { key = Table.keyValue(key); if (typeof key === 'number' && key > 0) { - table.value.hash.set(key - 1, value); // Lua array starts at 1 + table.value.set(key - 1, value); // Lua array starts at 1 } else { - table.value.hash.set(key, value); + table.value.set(key, value); } } @@ -146,9 +147,9 @@ class Table extends TValue { let v = nil; if (typeof key === 'number' && key > 0) { - v = table.value.hash.get(key - 1); // Lua array starts at 1 + v = table.value.get(key - 1); // Lua array starts at 1 } else { - v = table.value.hash.get(key); + v = table.value.get(key); } return v ? v : nil; |