Skip to content

Commit dd93e72

Browse files
committed
Add storage slot for WHO and get_who/set_who ops.
1 parent 2b1619e commit dd93e72

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/metamodel/rakudoobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ typedef struct {
2525

2626
/* The type-object. */
2727
PMC *WHAT;
28+
29+
/* The underlying package stash. */
30+
PMC *WHO;
2831

2932
/* The method finder. */
3033
PMC * (*find_method) (PARROT_INTERP, PMC *obj, STRING *name, INTVAL hint);

src/ops/nqp.ops

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,40 @@ inline op get_what(out PMC, in PMC) :base_core {
8888

8989
/*
9090

91+
=item get_who(obj)
92+
93+
Gets the WHO for a Rakudo Object.
94+
95+
=cut
96+
97+
*/
98+
inline op get_who(out PMC, in PMC) :base_core {
99+
if ($2->vtable->base_type == ro_id)
100+
$1 = STABLE($2)->WHO;
101+
else
102+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
103+
"Can only use get_who on a RakudoObject");
104+
}
105+
106+
/*
107+
108+
=item set_who(obj)
109+
110+
Sets the WHO for a Rakudo Object.
111+
112+
=cut
113+
114+
*/
115+
inline op set_who(in PMC, in PMC) :base_core {
116+
if ($1->vtable->base_type == ro_id)
117+
STABLE($1)->WHO = $2;
118+
else
119+
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
120+
"Can only use set_who on a RakudoObject");
121+
}
122+
123+
/*
124+
91125
=item repr_type_object_for(how, repr_name)
92126

93127
Creates a type object associated with the given HOW and of the given

0 commit comments

Comments
 (0)