3 use Types::Standard qw(HashRef ArrayRef);
6 has predicates => (is => 'ro', isa => HashRef[Predicate], required => 1);
8 has globals => (is => 'ro', isa => DictValue, required => 1);
10 has locals => (is => 'ro', isa => ArrayRef[DictValue], required => 1);
12 #has known_facts => (is => 'ro', required => 1);
14 sub lookup_predicate {
15 my ($self, $predicate) = @_;
16 return $self->predicates->{$predicate} || die "No such predicate: $predicate";
20 my ($self, $name) = @_;
21 my $lookup_in = ($name =~ /^[_A-Z]/ ? $self->locals->[-1] : $self->globals);
22 return $lookup_in->get_member_at($name)
23 or die "No such name in scope: $name";
26 sub depth { $#{$_[0]->locals} }
30 $self->but(locals => [ @{$self->locals}[0..$to] ]);
35 if ($at =~ /^[0-9]+$/) {
36 return $self->locals->[$at];
38 return $self->globals->get_member_at($at);
42 my ($self, $at, $value) = @_;
43 if ($at =~ /^[0-9]+$/) {
44 my @locals = @{$self->locals};
45 $locals[$at] = $value;
51 globals => $self->globals->with_member_at($at, $value)
56 my ($self, @updates) = @_;
59 ($scope, @events) = ($_->apply_to($scope), @events) for @updates;
60 return ($scope, @events);