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 lex_map => (is => 'ro', isa => HashRef, required => 1);
14 #has known_facts => (is => 'ro', required => 1);
16 sub lookup_predicate {
17 my ($self, $predicate) = @_;
18 return $self->predicates->{$predicate} || die "No such predicate: $predicate";
22 my ($self, $symbol) = @_;
23 if ($symbol =~ /^[_A-Z]/) {
24 my @mapped = @{$self->lex_map->{$symbol}||[]}
25 or die "No such name in scope: $symbol";
27 $targ = $targ->get_member_at($_) for @mapped;
30 return $self->globals->get_member_at($symbol)
31 or die "No such name in scope: $symbol";
34 sub depth { $#{$_[0]->locals} }
38 $self->but(locals => [ @{$self->locals}[0..$to] ]);
43 if ($at =~ /^[0-9]+$/) {
44 return $self->locals->[$at];
46 return $self->globals->get_member_at($at);
50 my ($self, $at, $value) = @_;
51 if ($at =~ /^[0-9]+$/) {
52 my @locals = @{$self->locals};
53 $locals[$at] = $value;
59 globals => $self->globals->with_member_at($at, $value)
64 my ($self, @updates) = @_;
67 ($scope, @events) = ($_->apply_to($scope), @events) for @updates;
68 return ($scope, @events);