[Bps-public-commit] r13859 - in Lorzy/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Jul 8 11:26:29 EDT 2008


Author: sartak
Date: Tue Jul  8 11:26:28 2008
New Revision: 13859

Modified:
   Lorzy/trunk/   (props changed)
   Lorzy/trunk/lib/Lorzy/Builder.pm

Log:
 r63832 at onn:  sartak | 2008-07-08 11:26:22 -0400
 Some cleanup of Lorzy::Builder


Modified: Lorzy/trunk/lib/Lorzy/Builder.pm
==============================================================================
--- Lorzy/trunk/lib/Lorzy/Builder.pm	(original)
+++ Lorzy/trunk/lib/Lorzy/Builder.pm	Tue Jul  8 11:26:28 2008
@@ -7,7 +7,7 @@
 sub build_op_expression {
     my ($self, $name, $args) = @_;
     my $class = $name;
-    $class = "Lorzy::Expression::$name" unless ($name =~ /^Lorzy::Expression/);
+    $class = "Lorzy::Expression::$name" unless $name =~ /^Lorzy::Expression/;
     if ($class->can('meta')) {
         $name = $class;
     }
@@ -18,31 +18,48 @@
     # XXX: in case of primitive-ops, we should only bulid the args we
     # know about
 
-    my @known_args = $class eq 'Lorzy::Expression' ? keys %$args : keys %{ $class->signature };
-    return $class->new( name => $name, builder => $self, builder_args => $args,
-                        args => { map { $_ => $self->build_expression( $args->{$_} ) } @known_args } );
-
+    my @known_args = $class eq 'Lorzy::Expression'
+                   ? keys %$args
+                   : keys %{ $class->signature };
+
+    return $class->new(
+        name         => $name,
+        builder      => $self,
+        builder_args => $args,
+        args         => {
+            map { $_ => $self->build_expression( $args->{$_} ) } @known_args
+        },
+    );
 }
 
 sub build_expression {
     my ($self, $tree) = @_;
+
     if (!ref($tree)) {
         return Lorzy::Expression::String->new(args => { value => $tree} );
     }
     elsif (ref($tree) eq 'HASH') {
         return $self->build_op_expression($tree->{name}, $tree->{args});
     } else {
-        Carp::confess("Don't know what to do with a tree that looksl ike ". YAML::Dump($tree));use YAML;
+        require YAML;
+        confess "Don't know what to do with a tree that looks like "
+              . YAML::Dump($tree);
     }
 }
 
-
 sub defun {
     my $self = shift;
     my %args = validate( @_, { ops => 1, signature => 1 });
-    return Lorzy::Lambda->new( progn => Lorzy::Expression::ProgN->new(
-                                                                  nodes => [map { $self->build_expression($_) } @{$args{ops}} ]),
-                             signature => $args{signature} );
+
+    my $progn = Lorzy::Expression::ProgN->new(
+        nodes => [map { $self->build_expression($_) } @{$args{ops}} ],
+    );
+
+    return Lorzy::Lambda->new(
+        progn     => $progn,
+        signature => $args{signature},
+    );
 }
 
 1;
+



More information about the Bps-public-commit mailing list