Skip to content

Commit

Permalink
Enhance support for crony role composition; this probably doesn't get…
Browse files Browse the repository at this point in the history
… us all the way, but what little exists of S12-role/crony.t at least now passes.
  • Loading branch information
unknown authored and unknown committed Feb 4, 2009
1 parent 0c50158 commit c8d8b2d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/builtins/guts.pir
Expand Up @@ -512,11 +512,37 @@ and creating the protoobjects.
.end


=item !meta_compose(Role metarole)

Composes roles.

=cut

.sub '!meta_compose' :multi(['Role'])
.param pmc metarole

# Parrot handles composing methods into roles, but we need to handle the
# attribute composition ourselves.
.local pmc roles, roles_it
roles = getprop '@!roles', metarole
if null roles goto roles_it_loop_end
roles_it = iter roles
roles_it_loop:
unless roles_it goto roles_it_loop_end
$P0 = shift roles_it
metarole.'add_role'($P0)
'!compose_role_attributes'(metarole, $P0)
goto roles_it_loop
roles_it_loop_end:

.return (metarole)
.end


=item !meta_compose()

Default meta composer -- does nothing.


=cut

.sub '!meta_compose' :multi()
Expand Down
1 change: 1 addition & 0 deletions src/parser/actions.pm
Expand Up @@ -1660,6 +1660,7 @@ method package_def($/, $key) {
# PIR here to do it rather than doing a call, since we need to call
# new_closure from the correct scope.
$block[0].push(PAST::Op.new(:inline(
' "!meta_compose"(%0)',
' .local pmc orig_role, meths, meth_iter',
' orig_role = getprop "$!orig_role", %0',
' meths = orig_role."methods"()',
Expand Down

0 comments on commit c8d8b2d

Please sign in to comment.