Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Capture.perl and fix Capture.BUILD
  • Loading branch information
moritz committed Feb 20, 2012
1 parent 92aeec2 commit 4130f6f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/Capture.pm
Expand Up @@ -2,7 +2,15 @@ my class Capture {
has Mu $!list;
has Mu $!hash;

submethod BUILD(:$!list, :$!hash) { }
submethod BUILD(:@list, :%hash) {
nqp::bindattr(self, Capture, '$!list',
nqp::getattr(nqp::p6decont(@list.Parcel), Parcel, '$!storage')
);
nqp::bindattr(self, Capture, '$!hash',
nqp::getattr(nqp::p6decont(%hash), EnumMap, '$!storage')
);
1;
}

method at_key(Capture:D: $key is copy) {
$key = $key.Str;
Expand Down Expand Up @@ -87,6 +95,11 @@ my class Capture {
method kv(Capture:D:) {
(self.list.kv, self.hash.kv).flat
}

multi method perl(Capture:D:) {
join '', self.^name, '.new( list => ', self.list.perl,
', hash => ', self.hash.perl, ')';
}
}

multi sub infix:<eqv>(Capture $a, Capture $b) {
Expand Down

0 comments on commit 4130f6f

Please sign in to comment.