| 658 | #include "lj_libdef.h" |
| 659 | |
| 660 | LUALIB_API int luaopen_string(lua_State *L) |
| 661 | { |
| 662 | GCtab *mt; |
| 663 | global_State *g; |
| 664 | LJ_LIB_REG(L, LUA_STRLIBNAME, string); |
| 665 | #if defined(LUA_COMPAT_GFIND) && !LJ_52 |
| 666 | lua_getfield(L, -1, "gmatch"); |
| 667 | lua_setfield(L, -2, "gfind"); |
| 668 | #endif |
| 669 | mt = lj_tab_new(L, 0, 1); |
| 670 | /* NOBARRIER: basemt is a GC root. */ |
| 671 | g = G(L); |
| 672 | setgcref(basemt_it(g, LJ_TSTR), obj2gco(mt)); |
| 673 | settabV(L, lj_tab_setstr(L, mt, mmname_str(g, MM_index)), tabV(L->top-1)); |
| 674 | mt->nomm = (uint8_t)(~(1u<<MM_index)); |
| 675 | #if LJ_HASBUFFER |
| 676 | lj_lib_prereg(L, LUA_STRLIBNAME ".buffer", luaopen_string_buffer, tabV(L->top-1)); |
| 677 | #endif |
| 678 | return 1; |
| 679 | } |
| 680 |
nothing calls this directly
no test coverage detected