diff options
| author | daurnimator <quae@daurnimator.com> | 2017-12-10 23:03:46 +1100 | 
|---|---|---|
| committer | daurnimator <quae@daurnimator.com> | 2017-12-10 23:03:46 +1100 | 
| commit | 3086e2542b0e0e41f286b6e80041b473966df882 (patch) | |
| tree | 5b348f9c419ed032a8c857db3c860116aa8cb129 /src/lobject.js | |
| parent | e8479960e53740e501501f125358be72fc919f72 (diff) | |
| parent | 085fedefe00d60eee9defa5f59a86361348e2f5c (diff) | |
| download | fengari-3086e2542b0e0e41f286b6e80041b473966df882.tar.gz fengari-3086e2542b0e0e41f286b6e80041b473966df882.tar.bz2 fengari-3086e2542b0e0e41f286b6e80041b473966df882.zip | |
Merge branch 'object-ids'
Diffstat (limited to 'src/lobject.js')
| -rw-r--r-- | src/lobject.js | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/src/lobject.js b/src/lobject.js index 97b0514..becec17 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -578,6 +578,23 @@ const luaO_pushvfstring = function(L, fmt, argp) {                      v instanceof CClosure ||                      v instanceof lfunc.UpVal) {                      pushstr(L, defs.to_luastring("0x"+v.id.toString(16))); +                } else if (v === null) { /* handle null before checking for typeof == object */ +                    pushstr(L, defs.to_luastring("null")); +                } else if (typeof v === "function" || typeof v === "object") { +                    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, defs.to_luastring("0x"+id.toString(16))); +                } else if (v === void 0) { +                    pushstr(L, defs.to_luastring("undefined")); +                } else if (typeof v === "number") { /* before check object as null is an object */ +                    pushstr(L, defs.to_luastring("Number("+v+")")); +                } else if (typeof v === "string") { /* before check object as null is an object */ +                    pushstr(L, defs.to_luastring("String("+JSON.stringify(v)+")")); +                } else if (typeof v === "boolean") { /* before check object as null is an object */ +                    pushstr(L, defs.to_luastring(v?"Boolean(true)":"Boolean(false)"));                  } else {                      /* user provided object. no id available */                      pushstr(L, defs.to_luastring("<id NYI>")); | 
