diff options
Diffstat (limited to 'src/lib_base.c')
-rw-r--r-- | src/lib_base.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index 032d5bcc..e85b7264 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
@@ -22,7 +22,9 @@ | |||
22 | #include "lj_tab.h" | 22 | #include "lj_tab.h" |
23 | #include "lj_meta.h" | 23 | #include "lj_meta.h" |
24 | #include "lj_state.h" | 24 | #include "lj_state.h" |
25 | #include "lj_bc.h" | ||
25 | #include "lj_ff.h" | 26 | #include "lj_ff.h" |
27 | #include "lj_dispatch.h" | ||
26 | #include "lj_ctype.h" | 28 | #include "lj_ctype.h" |
27 | #include "lj_lib.h" | 29 | #include "lj_lib.h" |
28 | 30 | ||
@@ -521,19 +523,25 @@ void LJ_FASTCALL lj_ffh_coroutine_wrap_err(lua_State *L, lua_State *co) | |||
521 | lj_err_run(L); | 523 | lj_err_run(L); |
522 | } | 524 | } |
523 | 525 | ||
526 | /* Forward declaration. */ | ||
527 | static void setpc_wrap_aux(lua_State *L, GCfunc *fn); | ||
528 | |||
524 | LJLIB_CF(coroutine_wrap) | 529 | LJLIB_CF(coroutine_wrap) |
525 | { | 530 | { |
526 | GCfunc *fn; | ||
527 | lj_cf_coroutine_create(L); | 531 | lj_cf_coroutine_create(L); |
528 | lua_pushcclosure(L, lj_ffh_coroutine_wrap_aux, 1); | 532 | lj_lib_pushcc(L, lj_ffh_coroutine_wrap_aux, FF_coroutine_wrap_aux, 1); |
529 | fn = funcV(L->top-1); | 533 | setpc_wrap_aux(L, funcV(L->top-1)); |
530 | fn->c.gate = lj_ff_coroutine_wrap_aux; | ||
531 | fn->c.ffid = FF_coroutine_wrap_aux; | ||
532 | return 1; | 534 | return 1; |
533 | } | 535 | } |
534 | 536 | ||
535 | #include "lj_libdef.h" | 537 | #include "lj_libdef.h" |
536 | 538 | ||
539 | /* Fix the PC of wrap_aux. Really ugly workaround. */ | ||
540 | static void setpc_wrap_aux(lua_State *L, GCfunc *fn) | ||
541 | { | ||
542 | setmref(fn->c.pc, &L2GG(L)->bcff[lj_lib_init_coroutine[1]+2]); | ||
543 | } | ||
544 | |||
537 | /* ------------------------------------------------------------------------ */ | 545 | /* ------------------------------------------------------------------------ */ |
538 | 546 | ||
539 | static void newproxy_weaktable(lua_State *L) | 547 | static void newproxy_weaktable(lua_State *L) |