Skip to content

Commit

Permalink
Implement .+ and .*.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 26, 2011
1 parent 1357b60 commit ab2b93b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NOMMAP.markdown
Expand Up @@ -61,7 +61,7 @@ Many things are working, some are not...
* Try to implement enumerations
* Some support for augment
* handles
* .*, .+ and .Foo::bar
* .Foo::bar
* does and but

## Ensure nested packages work
Expand Down
23 changes: 21 additions & 2 deletions src/core/Mu.pm
Expand Up @@ -75,11 +75,30 @@ my class Mu {
}

method dispatch:<.+>($name, *@pos, *%named) {
die ".+ not yet implemented"
my @result := self.dispatch:<.*>($name, |@pos, |%named);
if @result.elems == 0 {
die "Method '$name' not found for invocant of type '" ~
self.WHAT.perl ~ "'";
}
@result
}

method dispatch:<.*>($name, *@pos, *%named) {
die ".* not yet implemented"
my @mro = self.HOW.mro(self);
my @results;
my $i = 0;
while $i < +@mro {
my $obj = @mro[$i];
my $meth = ($obj.HOW.method_table($obj)){$name};
if !$meth && $i == 0 {
$meth = ($obj.HOW.submethod_table($obj)){$name};
}
if $meth {
@results.push($meth($obj, |@pos, |%named));
}
$i++;
}
&infix:<,>(|@results)
}
}

Expand Down

0 comments on commit ab2b93b

Please sign in to comment.