aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-02-28 22:31:35 +1100
committerdaurnimator <quae@daurnimator.com>2018-02-28 22:31:51 +1100
commit585b758281c599be61656eb922cb82ca934dc47f (patch)
tree39a2cb7df7ff88e13d3a9ad8518189a8172a02a7 /src
parent9c7e6a39c8a7f4843de7c19b3b151f071a222820 (diff)
downloadfengari-585b758281c599be61656eb922cb82ca934dc47f.tar.gz
fengari-585b758281c599be61656eb922cb82ca934dc47f.tar.bz2
fengari-585b758281c599be61656eb922cb82ca934dc47f.zip
src/lobject.js: Fix %p printing two ids
Diffstat (limited to 'src')
-rw-r--r--src/lobject.js59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 4b3d0aa..8896c1e 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -656,38 +656,39 @@ const luaO_pushvfstring = function(L, fmt, argp) {
v instanceof LClosure ||
v instanceof CClosure) {
pushstr(L, to_luastring("0x"+v.id.toString(16)));
- }
- switch(typeof v) {
- case "undefined":
- pushstr(L, to_luastring("undefined"));
- break;
- case "number": /* before check object as null is an object */
- pushstr(L, to_luastring("Number("+v+")"));
- break;
- case "string": /* before check object as null is an object */
- pushstr(L, to_luastring("String("+JSON.stringify(v)+")"));
- break;
- case "boolean": /* before check object as null is an object */
- pushstr(L, to_luastring(v?"Boolean(true)":"Boolean(false)"));
- break;
- case "object":
- if (v === null) { /* null is special */
- pushstr(L, to_luastring("null"));
+ } else {
+ switch(typeof v) {
+ case "undefined":
+ pushstr(L, to_luastring("undefined"));
+ break;
+ case "number": /* before check object as null is an object */
+ pushstr(L, to_luastring("Number("+v+")"));
+ break;
+ case "string": /* before check object as null is an object */
+ pushstr(L, to_luastring("String("+JSON.stringify(v)+")"));
+ break;
+ case "boolean": /* before check object as null is an object */
+ pushstr(L, to_luastring(v?"Boolean(true)":"Boolean(false)"));
+ break;
+ case "object":
+ if (v === null) { /* null is special */
+ pushstr(L, to_luastring("null"));
+ break;
+ }
+ /* fall through */
+ case "function": {
+ let id = L.l_G.ids.get(v);
+ if (!id) {
+ id = L.l_G.id_counter++;
+ L.l_G.ids.set(v, id);
+ }
+ pushstr(L, to_luastring("0x"+id.toString(16)));
break;
}
- /* fall through */
- case "function": {
- let id = L.l_G.ids.get(v);
- if (!id) {
- id = L.l_G.id_counter++;
- L.l_G.ids.set(v, id);
- }
- pushstr(L, to_luastring("0x"+id.toString(16)));
- break;
+ default:
+ /* user provided object. no id available */
+ pushstr(L, to_luastring("<id NYI>"));
}
- default:
- /* user provided object. no id available */
- pushstr(L, to_luastring("<id NYI>"));
}
break;
}