Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get role to instance application implemented (operators are fully in …
…Perl 6, applicator is in NQP with one little Parrot-specific bit that we can eliminate later).
- Loading branch information
Showing
6 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
=begin | ||
|
||
=head1 TITLE | ||
Perl6::Metamodel::RoleToInstanceApplier | ||
|
||
=head1 DESCRIPTION | ||
Applies roles to an instance. | ||
|
||
=head1 METHODS | ||
=over 4 | ||
=item apply(target, composees) | ||
Applies all of the composees to an instance. | ||
|
||
=end | ||
|
||
class Perl6::Metamodel::RoleToInstanceApplier; | ||
|
||
method apply($target, @composees) { | ||
# Make anonymous subclass. | ||
my $how := $target.HOW; | ||
my $subclass := $how.new; | ||
$how.add_parent($subclass, $target.WHAT); | ||
|
||
# Add all of our given composees to it. | ||
for @composees { | ||
$how.add_composable($subclass, $_); | ||
} | ||
|
||
# Complete construction of anonymous subclass and then rebless the target | ||
# into it. XXX This bit is a tad Parrot-specific at the moment; need to | ||
# better encapsulate reblessing. | ||
my $new_class := $how.compose($subclass); | ||
pir::rebless_subclass__vPP($target, $how.get_parrotclass($new_class)); | ||
} | ||
|
||
=begin | ||
|
||
=back | ||
|
||
=end |