summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 0a0b615..2ba45ad 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -113,10 +113,7 @@ const nil = new TValue(CT.LUA_TNIL, null);
class Table extends TValue {
constructor(array, hash) {
- super(CT.LUA_TTABLE, {
- array: array !== undefined ? array : [],
- hash: new Map(hash)
- });
+ super(CT.LUA_TTABLE, new Map(hash));
this.metatable = null;
}
@@ -124,11 +121,9 @@ class Table extends TValue {
static keyValue(key) {
// Those lua values are used by value, others by reference
if (key instanceof TValue
- && [CT.LUA_TNUMBER,
- CT.LUA_TSTRING,
+ && [CT.LUA_TSTRING,
CT.LUA_TSHRSTR,
CT.LUA_TLNGSTR,
- CT.LUA_TNUMFLT,
CT.LUA_TNUMINT].indexOf(key.type) > -1) {
key = key.value;
}
@@ -140,7 +135,7 @@ class Table extends TValue {
key = Table.keyValue(key);
if (typeof key === 'number' && key > 0) {
- table.value.array[key - 1] = value; // Lua array starts at 1
+ table.value.hash.set(key - 1, value); // Lua array starts at 1
} else {
table.value.hash.set(key, value);
}
@@ -151,7 +146,7 @@ class Table extends TValue {
let v = nil;
if (typeof key === 'number' && key > 0) {
- v = table.value.array[key - 1]; // Lua array starts at 1
+ v = table.value.hash.get(key - 1); // Lua array starts at 1
} else {
v = table.value.hash.get(key);
}