diff options
Diffstat (limited to 'src/lib_debug.c')
-rw-r--r-- | src/lib_debug.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lib_debug.c b/src/lib_debug.c index d90c422f..0330f1d2 100644 --- a/src/lib_debug.c +++ b/src/lib_debug.c | |||
@@ -224,6 +224,37 @@ LJLIB_CF(debug_setupvalue) | |||
224 | return debug_getupvalue(L, 0); | 224 | return debug_getupvalue(L, 0); |
225 | } | 225 | } |
226 | 226 | ||
227 | LJLIB_CF(debug_upvalueid) | ||
228 | { | ||
229 | GCfunc *fn = lj_lib_checkfunc(L, 1); | ||
230 | int32_t n = lj_lib_checkint(L, 2) - 1; | ||
231 | if ((uint32_t)n >= fn->l.nupvalues) | ||
232 | lj_err_arg(L, 2, LJ_ERR_IDXRNG); | ||
233 | setlightudV(L->top-1, isluafunc(fn) ? (void *)gcref(fn->l.uvptr[n]) : | ||
234 | (void *)&fn->c.upvalue[n]); | ||
235 | return 1; | ||
236 | } | ||
237 | |||
238 | LJLIB_CF(debug_upvaluejoin) | ||
239 | { | ||
240 | GCfunc *fn[2]; | ||
241 | GCRef *p[2]; | ||
242 | int i; | ||
243 | for (i = 0; i < 2; i++) { | ||
244 | int32_t n; | ||
245 | fn[i] = lj_lib_checkfunc(L, 2*i+1); | ||
246 | if (!isluafunc(fn[i])) | ||
247 | lj_err_arg(L, 2*i+1, LJ_ERR_NOLFUNC); | ||
248 | n = lj_lib_checkint(L, 2*i+2) - 1; | ||
249 | if ((uint32_t)n >= fn[i]->l.nupvalues) | ||
250 | lj_err_arg(L, 2*i+2, LJ_ERR_IDXRNG); | ||
251 | p[i] = &fn[i]->l.uvptr[n]; | ||
252 | } | ||
253 | setgcrefr(*p[0], *p[1]); | ||
254 | lj_gc_objbarrier(L, fn[0], gcref(*p[1])); | ||
255 | return 0; | ||
256 | } | ||
257 | |||
227 | /* ------------------------------------------------------------------------ */ | 258 | /* ------------------------------------------------------------------------ */ |
228 | 259 | ||
229 | static const char KEY_HOOK = 'h'; | 260 | static const char KEY_HOOK = 'h'; |