mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fallback to metamethod resolving for tostring in print().
This commit is contained in:
parent
fa673eb179
commit
cdc37a33b3
@ -402,8 +402,15 @@ LJLIB_CF(print)
|
|||||||
{
|
{
|
||||||
ptrdiff_t i, nargs = L->top - L->base;
|
ptrdiff_t i, nargs = L->top - L->base;
|
||||||
cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1)));
|
cTValue *tv = lj_tab_getstr(tabref(L->env), strV(lj_lib_upvalue(L, 1)));
|
||||||
int shortcut = (tv && tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring);
|
int shortcut;
|
||||||
copyTV(L, L->top++, tv ? tv : niltv(L));
|
if (tv && !tvisnil(tv)) {
|
||||||
|
copyTV(L, L->top++, tv);
|
||||||
|
} else {
|
||||||
|
setstrV(L, L->top++, strV(lj_lib_upvalue(L, 1)));
|
||||||
|
lua_gettable(L, LUA_GLOBALSINDEX);
|
||||||
|
tv = L->top-1;
|
||||||
|
}
|
||||||
|
shortcut = (tvisfunc(tv) && funcV(tv)->c.ffid == FF_tostring);
|
||||||
for (i = 0; i < nargs; i++) {
|
for (i = 0; i < nargs; i++) {
|
||||||
const char *str;
|
const char *str;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
Loading…
Reference in New Issue
Block a user