Skip to content

Instantly share code, notes, and snippets.

Created July 5, 2010 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/464491 to your computer and use it in GitHub Desktop.
Save anonymous/464491 to your computer and use it in GitHub Desktop.
/*
=item deref_unless_object(out PMC, in PMC)
If the value underlying $2 is anything but an Object or P6opaque,
return that value; otherwise return $2.
=cut
*/
inline op deref_unless_object(out PMC, in PMC) :base_core {
PMC * val;
val = $2;
while (val->vtable->base_type == or_id || val->vtable->base_type == p6s_id)
val = VTABLE_get_pmc(interp, val);
$1 = (val->vtable->basetype == obj_id || val->vtable->basetype == p6o_id)
? $2 : val;
goto NEXT();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment