[Bps-public-commit] r12599 - in pie/trunk: lib/PIE/Lambda t
clkao at bestpractical.com
clkao at bestpractical.com
Wed May 21 06:30:26 EDT 2008
Author: clkao
Date: Wed May 21 06:30:26 2008
New Revision: 12599
Modified:
pie/trunk/lib/PIE/Evaluator.pm
pie/trunk/lib/PIE/Lambda.pm
pie/trunk/lib/PIE/Lambda/Native.pm
pie/trunk/t/hello_world.t
Log:
hello jesse.
Modified: pie/trunk/lib/PIE/Evaluator.pm
==============================================================================
--- pie/trunk/lib/PIE/Evaluator.pm (original)
+++ pie/trunk/lib/PIE/Evaluator.pm Wed May 21 06:30:26 2008
@@ -53,8 +53,7 @@
}
elsif ($lambda->isa("PIE::Lambda")) {
# XXX: cleanup, unmask, etc
- $lambda->bind_expressions( $self, @exp );
- $lambda->evaluate($self);
+ $lambda->evaluate($self, @exp);
}
else {
die 'wtf';
Modified: pie/trunk/lib/PIE/Lambda.pm
==============================================================================
--- pie/trunk/lib/PIE/Lambda.pm (original)
+++ pie/trunk/lib/PIE/Lambda.pm Wed May 21 06:30:26 2008
@@ -22,6 +22,9 @@
sub evaluate {
my $self = shift;
my $evaluator = shift;
+
+ $self->bind_expressions( $evaluator, @_ );
+
foreach my $node (@{$self->nodes}) {
$evaluator->run($node);
}
Modified: pie/trunk/lib/PIE/Lambda/Native.pm
==============================================================================
--- pie/trunk/lib/PIE/Lambda/Native.pm (original)
+++ pie/trunk/lib/PIE/Lambda/Native.pm Wed May 21 06:30:26 2008
@@ -10,18 +10,16 @@
sub bind_expressions {
my ($self, $ev, @exp) = @_;
- my $bindings = $self->bindings;
- Carp::croak "unmatched number of arguments" unless $#{$bindings} == $#exp;
-
return;
- Carp::croak "unmatched number of arguments" unless $#{$bindings} == $#exp;
- $ev->set_named( $bindings->[$_] => $exp[$_] ) for 0.. $#exp;
}
sub evaluate {
my $self = shift;
my $ev = shift;
- $self->body->(map {$ev->run($_); $self->result->value } @_);
+ my $bindings = $self->bindings;
+ Carp::croak "unmatched number of arguments" unless $#{$bindings} == $#_;
+
+ $self->body->(map {$ev->run($_); $ev->result->value } @_);
}
1;
Modified: pie/trunk/t/hello_world.t
==============================================================================
--- pie/trunk/t/hello_world.t (original)
+++ pie/trunk/t/hello_world.t Wed May 21 06:30:26 2008
@@ -1,4 +1,4 @@
-use Test::More tests => 11;
+use Test::More tests => 13;
use_ok('PIE::Evaluator');
@@ -91,6 +91,9 @@
is ($hello->run('jesse'),'Hello fred');
+$hello->rules([ $hello->evaluator->get_named('make-whoever') ]);
+can_ok($hello->rules->[0], 'evaluate');
+is ($hello->run('jesse'),'Hello jesse');
1;
More information about the Bps-public-commit
mailing list