1 package DX::Op::CallRule;
11 has rule_name => (is => 'ro', required => 1);
12 has rule_args => (is => 'ro', required => 1);
13 has full_name => (is => 'lazy', builder => sub {
15 join('/', $self->rule_name, scalar @{$self->rule_args});
19 my ($self, $state) = @_;
20 #warn "Call: ".$self->full_name;
21 my @args = map $self->_expand_argspec($state, $_), @{$self->rule_args};
22 my @rules = @{$state->rule_set->rules->{$self->full_name}||[]};
23 die "No rules for ${\$self->full_name}" unless @rules;
24 my $var = DX::Var->new(id => "rule:".$self->full_name)
25 ->with_stream(DX::ArrayStream->from_array(@rules));
26 my $invoke = DX::Op::FromCode->new(
28 my ($self, $state) = @_;
29 my $call = $var->bound_value->but(args => \@args);
30 $state->but(scope => {})->then($call);
33 my $ret_op = DX::Op::SetScope->new(
34 scope => $state->scope, next => $self->next
36 $state->push_return_then($ret_op, $invoke)->mark_choice($var);