aboutsummaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-02 16:37:50 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-03 12:20:43 +1000
commitcb0295e52870f22c5dd1a1726342b8d4b147b1c5 (patch)
tree3655d4d6f4873ed246c00c0eb6680a06124f3046 /src/lobject.js
parent50820e54d065bffbb504e6b20b6c27802e102c25 (diff)
downloadfengari-cb0295e52870f22c5dd1a1726342b8d4b147b1c5.tar.gz
fengari-cb0295e52870f22c5dd1a1726342b8d4b147b1c5.tar.bz2
fengari-cb0295e52870f22c5dd1a1726342b8d4b147b1c5.zip
Refactor table implementation
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 784720b..d38e276 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -18,7 +18,6 @@ class TValue {
this.id = tvalueCount++;
this.type = type;
this.value = value;
- this.metatable = null;
}
/* type tag of a TValue (bits 0-3 for tags + variant bits 4-5) */
@@ -164,41 +163,6 @@ class TValue {
const luaO_nilobject = new TValue(CT.LUA_TNIL, null);
module.exports.luaO_nilobject = luaO_nilobject;
-const table_keyValue = function(key) {
- // Those lua values are used by value, others by reference
- if (key instanceof TValue) {
- if ([CT.LUA_TNIL,
- CT.LUA_TBOOLEAN,
- CT.LUA_TSTRING,
- CT.LUA_TTHREAD,
- CT.LUA_TNUMINT].indexOf(key.type) > -1) {
- key = key.value;
- } else if ([CT.LUA_TSHRSTR, CT.LUA_TLNGSTR].indexOf(key.type) > -1) {
- key = key.value.map(e => `${e}|`).join('');
- }
- } else if (typeof key === "string") { // To avoid
- key = defs.to_luastring(key).map(e => `${e}|`).join('');
- } else if (Array.isArray(key)) {
- key = key.map(e => `${e}|`).join('');
- }
-
- return key;
-};
-
-const table_newindex = function(table, key, value) {
- key = table_keyValue(key);
-
- table.value.set(key, value);
-};
-
-const table_index = function(table, key) {
- key = table_keyValue(key);
-
- let v = table.value.get(key);
-
- return v ? v : luaO_nilobject;
-};
-
class LClosure {
constructor(L, n) {
@@ -512,6 +476,3 @@ module.exports.luaO_str2num = luaO_str2num;
module.exports.luaO_utf8desc = luaO_utf8desc;
module.exports.luaO_utf8esc = luaO_utf8esc;
module.exports.numarith = numarith;
-module.exports.table_index = table_index;
-module.exports.table_keyValue = table_keyValue;
-module.exports.table_newindex = table_newindex;