aboutsummaryrefslogtreecommitdiff
path: root/src/lauxlib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-24 14:46:19 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-24 14:48:47 +1000
commit1b48f9b50a2e4edefdffd5d33efab929296a395c (patch)
tree7cbf68f636e4969828742c389fd8a18a7d4d2705 /src/lauxlib.js
parentb754b0af38eb24df41557cb771e698972ced10ab (diff)
downloadfengari-1b48f9b50a2e4edefdffd5d33efab929296a395c.tar.gz
fengari-1b48f9b50a2e4edefdffd5d33efab929296a395c.tar.bz2
fengari-1b48f9b50a2e4edefdffd5d33efab929296a395c.zip
Implement %p specifier in luaO_pushvfstring
Move hacks out of luaL_tolstring
Diffstat (limited to 'src/lauxlib.js')
-rw-r--r--src/lauxlib.js24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 3959817..b14379c 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -490,29 +490,7 @@ const luaL_tolstring = function(L, idx) {
default:
let tt = luaL_getmetafield(L, idx, lua.to_luastring("__name", true));
let kind = tt === lua.LUA_TSTRING ? lua.lua_tostring(L, -1) : luaL_typename(L, idx);
- let p = lua.lua_topointer(L, idx);
- let id;
- switch (t) {
- case lua.LUA_TLIGHTUSERDATA:
- /* user provided object. no id available */
- id = "<id NYI>";
- break;
- case lua.LUA_TFUNCTION:
- /* light C functions are returned from lua_topointer directly */
- if (typeof p == "function") {
- id = "<id NYI>";
- break;
- }
- /* fall through */
- case lua.LUA_TTABLE:
- case lua.LUA_TTHREAD:
- case lua.LUA_TUSERDATA:
- id = `0x${p.id.toString(16)}`;
- break;
- default:
- throw Error("unhandled type: "+t);
- }
- lua.lua_pushstring(L, lua.to_luastring(`${lua.to_jsstring(kind)}: ${id}`));
+ lua.lua_pushfstring(L, lua.to_luastring("%s: %p"), kind, lua.lua_topointer(L, idx));
if (tt !== lua.LUA_TNIL)
lua.lua_remove(L, -2);
break;