diff options
author | daurnimator <quae@daurnimator.com> | 2017-04-27 12:15:10 +1000 |
---|---|---|
committer | Benoit Giannangeli <giann008@gmail.com> | 2017-04-28 14:15:58 +0200 |
commit | b45dc3dd1e3f9ef4548a5e422cb6f7daa9a3ba79 (patch) | |
tree | d27f1299ae4324395367703cf311ec4d3dc54ea7 /src/ltable.js | |
parent | 86c357cd0c0184b640d0c2233ff53b6f23188d90 (diff) | |
download | fengari-b45dc3dd1e3f9ef4548a5e422cb6f7daa9a3ba79.tar.gz fengari-b45dc3dd1e3f9ef4548a5e422cb6f7daa9a3ba79.tar.bz2 fengari-b45dc3dd1e3f9ef4548a5e422cb6f7daa9a3ba79.zip |
Add table construction function
Diffstat (limited to 'src/ltable.js')
-rw-r--r-- | src/ltable.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ltable.js b/src/ltable.js index 7972f08..432a91d 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -4,7 +4,6 @@ const defs = require('./defs.js'); const lobject = require('./lobject.js'); const CT = defs.constant_types; -const TValue = lobject.TValue; const ordered_intindexes = function(table) { @@ -24,6 +23,11 @@ const ordered_indexes = function(table) { }); }; +const luaH_new = function(L) { + let t = new Map(); + return t; +}; + /* ** Try to find a boundary in table 't'. A 'boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). @@ -62,9 +66,9 @@ const luaH_next = function(L, table, keyI) { let tnidx = typeof nidx; if (tnidx === 'number' && nidx % 1 === 0) - L.stack[keyI] = new TValue(CT.LUA_TNUMINT, indexes[i + 1]); + L.stack[keyI] = new lobject.TValue(CT.LUA_TNUMINT, indexes[i + 1]); else if (tnidx === 'string') - L.stack[keyI] = new TValue(CT.LUA_TLNGSTR, indexes[i + 1].split('|').map(e => Number.parseInt(e)).slice(0, -1)); + L.stack[keyI] = new lobject.TValue(CT.LUA_TLNGSTR, indexes[i + 1].split('|').map(e => Number.parseInt(e)).slice(0, -1)); else L.stack[keyI] = indexes[i + 1]; @@ -75,5 +79,6 @@ const luaH_next = function(L, table, keyI) { return 0; }; +module.exports.luaH_new = luaH_new; module.exports.luaH_next = luaH_next; module.exports.luaH_getn = luaH_getn; |