From 883d01f0a707a03ef5b183cd2d03046fdc544e0e Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sun, 12 Mar 2017 10:38:13 +0100 Subject: [Strings] ltable.js, ltm.js --- src/ltable.js | 6 +++--- src/ltm.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ltable.js b/src/ltable.js index 7611b4c..36928d5 100644 --- a/src/ltable.js +++ b/src/ltable.js @@ -22,8 +22,8 @@ Table.prototype.ordered_indexes = function() { .sort(function(a, b) { if (typeof a !== "number") return 1; if (typeof b !== "number") return -1; - return a > b ? 1 : -1 - }) + return a > b ? 1 : -1; + }); }; /* @@ -64,7 +64,7 @@ Table.prototype.luaH_next = function(L, keyI) { if (tnidx === 'number' && nidx % 1 === 0) L.stack[keyI] = new TValue(CT.LUA_TNUMINT, indexes[i + 1]); else if (tnidx === 'string') - L.stack[keyI] = new TValue(CT.LUA_TLNGSTR, indexes[i + 1]); + L.stack[keyI] = L.l_G.strt.get(indexes[i + 1]); else L.stack[keyI] = indexes[i + 1]; diff --git a/src/ltm.js b/src/ltm.js index 742ce56..51ab8ec 100644 --- a/src/ltm.js +++ b/src/ltm.js @@ -63,7 +63,8 @@ const ttypename = function(t) { const luaT_init = function(L) { L.l_G.tmname = []; for (let event in TMS) { - L.l_G.tmname.push(new TValue(CT.LUA_TLNGSTR, TMS[event])); // Strings are already interned by JS + let name = lua.to_luastring(TMS[event], TMS[event].length); + L.l_G.tmname.push(L.l_G.intern(name)); // Strings are already interned by JS } }; @@ -76,7 +77,7 @@ const luaT_objtypename = function(L, o) { || (o.ttisfulluserdata() && o.metatable !== null)) { let name = o.__index(o, '__name'); if (name.ttisstring()) - return name.value; + return String.fromCharCode(...name.value); } return ttypename(o.ttnov()); -- cgit v1.2.3-70-g09d2