Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement .REPR.
  • Loading branch information
jnthn committed Nov 27, 2011
1 parent 81bbe8e commit fb11f7d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Perl6/Actions.pm
Expand Up @@ -2556,6 +2556,10 @@ class Perl6::Actions is HLL::Actions {
$past.pasttype('pirop');
$past.pirop('perl6_var PP');
}
elsif $name eq 'REPR' {
$past.pasttype('pirop');
$past.pirop('perl6_repr_name PP');
}
else {
$past.name( $name );
}
Expand Down
26 changes: 26 additions & 0 deletions src/ops/perl6.ops
Expand Up @@ -678,6 +678,32 @@ inline op perl6_var(out PMC, in PMC) :base_core {
}


/*

=item perl6_repr_name

Takes an object and returns a string containing the name of its representation.

=cut

*/
inline op perl6_repr_name(out PMC, in PMC) :base_core {
PMC *val = Rakudo_cont_decontainerize(interp, $2);
if (val->vtable->base_type == smo_id) {
PMC *type = Rakudo_types_str_get();
STRING *name = REPR(val)->name;
PMC *res = REPR(type)->allocate(interp, STABLE(type));
REPR(res)->set_str(interp, STABLE(res), OBJECT_BODY(res), name);
PARROT_GC_WRITE_BARRIER(interp, res);
$1 = res;
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Can only use perl6_repr_name with a SixModelObject");
}
}


/*

=item find_method_null_ok(out PMC, in PMC, in STR)
Expand Down

0 comments on commit fb11f7d

Please sign in to comment.