Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
refactor/merge curr_func & getcurrenv
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Sep 29, 2009
1 parent 4696621 commit 6df18b2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/pmc/luauserdata.pmc
Expand Up @@ -28,15 +28,17 @@ _LuaUserdata_get_metatable(PARROT_INTERP, PMC *obj) {
return u_mt(obj);
}

static PMC* curr_func(PARROT_INTERP) {
static PMC* getcurrenv(PARROT_INTERP) {
PMC *sub_ctx = Parrot_pcc_get_caller_ctx(interp, CURRENT_CONTEXT(interp));
while (1) {
PMC *cont;
PMC *current_sub = Parrot_pcc_get_sub(interp, sub_ctx);
if (!PMC_IS_NULL(current_sub)
&& PMC_type(current_sub) == dynpmc_LuaFunction
&& _LuaFunction_get_environment(interp, current_sub))
return current_sub;
&& PMC_type(current_sub) == dynpmc_LuaFunction) {
PMC * const env = _LuaFunction_get_environment(interp, current_sub);
if (!PMC_IS_NULL(env))
return env;
}
cont = Parrot_pcc_get_continuation(interp, sub_ctx);
if (PMC_IS_NULL(cont))
break;
Expand All @@ -47,14 +49,6 @@ static PMC* curr_func(PARROT_INTERP) {
return NULL;
}

static PMC* getcurrenv(PARROT_INTERP) {
PMC * const sub = curr_func(interp);
if (sub) {
return _LuaFunction_get_environment(interp, sub);
}
return NULL;
}


pmclass LuaUserdata
extends LuaAny
Expand Down

0 comments on commit 6df18b2

Please sign in to comment.