Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start to sketch out how dispatchers could look for supporting nextsam…
…e et al.
  • Loading branch information
jnthn committed Jul 10, 2011
1 parent cd4801e commit 62c04ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -648,5 +648,8 @@ my module EXPORT {
$?PACKAGE.WHO<False> := $false;
$?PACKAGE.WHO<True> := $true;
$?PACKAGE.WHO<ContainerDescriptor> := Perl6::Metamodel::ContainerDescriptor;
$?PACKAGE.WHO<MethodDispatcher> := Perl6::Metamodel::MethodDispatcher;
$?PACKAGE.WHO<MultiDispatcher> := Perl6::Metamodel::MultiDispatcher;
$?PACKAGE.WHO<WrapDispatcher> := Perl6::Metamodel::WrapDispatcher;
}
}
1 change: 1 addition & 0 deletions src/Perl6/Metamodel/Dispatchers.pm
@@ -0,0 +1 @@
class Perl6::Metamodel::MethodDispatcher { has @!methods; has $!idx; method vivify_for($sub, $lexpad) { my $obj := $lexpad['self']; my $name := $sub.name; my @methods := $obj.HOW.methods($obj, $name); self.new(:methods(@methods), :idx(1)) } method next() { my $result := @!methods[$!idx]; $!idx := $!idx + 1; $result } method last() { @!methods := []; }}class Perl6::Metamodel::MultiDispatcher { has @!candidates; has $!idx; method vivify_for($sub, $lexpad) { my $disp := $sub.dispatcher(); my $args := $lexpad['callsig']; my @cands; # XXX := pir::XXX($disp, $args); self.new(:candidates(@cands), :idx(1)) } method next() { my $result := @!candidates[$!idx]; $!idx := $!idx + 1; $result } method last() { @!candidates := []; }}class Perl6::Metamodel::WrapDispatcher { has @!wrappers; has $!idx; method new(@wrappers) { self.bless(:wrappers(@wrappers), :idx(0)) } method next() { my $result := @!wrappers[$!idx]; $!idx := $!idx + 1; $result } method last() { @!wrappers := []; }}
Expand Down
1 change: 1 addition & 0 deletions tools/build/Makefile.in
Expand Up @@ -107,6 +107,7 @@ METAMODEL_SOURCES = \
src/Perl6/Metamodel/NativeHOW.pm \
src/Perl6/Metamodel/SubsetHOW.pm \
src/Perl6/Metamodel/ContainerDescriptor.pm \
src/Perl6/Metamodel/Dispatchers.pm \
src/Perl6/Metamodel/BOOTSTRAP.pm \
src/Perl6/Metamodel/EXPORTHOW.pm \

Expand Down

0 comments on commit 62c04ce

Please sign in to comment.