Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add storage slot for WHO and get_who/set_who ops.
  • Loading branch information
jnthn committed Mar 13, 2011
1 parent 2b1619e commit dd93e72
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/metamodel/rakudoobject.h
Expand Up @@ -25,6 +25,9 @@ typedef struct {

/* The type-object. */
PMC *WHAT;

/* The underlying package stash. */
PMC *WHO;

/* The method finder. */
PMC * (*find_method) (PARROT_INTERP, PMC *obj, STRING *name, INTVAL hint);
Expand Down
34 changes: 34 additions & 0 deletions src/ops/nqp.ops
Expand Up @@ -88,6 +88,40 @@ inline op get_what(out PMC, in PMC) :base_core {

/*

=item get_who(obj)

Gets the WHO for a Rakudo Object.

=cut

*/
inline op get_who(out PMC, in PMC) :base_core {
if ($2->vtable->base_type == ro_id)
$1 = STABLE($2)->WHO;
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use get_who on a RakudoObject");
}

/*

=item set_who(obj)

Sets the WHO for a Rakudo Object.

=cut

*/
inline op set_who(in PMC, in PMC) :base_core {
if ($1->vtable->base_type == ro_id)
STABLE($1)->WHO = $2;
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use set_who on a RakudoObject");
}

/*

=item repr_type_object_for(how, repr_name)

Creates a type object associated with the given HOW and of the given
Expand Down

0 comments on commit dd93e72

Please sign in to comment.