Skip to content

Commit

Permalink
Regularize attribute access opcode set, and remove a level of indirec…
Browse files Browse the repository at this point in the history
…tion along the way.
  • Loading branch information
jnthn committed Sep 15, 2011
1 parent c89bd60 commit 4a0294c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PAST/SixModelPASTExtensions.pir
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ some PAST that will produce it or a name that it can be looked up by.
if primitive_type_id == STORAGE_SPEC_BP_INT goto prim_int
if primitive_type_id == STORAGE_SPEC_BP_NUM goto prim_num
if primitive_type_id == STORAGE_SPEC_BP_STR goto prim_str
.return ('P', 'getattribute', 'setattribute')
.return ('P', 'repr_get_attr_obj', 'repr_bind_attr_obj')
prim_int:
.return ('i', 'repr_get_attr_int', 'repr_bind_attr_int')
prim_num:
Expand Down
38 changes: 38 additions & 0 deletions src/ops/nqp.ops
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,25 @@ inline op repr_defined(out INT, in PMC) :base_core {

/*

=item repr_get_attr_obj()

Gets the specified object attribute. Note that the attribute must be stored as
an object - the repr is not obligated to do boxing/unboxing for you.

=cut

*/
inline op repr_get_attr_obj(out PMC, in PMC, in PMC, in STR) :base_core {
PMC *ch = decontainerize(interp, $3);
if ($2->vtable->base_type == smo_id)
$1 = REPR($2)->get_attribute(interp, $2, ch, $4, NO_HINT);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use repr_get_attr_obj on a SixModelObject");
}

/*

=item repr_get_attr_int()

Gets the specified int attribute. Note that the attribute must be stored as
Expand Down Expand Up @@ -299,6 +318,25 @@ inline op repr_get_attr_str(out STR, in PMC, in PMC, in STR) :base_core {

/*

=item repr_bind_attr_obj()

Binds the specified object attribute. Note that the attribute must be stored as
an object - the repr is not obligated to do boxing/unboxing for you.

=cut

*/
inline op repr_bind_attr_obj(in PMC, in PMC, in STR, in PMC) :base_core {
PMC *ch = decontainerize(interp, $2);
if ($1->vtable->base_type == smo_id)
REPR($1)->bind_attribute(interp, $1, ch, $3, NO_HINT, $4);
else
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use repr_bind_attr_obj on a SixModelObject");
}

/*

=item repr_bind_attr_int()

Binds the specified int attribute. Note that the attribute must be stored as
Expand Down

0 comments on commit 4a0294c

Please sign in to comment.