Skip to content

Commit

Permalink
Finally, Match does Positional.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jun 17, 2010
1 parent 48e2e8d commit 4cb5c39
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/core/Match.pm
@@ -1,4 +1,4 @@
class Match is Regex::Match is Cool does Associative {
class Match is Regex::Match is Cool does Positional does Associative {
method ast() {
my $x = self.Regex::Match::ast;
pir::isa__IPs($x, 'Undef') ?? Any !! $x;
Expand All @@ -8,7 +8,8 @@ class Match is Regex::Match is Cool does Associative {
~self.Regex::Match::Str;
}

multi method postcircumfix:<{ }>($key) {

method at_key($key) {
Q:PIR {
$P0 = find_lex 'self'
$P1 = find_lex '$key'
Expand All @@ -21,17 +22,10 @@ class Match is Regex::Match is Cool does Associative {
}
}

# We shouldn't need to provide this -- we should be able to
# simply write "does Positional" in the class declaration
# and it would provide us the postcircumfix:<[ ]> methods
# for free. But there seems to be a bug or problem in the
# role composer that prevents us from having both "does Positional"
# and "does Associative" in the class declaration, so we'll
# provide the simple .[] for now.
multi method postcircumfix:<[ ]>(Int $key) {
method at_pos($pos) {
Q:PIR {
$P0 = find_lex 'self'
$P1 = find_lex '$key'
$P1 = find_lex '$pos'
$I1 = $P1
%r = $P0[$I1]
unless null %r goto done
Expand All @@ -42,6 +36,8 @@ class Match is Regex::Match is Cool does Associative {
}
}

method of() { Mu }

multi method hash() {
# nextsame() dies here with 'Null PMC access in clone()'
CREATE_HASH_FROM_LOW_LEVEL(self.Regex::Match::hash);
Expand Down

0 comments on commit 4cb5c39

Please sign in to comment.