[Bps-public-commit] r12659 - pie/branches/named-params/lib/PIE

jesse at bestpractical.com jesse at bestpractical.com
Sat May 24 01:34:06 EDT 2008


Author: jesse
Date: Sat May 24 01:34:04 2008
New Revision: 12659

Modified:
   pie/branches/named-params/lib/PIE/Evaluator.pm
   pie/branches/named-params/lib/PIE/Expression.pm
   pie/branches/named-params/lib/PIE/Lambda.pm

Log:
* minor refactor

Modified: pie/branches/named-params/lib/PIE/Evaluator.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Evaluator.pm	(original)
+++ pie/branches/named-params/lib/PIE/Evaluator.pm	Sat May 24 01:34:04 2008
@@ -41,20 +41,22 @@
 
 sub enter_stack_frame {
     my $self = shift;
+    my %args = validate(@_, {args => 1});
+
     $self->stack_depth($self->stack_depth+1);
+    $self->push_stack_vars($args{'args'});
 }
 
 sub leave_stack_frame {
     my $self = shift;
     die "Trying to leave stack frame 0. Too many returns. Something relaly bad happened" if ($self->stack_depth == 0);
+    $self->pop_stack_vars();
     $self->stack_depth($self->stack_depth-1);
 }
 
 sub run {
     my $self       = shift;
     my $expression = shift;
-    $self->enter_stack_frame;
-#    warn( ("-" x $self->stack_depth) .  "$expression enter");
     eval {
         Carp::confess unless ($expression);
         my $ret = $expression->evaluate($self);
@@ -70,18 +72,9 @@
         $self->result->value(undef);
         $self->result->error($err);
     }
-
-#    warn (("-" x $self->stack_depth) , " returns : " . $self->result->value(). " - ".$self->result->success . " - " .$self->result->error);
-#    warn (("-" x $self->stack_depth),  "$expression done");
-    $self->trace();
-    
-    $self->leave_stack_frame;
     return $self->result->success;
 }
 
-sub trace{}
-
-
 sub resolve_symbol_name {
     my ($self, $name) = @_;
     my $stack = $self->stack_vars->[-1] || {};

Modified: pie/branches/named-params/lib/PIE/Expression.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Expression.pm	(original)
+++ pie/branches/named-params/lib/PIE/Expression.pm	Sat May 24 01:34:04 2008
@@ -33,7 +33,6 @@
 sub evaluate {
     my ($self, $ev) = @_;
     my $lambda = $ev->resolve_symbol_name($self->name);
-    die "Function ".$self->name." not defined"  unless $lambda;
     $ev->apply_script( $lambda, $self->args );
     return $ev->result->value;
 }

Modified: pie/branches/named-params/lib/PIE/Lambda.pm
==============================================================================
--- pie/branches/named-params/lib/PIE/Lambda.pm	(original)
+++ pie/branches/named-params/lib/PIE/Lambda.pm	Sat May 24 01:34:04 2008
@@ -55,15 +55,15 @@
 
     $self->validate_args_or_die($args);
 
-    my $arguments = $self->signature;
 
-    $evaluator->push_stack_vars( $args );
+
+    $evaluator->enter_stack_frame( args => $args);
     my $res;
     foreach my $node (@{$self->nodes}) {
        $res =  $node->evaluate($evaluator);
     }
 
-    $evaluator->pop_stack_vars( $args );
+    $evaluator->leave_stack_frame(); 
     return $res;
     #return $evaluator->result->value; 
 



More information about the Bps-public-commit mailing list