summaryrefslogtreecommitdiff
path: root/src/lobject.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/lobject.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/lobject.js')
-rw-r--r--src/lobject.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 119e20e..5cbf2c3 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -7,7 +7,9 @@ const defs = require('./defs.js');
const ljstype = require('./ljstype.js');
const ldebug = require('./ldebug.js');
const ldo = require('./ldo.js');
+const lstate = require('./lstate.js');
const lstring = require('./lstring.js');
+const ltable = require('./ltable.js');
const luaconf = require('./luaconf.js');
const lvm = require('./lvm.js');
const llimit = require('./llimit.js');
@@ -514,7 +516,19 @@ const luaO_pushvfstring = function(L, fmt, argp) {
ldo.luaD_inctop(L);
L.stack[L.top-1] = luaO_tostring(L, new TValue(CT.LUA_TNUMFLT, argp[a++]));
break;
- // case char['p']:
+ case char['p']:
+ let v = argp[a++];
+ if (v instanceof lstate.lua_State ||
+ v instanceof ltable.Table ||
+ v instanceof Udata ||
+ v instanceof LClosure ||
+ v instanceof CClosure) {
+ pushstr(L, defs.to_luastring("0x"+v.id.toString(16)));
+ } else {
+ /* user provided object. no id available */
+ pushstr(L, defs.to_luastring("<id NYI>"));
+ }
+ break;
case char['U']:
pushstr(L, defs.to_luastring(String.fromCodePoint(argp[a++])));
break;