summaryrefslogtreecommitdiff
path: root/src/ltable.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-10 02:08:53 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-10 02:36:36 +1100
commit562ad6f874564c3770d096711f443b49f59ef686 (patch)
tree910d919dcee89c71eaeeec8465152add19dc4e9f /src/ltable.js
parent54c4a6a66778466630cca7a9223c760942c7ab70 (diff)
downloadfengari-562ad6f874564c3770d096711f443b49f59ef686.tar.gz
fengari-562ad6f874564c3770d096711f443b49f59ef686.tar.bz2
fengari-562ad6f874564c3770d096711f443b49f59ef686.zip
src/: Fix some linter complaints
Diffstat (limited to 'src/ltable.js')
-rw-r--r--src/ltable.js101
1 files changed, 51 insertions, 50 deletions
diff --git a/src/ltable.js b/src/ltable.js
index f7b1167..cf8b1da 100644
--- a/src/ltable.js
+++ b/src/ltable.js
@@ -24,58 +24,59 @@ const get_lightuserdata_hash = function(v) {
const table_hash = function(L, key) {
switch(key.type) {
- case CT.LUA_TNIL:
- return ldebug.luaG_runerror(L, defs.to_luastring("table index is nil", true));
- case CT.LUA_TNUMFLT:
- if (isNaN(key.value))
- return ldebug.luaG_runerror(L, defs.to_luastring("table index is NaN", true));
- /* fall through */
- case CT.LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */
- case CT.LUA_TBOOLEAN:
- case CT.LUA_TTABLE:
- case CT.LUA_TLCL:
- case CT.LUA_TLCF:
- case CT.LUA_TCCL:
- case CT.LUA_TUSERDATA:
- case CT.LUA_TTHREAD:
- return key.value;
- case CT.LUA_TSHRSTR:
- case CT.LUA_TLNGSTR:
- return lstring.luaS_hashlongstr(key.tsvalue());
- case CT.LUA_TLIGHTUSERDATA:
- let v = key.value;
- switch(typeof v) {
- case "string":
- /* possible conflict with LUA_TSTRING.
- prefix this string with "*" so they don't clash */
- return "*" + v;
- case "number":
- /* possible conflict with LUA_TNUMBER.
- turn into string and prefix with "#" to avoid clash with other strings */
- return "#" + v;
- case "boolean":
- /* possible conflict with LUA_TBOOLEAN. use strings ?true and ?false instead */
- return v?"?true":"?false";
- case "function":
- /* possible conflict with LUA_TLCF.
- indirect via a weakmap */
- return get_lightuserdata_hash(v);
- case "object":
- /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */
- if ((v instanceof lstate.lua_State && v.l_G === L.l_G) ||
- v instanceof Table ||
- v instanceof lobject.Udata ||
- v instanceof lobject.LClosure ||
- v instanceof lobject.CClosure) {
- /* indirect via a weakmap */
- return get_lightuserdata_hash(v);
- }
+ case CT.LUA_TNIL:
+ return ldebug.luaG_runerror(L, defs.to_luastring("table index is nil", true));
+ case CT.LUA_TNUMFLT:
+ if (isNaN(key.value))
+ return ldebug.luaG_runerror(L, defs.to_luastring("table index is NaN", true));
/* fall through */
- default:
- return v;
+ case CT.LUA_TNUMINT: /* takes advantage of floats and integers being same in JS */
+ case CT.LUA_TBOOLEAN:
+ case CT.LUA_TTABLE:
+ case CT.LUA_TLCL:
+ case CT.LUA_TLCF:
+ case CT.LUA_TCCL:
+ case CT.LUA_TUSERDATA:
+ case CT.LUA_TTHREAD:
+ return key.value;
+ case CT.LUA_TSHRSTR:
+ case CT.LUA_TLNGSTR:
+ return lstring.luaS_hashlongstr(key.tsvalue());
+ case CT.LUA_TLIGHTUSERDATA: {
+ let v = key.value;
+ switch(typeof v) {
+ case "string":
+ /* possible conflict with LUA_TSTRING.
+ prefix this string with "*" so they don't clash */
+ return "*" + v;
+ case "number":
+ /* possible conflict with LUA_TNUMBER.
+ turn into string and prefix with "#" to avoid clash with other strings */
+ return "#" + v;
+ case "boolean":
+ /* possible conflict with LUA_TBOOLEAN. use strings ?true and ?false instead */
+ return v?"?true":"?false";
+ case "function":
+ /* possible conflict with LUA_TLCF.
+ indirect via a weakmap */
+ return get_lightuserdata_hash(v);
+ case "object":
+ /* v could be a lua_State, CClosure, LClosure, Table or Userdata from this state as returned by lua_topointer */
+ if ((v instanceof lstate.lua_State && v.l_G === L.l_G) ||
+ v instanceof Table ||
+ v instanceof lobject.Udata ||
+ v instanceof lobject.LClosure ||
+ v instanceof lobject.CClosure) {
+ /* indirect via a weakmap */
+ return get_lightuserdata_hash(v);
+ }
+ /* fall through */
+ default:
+ return v;
+ }
}
- default:
- throw new Error("unknown key type: " + key.type);
+ default:
+ throw new Error("unknown key type: " + key.type);
}
};