Skip to content

Commit

Permalink
Revert "Merge pull request #3590 from vrurg/problem-solving-170"
Browse files Browse the repository at this point in the history
This reverts commit 2cbf583, reversing
changes made to aa5154e.
  • Loading branch information
Altai-man committed May 1, 2020
1 parent 9cabea0 commit 6d0a6bc
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/Perl6/Metamodel/Dispatchers.nqp
Expand Up @@ -20,12 +20,14 @@ class Perl6::Metamodel::BaseDispatcher {
method get_call() {
my $call := @!candidates[$!idx];
++$!idx;
if self.is_wrapper_like && self.last_candidate {
self.set_last_call_dispatchers($call);
if (nqp::can($call, 'is_dispatcher') && $call.is_dispatcher)
|| (nqp::can($call, 'is_wrapped') && $call.is_wrapped)
{
nqp::nextdispatcherfor(self, $call);
}
else {
if (nqp::can($call, 'is_dispatcher') && $call.is_dispatcher) {
nqp::nextdispatcherfor(self, $call);
if self.is_wrapper_like && self.last_candidate {
nqp::setdispatcherfor($!next_dispatcher, $call) if $!next_dispatcher;
}
else {
nqp::setdispatcherfor(self, $call);
Expand Down Expand Up @@ -176,14 +178,11 @@ class Perl6::Metamodel::MultiDispatcher is Perl6::Metamodel::BaseDispatcher {
}

class Perl6::Metamodel::WrapDispatcher is Perl6::Metamodel::BaseDispatcher {
has $!stashed_dispatcher;

method new(:@candidates, :$idx, :$invocant, :$has_invocant, :$next_dispatcher, :$stashed_dispatcher) {
method new(:@candidates, :$idx, :$invocant, :$has_invocant, :$next_dispatcher) {
my $disp := nqp::create(self);
nqp::bindattr($disp, Perl6::Metamodel::BaseDispatcher, '@!candidates', @candidates);
nqp::bindattr($disp, Perl6::Metamodel::BaseDispatcher, '$!idx', 1);
nqp::bindattr($disp, Perl6::Metamodel::BaseDispatcher, '$!next_dispatcher', $next_dispatcher);
nqp::bindattr($disp, Perl6::Metamodel::WrapDispatcher, '$!stashed_dispatcher', $stashed_dispatcher);
$disp
}

Expand All @@ -192,19 +191,10 @@ class Perl6::Metamodel::WrapDispatcher is Perl6::Metamodel::BaseDispatcher {
my $next_dispatcher := nqp::existskey($lexpad, '$*NEXT-DISPATCHER')
?? nqp::atkey($lexpad, '$*NEXT-DISPATCHER')
!! nqp::null();
my $stashed_dispatcher := nqp::existskey($lexpad, '$*DISPATCHER')
?? nqp::atkey($lexpad, '$*DISPATCHER')
!! nqp::null();
self.new(:@candidates, :idx(1), :$next_dispatcher, :$stashed_dispatcher)
self.new(:@candidates, :idx(1), :$next_dispatcher)
}

method has_invocant() { 0 }
method invocant() { NQPMu }
method is_wrapper_like() { 1 }

method set_last_call_dispatchers($call) {
nqp::setdispatcherfor($!stashed_dispatcher, $call) unless nqp::isnull($!stashed_dispatcher);
my $next_dispatcher := nqp::getattr(self, Perl6::Metamodel::BaseDispatcher, '$!next_dispatcher');
nqp::nextdispatcherfor($next_dispatcher, $call) unless nqp::isnull($next_dispatcher);
}
}

0 comments on commit 6d0a6bc

Please sign in to comment.