diff options
author | Benoit Giannangeli <giann008@gmail.com> | 2017-04-13 07:17:05 +0200 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-13 08:57:25 +0200 |
commit | d251efeb37778e2ab57a3d2c80b9df621a691796 (patch) | |
tree | fe6db792a0e9a018d10983a142724fda6e17071b /src/lobject.js | |
parent | a6dc1dbf5a439a854581927fb36fdad05d0dff4b (diff) | |
download | fengari-d251efeb37778e2ab57a3d2c80b9df621a691796.tar.gz fengari-d251efeb37778e2ab57a3d2c80b9df621a691796.tar.bz2 fengari-d251efeb37778e2ab57a3d2c80b9df621a691796.zip |
Table indexes are also starting at 1 internally
Since we use a Map we don't have to care about indexes starting at 0
Diffstat (limited to 'src/lobject.js')
-rw-r--r-- | src/lobject.js | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/lobject.js b/src/lobject.js index 618e801..cf3a52e 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -207,22 +207,13 @@ class Table extends TValue { __newindex(table, key, value) { key = Table.keyValue(key); - if (typeof key === 'number' && key > 0) { - table.value.set(key - 1, value); // Lua array starts at 1 - } else { - table.value.set(key, value); - } + table.value.set(key, value); } __index(table, key) { key = Table.keyValue(key); - let v = luaO_nilobject; - if (typeof key === 'number' && key > 0) { - v = table.value.get(key - 1); // Lua array starts at 1 - } else { - v = table.value.get(key); - } + let v = table.value.get(key); return v ? v : luaO_nilobject; } |